Reputation: 55
I would like to ask if it is possible to extract coefficients for individual observations for a given variable in panel data using plm
in R, for instance using the example data:
wi <- plm(inv ~ value + capital, data = Grunfeld, model = "within", effect = "twoways")
In other words, in this example a coefficient for each of the firms in the sample.
Upvotes: 2
Views: 1427
Reputation: 3697
It is not clear to me what you are looking for:
1) "coefficients for individual observations"
vs.
2) "a coefficient for each of the firms" .
These are two different things and I believe you cannot have neither.
1) Asking for more than one coefficient for one observation does not work.
2) Asking for one coefficient per firm but trying to estimate two (value
and capital
) does not seem plausible.
Maybe this answer gives what you are looking for: Extract all individual slope coefficient from pooled OLS estimation in R
Upvotes: 1
Reputation: 2416
I think you're looking for the function fixef
in the plm package, which extracts the "fixed effects" (firm coefficients in this case). In your example:
library(plm)
data("Grunfeld")
wi <- plm(inv ~ value + capital, data = Grunfeld, model = "within", effect = "twoways")
and then run:
> fixef(wi)
1 2 3 4 5 6 7 8 9
-134.227709 72.826531 -269.458508 -38.873866 -139.666304 -31.339066 -82.761099 -66.737194 -104.010153
10
-7.390586
Upvotes: 1