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)
save plm coefficients
2 messages · Cecilia Carmo, Spencer Graves
I'm not sure what you are asking, especially since I do not have access to "regaccdis". However, will something like the following do what you want? caeLvls <- c(1, 5, 10) for(i in 1:3) coef[i,2:4] <- coef(plm(ff,data=regaccdis,na.action=na.omit,model="pooling",subset=(regaccdis$caedois==caeLvls[i]))) If this does NOT answer your question, PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hope this helps. Spencer
Cecilia Carmo wrote:
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)
______________________________________________ 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.