ST512 Lab 2

ST512 Lab 2 - ST512 Assignment 2 Due Date September 14...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 of 9 ST512 Assignment 2 Due Date: September 14. Assignment Goal: Use R to conduct a computer experiment that investigates the consequences of violating an SLR assumption. We spend lots of time in statistics class emphasizing the assumptions on which different statistical methods are based. We spend less time thinking about how violations of those assumptions affect the behavior of the method. In this lab, you will conduct a computer experiment to investigate how statistical inference about the estimated slope in a SLR model is affected by a violation of the equal variance assumption. Computer experiments like the one that you will conduct here usually require enough fluency in a computer language to write a small program. The statistical software package R is particularly well suited to writing small programs. (This is one of the major selling points of R.) Because you are not expected to have this fluency with R right away, for now the programs will be provided for you. If you are interested in using R for your own research, study these programs to see how they work. First, let's work through some of the commands that you'll need to conduct the computer experiment. We are going to suppose that we are studying some relationship between a predictor x and response y where there is no linear relationship between predictor and response. That is to say, the true model is 0 0 yx β ε = +×+ or more simply 0 y = + To be concrete, let's assume that the intercept β o =1. For the time being, let's assume that the standard regression assumptions hold, and the errors are independent and identically distributed random variables with mean 0 and variance 2 1 σ = . Now let's construct a simulated data set from this model and fit a SLR to it. First, we need values of the predictor. Let's suppose that our data set will consist of 20 data points. To make life easy on ourselves, we'll generate values of the predictor by using one of R's built-in functions. Let's distribute our values of the predictor evenly between a minimum value x =0 and maximum value x =1. If you haven't done so already, launch R and type in the following command: > x.values <- seq(from=0,to=1,length=20) Now, let's generate values for the errors by randomly sampling from a normal distribution with mean 0 and variance 1:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2 of 9 > errors <- rnorm(n=20,mean=0,sd=1) (Note that the 'rnorm' function is parameterized in terms of the [s]tandard [d]eviation, not the variance. However, when the variance = 1, the standard deviation is = 1 also.) Finally, let's create values for the response by adding the errors to the intercept of 1: > y.values = 1 + errors (Note that this has the same effect as > y.values = 1 + 0 * x.values + errors ).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/22/2009 for the course ST 512 taught by Professor Dickey during the Spring '07 term at N.C. State.

Page1 / 9

ST512 Lab 2 - ST512 Assignment 2 Due Date September 14...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online