Linear Statistical Model: Generating and Plotting Data Points and True Model, Lecture notes of Statistics

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

2021/2022

Uploaded on 08/05/2022

char_s67
char_s67 🇱🇺

4.5

(116)

1.9K documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Dynamic Document Example
1. A linear statistical model
Let β0= 2,β1= 1 and assume the followig relation holds true
Y=β0+β1x+,
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)
0 2 4 6 8 10
2 4 6 8 10 14
x
Y
1

Partial preview of the text

Download Linear Statistical Model: Generating and Plotting Data Points and True Model and more Lecture notes Statistics in PDF only on Docsity!

Dynamic Document Example

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)

x

Y