[datatable-help] Linear Regression problem

eg1858 emily1858 at gmail.com
Fri May 5 14:08:55 CEST 2017


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.


More information about the datatable-help mailing list