
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An example of generating 100 observations from a linear statistical model using r programming language and plotting the data points along with the true linear model. The model is defined by the equation y = β0 + β1x + ε, where x ∈ [0, 10], β0 = 2, β1 = 1, and ε ∼ n(0, σ2) with σ2 = 1.
Typology: Lecture notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

1. A linear statistical model
Let β 0 = 2, β 1 = 1 and assume the followig relation holds true
Y = β 0 + β 1 x + ,
where x ∈ [0 , 10], and ∼ N (0 , σ^2 ), with σ^2 = 1.
The following R code generates 100 observations from the statistical model above. Then the data points are plotted as well as the true linear model.
set.seed (123) x= seq (0,10,length.out=100) f=2+x Y=f+ rnorm (100) plot (x,Y) abline (2,1,col=2)