Hello,
I was assigned a problem for a math class that involves coding in R. I have
very little experience and cant make this work.
Question:
The code below produces a dataset of size n = 20 containing a random
variable X from a
uniform distribution and a random variable Y from a normal distribution.
Clearly, X and
Y are independently generated.
x <- runif(20, 0, 1)
y <- rnorm(20, 2, 2)
1. Generate 100 different datasets using the above code each of size n = 20.
You get to
observe only the generated datasets (and assume variance is unknown).
My attempt
model <- NULL
LM <-list()
x <- runif(20,0,1)
y <- rnorm(20,2,2)
#Generate 100 different datasets with n=20
for(i in 1:100) {
model<- lm(y~x)
LM[[i]] <- model
print(summary(LM[[i]])$coefficient)[2,1]
}
summary(LM[[i]])
Any help?
Thanks
--
View this message in context:
http://r.789695.n4.nabble.com/Linear-Regression-problem-tp4733405.html
Sent from the datatable-help mailing list archive at Nabble.com.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help