Reputation: 6409
I have a linear regression of the form:
Y= B0 + B1*X1 + B2*X2 + Be*Xe
If I assume values for Beta (0.38,0.27,0.10)
and also assume that Xi
are normally distributed with N(0,1)
.
How can I generate a dataset that will be a linear combination of these variables?
Upvotes: 1
Views: 1330
Reputation: 7248
If I'm understanding the question correctly, you can generate this with a simple expression:
Y <- .38 + .27 * rnorm(1000) + .10 * rnorm(1000)
which will give you a vector, Y
, distributed based on the formula above.
Upvotes: 2
Reputation: 121588
This should work:
beta =c(0.38,0.27,0.10)
beta0 <- 1
N <- 10
x <- matrix(rnorm(n=N*3) ,ncol=3) ## generate (x1,x2,xe)
y <- beta0 + x %*% beta
Upvotes: 5