data
On 20 Feb 2014, at 06:07 , IZHAK shabsogh <ishaqbaba at yahoo.com> wrote:
please, how can i generate ten different estimated parameter with multiple y, response from the following response.
You did. You're just only printing the last one... (sapply(list, coef) to extract the coefficients in matrix form, if that's what you meant. Neater solutions are possible with replicate().) -pd
true.slope<-5
true.err.var<-3.7
n.iter<-100
s.sample<-10
estimates<-matrix(NA,nrow=n.iter,ncol=2)
list<-list()
s.sample<-10
x<-10*runif(s.sample)
for(i in 1:n.iter) {
+ y<-true.intercept+true.slope*x+rnorm(s.sample,mean=0, sd=true.err.var) + list[[i]]<-lm(y~x) + }
list[[i]]
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
12.133 5.447
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com