I have it, I have used a simply programmation using loops....
I have to run the multiple lm with at least 3 variables (because it needs at least 2 degrees of freedom). Many Thanks 2012/5/11 Trying To learn again <tryingtolearnag...@gmail.com> > Hi all, > > I have I got it. I see the way on my mind. I will try this week end and if > I get it I will send. > > Thanks. > > > 2012/5/10 Trying To learn again <tryingtolearnag...@gmail.com> > >> Hi all, >> >> I want to make the following: >> >> I want to run a linear regression on each column of a matrix "estima" on >> the correspondent column on the matrix "estima2". >> >> You see I want to regress estima[,1] on estima2[,1] this way to all >> columns.... >> >> At the same time I want to make a regression adding each time a new >> observation. >> >> You see, the first regression will regress only one observation with >> one observation (I now this has no sense in this only one observation step) >> >> the second turn of observation will make >> >> estima[1:2,n] on estima2[1:2,n] for all "n". >> >> Third stimation will make >> >> estima[1:3,n] on estima2[1:3,n] for all "n". >> >> And so on. >> >> Make this, I want to make an output matrix on each "t-value" associated >> with the "regressor". >> >> Conclusion my final matrix called "t value" should include al the t >> values on the regression each of them incorporating a new observation, with >> the same rows and colums than "estima". >> >> I have tried several thing but I cannot achive. >> >> I writte to see if you can guide me¡¡¡ >> >> I swear I´m trying. >> >> >> >> randz<-matrix(rnorm(5000),50,100) >> >> H<-matrix(0,50,100) >> >> H[1,]<-randz[1,] >> for (i in 2:50){ >> if(i < 26) { >> H[i, ] <- 0.6 * H[i-1, ] + randz[i, ] >> } else { >> H[i, ] <- H[i-1, ] + randz[i, ] >> } >> } >> >> >> write.table(H, file = "datad.txt") >> g<-read.table("datad.txt") >> >> hy<-nrow(g)-1 >> estima<-H[2:nrow(g), ] >> estima2<-H[ 1:hy, ] >> >> mycoef <- function (x,y) >> a<-estima >> b<-estima2 >> f<-summary(lm(a~b)) >> ff<-coef(f) >> ff[2,"t value"] >> tvalue <- sapply (2:ncol(b) , function (i){ >> y<-a[,i] >> x<-b[,i] >> mycoef(x,y) >> >> } >> ) >> print (summary(tvalue)) >> >> >> > [[alternative HTML version deleted]]
______________________________________________ R-help@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.