[R] save plm coefficients

Cecilia Carmo cecilia.carmo at ua.pt
Fri May 29 21:21:30 CEST 2009


Hi R-helpers,

I want to determine the coefficients of the following 
regression for several subsets, and I want to save it in a 
dataframe:
The data is in «regaccdis», «regaccdis$caedois» is the 
column that defines the subsets  and the function I have 
runned is
coef(plm(ff,data=regaccdis,na.action=na.omit,model="pooling",subset=(regaccdis$caedois==i)))
I‘ve created a dataframe named «coef» to store the 
coefficients like this :
      caedois           b1             b2               b3
1       1      0.033120395        -20.29478 
    -0.27463886
2       5   -0.040629634           74.54240 
    -0.06995842
3       10    -0.001116816         35.23986 
     0.21432718


And I runned the following regressions to obtain those 
values:
coef[1,2:4] <- 
coef(plm(ff,data=regaccdis,na.action=na.omit,model="pooling",subset=(regaccdis$caedois==1)))
coef[2,2:4] <- 
coef(plm(ff,data=regaccdis,na.action=na.omit,model="pooling",subset=(regaccdis$caedois==5)))
coef[3,2:4] <- 
coef(plm(ff,data=regaccdis,na.action=na.omit,model="pooling",subset=(regaccdis$caedois==10)))

But I need to do this more than 50 times!
Anyone could help me with a loop or with a function like 
apply?

Thank you!
Cecília (Universidade de Aveiro – Portugal)




More information about the R-help mailing list