Skip to content
Prev 306527 / 398506 Next

Running different Regressions using for loops

Ok...I am sorry for the misunderstanding....

what I am trying to do is....
When I run...this set of statements....the 1st regression to be run, will
have Price 1, Media 1...as X variables....and in the second loop it will
have Price 1 & Media 2 ....

So, what I was thinking is...if I can generate inside the for loop....the
mean for Price 1 and Media 1 during the 1st loop....and then mean for
Price 1 and Media 2 during the second loop...and so on...for all the 10
regressions


Is the method that I was trying appropriate...or is there a better method
there...I am sorry for the earlier explanation, I hope this one makes it
more understandable


Thanks for your time...and all the quick replies




Thanks & Regards,

Krunal Nanavati
9769-919198


-----Original Message-----
From: Rui Barradas [mailto:ruipbarradas at sapo.pt]
Sent: 28 September 2012 16:49
To: Krunal Nanavati
Cc: David Winsemius; r-help at r-project.org
Subject: Re: [R] Running different Regressions using for loops

Ok, if I'm understanding it well, you want the mean value of Price1,   ,
Price5? I don't know if it makes any sense, the coefficients already are
mean values, but see if this is it.

price.coef <- sapply(lm.list, function(x) coef(x)[2])
mean(price.coef)

Rui Barradas
Em 28-09-2012 12:07, Krunal Nanavati escreveu:
right?