
hello,

i am new to R and trying to calculate the beta coefficient for standard linear regression for a series of randomly generated numbers. I have created this loop, but it runs really slow, is there a way to improve it?

#number of simulations
n.k<-999
#create the matrix for regression coefficients generated from #random data

beta<-matrix(0,1,n.k+1)
e<-matrix(0,tslength,n.k+1)


for(k in 1:n.k+1)
   {
    for(i in 1:tslength)
       {
        beta[1,1]<-beta1
        e[i,k]<-c(rnorm(1,0,var.all))
        beta[1,k]<-summary(lm(e[1:tslength,k]~t))$coefficient[2]
       } 
   }
thanks
Anastasia Tzortzaki
 		 	   		  
	[[alternative HTML version deleted]]

