I hit a problem where I want to extract all individual coefficient of a particular variable in a pooled regression.
My data look like this and I regress Y on X.
Observation name date Y X
1 A 1 Y1 X1
2 A 2 Y2 X2
3 B 1 Y3 X3
4 B 2 Y4 X4
Using the plm
package and summary, R
only gives me one coefficient of X. However, I want to have coefficient of X variable in each individual regression. Can anyone help me with this?
To clarify, what I want is all the beta associated with the X_n,1 in the below picture. Sorry for the confusion.
If you want different coefficients for the entities (split by
name
in your example), you can use the functionpvcm()
from the packageplm
to fit a OLS model per individual or do it by hand, see code example below.Building upon the example from the help page (
?pvcm
):