Transcription of Chapter 1 Simple Linear Regression (Part 2)
{{id}} {{{paragraph}}}
Chapter 1 Simple Linear Regression (Part 2)1 Software R and Regression analysisDownloadable from ; some useful commands setwd( ) .. to change the directory for data loading and saving .. for reading/loading data data$variable .. variable in the data plot(X, Y) .. plotting Y against X (starting a new plot); lines(X, Y).. to add lines on an existing plot. object = lm(y x).. to call lm to estimate a model and stored the calculationresults in object Exporting the plotted figure (save as .pfd, .ps or other files)Example we have 10 observations for (X, Y): ( , ), ( , ), ( , ), ( , ), ( , ), ( , ), ( , ), ( , ), ( , ), ( , ).Theyarestoredinfile( ). We hope to fit a Linear Regression modelYi= 0+ 1Xi+ i,i=1, .., ncode of R (the words after # are comments only)mydata = ( ) # read the data from the file1X = mydata$V1 # select XY = mydata$V2 # select Yplot(X, Y) # plot the observations (data)myreg = lm(Y X) # do the Linear regressionsummary(myreg) # output the estimationCoefficients:Estimate Std.
The fitted regression line/model is Yˆ =1.3931 +0.7874X For any new subject/individual withX, its prediction of E(Y)is Yˆ = b0 +b1X . For the above data, • If X = −3, then we predict Yˆ = −0.9690 • If X = 3, then we predict Yˆ =3.7553 • If X =0.5, then we predict Yˆ =1.7868 2 Properties of Least squares estimators
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}