plm.Rd
Linear models for panel data estimated using the lm
function on
transformed data.
plm(formula, data, subset, weights, na.action, effect = c("individual", "time", "twoways", "nested"), model = c("within", "random", "ht", "between", "pooling", "fd"), random.method = NULL, random.models = NULL, random.dfcor = NULL, inst.method = c("bvk", "baltagi", "am", "bms"), restrict.matrix = NULL, restrict.rhs = NULL, index = NULL, ...) # S3 method for panelmodel terms(x, ...) # S3 method for panelmodel vcov(object, ...) # S3 method for panelmodel fitted(object, ...) # S3 method for panelmodel residuals(object, ...) # S3 method for panelmodel df.residual(object, ...) # S3 method for panelmodel coef(object, ...) # S3 method for panelmodel print(x, digits = max(3, getOption("digits") - 2), width = getOption("width"), ...) # S3 method for panelmodel update(object, formula., ..., evaluate = TRUE) # S3 method for panelmodel deviance(object, model = NULL, ...) # S3 method for plm predict(object, newdata = NULL, ...) # S3 method for plm formula(x, ...) # S3 method for plm plot(x, dx = 0.2, N = NULL, seed = 1, within = TRUE, pooling = TRUE, between = FALSE, random = FALSE, ...) # S3 method for plm residuals(object, model = NULL, effect = NULL, ...) # S3 method for plm fitted(object, model = NULL, effect = NULL, ...)
formula | a symbolic description for the model to be estimated, |
---|---|
data | a |
subset | see |
weights | see |
na.action | see |
effect | the effects introduced in the model, one of
|
model | one of |
random.method | method of estimation for the variance
components in the random effects model, one of |
random.models | an alternative to the previous argument, the models used to compute the variance components estimations are indicated, |
random.dfcor | a numeric vector of length 2 indicating which degree of freedom should be used, |
inst.method | the instrumental variable transformation: one of
|
restrict.matrix | a matrix which defines linear restrictions on the coefficients, |
restrict.rhs | the right hand side vector of the linear restrictions on the coefficients, |
index | the indexes, |
… | further arguments. |
x, object | an object of class |
digits | number of digits for printed output, |
width | the maximum length of the lines in the printed output, |
formula. | a new formula for the update method, |
evaluate | a boolean for the update method, if |
newdata | the new data set for the |
dx | the half--length of the individual lines for the plot method (relative to x range), |
N | the number of individual to plot, |
seed | the seed which will lead to individual selection, |
within | if |
pooling | if |
between | if |
random | if |
An object of class "plm"
.
A "plm"
object has the following elements :
the vector of coefficients,
the variance--covariance matrix of the coefficients,
the vector of residuals (these are the residuals of the (quasi-)demeaned model),
(only for weighted estimations) weights as specified,
degrees of freedom of the residuals,
an object of class "pFormula"
describing the model,
the model frame as a "pdata.frame"
containing the
variables used for estimation: the response is in first column followed by
the other variables, the individual and time indexes are in the 'index'
attribute of model
,
an object of class "ercomp"
providing the
estimation of the components of the errors (for random effects
models only),
named logical vector indicating any aliased
coefficients which are silently dropped by plm
due to
linearly dependent terms (see also detect.lindep()
),
the call.
plm
is a general function for the estimation of linear panel
models. It supports the following estimation methods: pooled OLS
(model = "pooling"
), fixed effects ("within"
), random effects
("random"
), first--differences ("fd"
), and between
("between"
). It supports unbalanced panels and two--way effects
(although not with all methods).
For random effects models, four estimators of the transformation
parameter are available by setting random.method
to one of
"swar"
(Swamy and Arora 1972)
(default), "amemiya"
(Amemiya 1971)
, "walhus"
(Wallace and Hussain 1969)
, or "nerlove"
(Nerlove 1971)
.
For first--difference models, the intercept is maintained (which
from a specification viewpoint amounts to allowing for a trend in
the levels model). The user can exclude it from the estimated
specification the usual way by adding "-1"
to the model formula.
Instrumental variables estimation is obtained using two--part
formulas, the second part indicating the instrumental variables
used. This can be a complete list of instrumental variables or an
update of the first part. If, for example, the model is y ~ x1 + x2 + x3
, with x1
and x2
endogenous and z1
and z2
external
instruments, the model can be estimated with:
formula = y~x1+x2+x3 | x3+z1+z2
,
formula = y~x1+x2+x3 | . -x1-x2+z1+z2
.
If an instrument variable estimation is requested, argument
inst.method
selects the instrument variable transformation
method:
"bvk"
(default) for Balestra and Varadharajan--Krishnakumar (1987)
,
"baltagi"
for Baltagi (1981)
,
"am"
for Amemiya and MaCurdy (1986)
,
"bms"
for Breusch et al. (1989)
.
The Hausman--Taylor estimator (Hausman and Taylor 1981)
is
computed with arguments random.method = "ht"
, model = "random"
, inst.method = "baltagi"
(the other way with only
model = "ht"
is deprecated).
Amemiya T (1971). “The Estimation of the Variances in a Variance--Components Model.” International Economic Review, 12, 1--13.
Amemiya T, MaCurdy TE (1986). “Instrumental-Variable Estimation of an Error-Components Model.” Econometrica, 54(4), 869-80.
Balestra P, Varadharajan--Krishnakumar J (1987). “Full Information Estimations of a System of Simultaneous Equations With Error Components.” Econometric Theory, 3, 223--246.
Baltagi B (1981). “Simultaneous Equations With Error Components.” Journal of Econometrics, 17, 21--49.
Baltagi B, Song S, Jung B (2001). “The unbalanced nested error component regression model.” Journal of Econometrics, 101, 357-381.
Baltagi B (2013). Econometric Analysis of Panel Data, 5th edition. John Wiley and Sons ltd.
Breusch TS, Mizon GE, Schmidt P (1989). “Efficient Estimation Using Panel Data.” Econometrica, 57(3), 695-700.
Hausman J, Taylor W (1981). “Panel Data and Unobservable Individual Effects.” Econometrica, 49, 1377--1398.
Nerlove M (1971). “Further Evidence on the Estimation of Dynamic Economic Relations from a Time--Series of Cross--Sections.” Econometrica, 39, 359--382.
Swamy P, Arora S (1972). “The Exact Finite Sample Properties of the Estimators of Coefficients in the Error Components Regression Models.” Econometrica, 40, 261--275.
Wallace T, Hussain A (1969). “The Use of Error Components Models in Combining Cross Section With Time Series Data.” Econometrica, 37(1), 55--72.
summary.plm()
for further details about the associated
summary method and the "summary.plm" object both of which provide some model
tests and tests of coefficients. fixef()
to compute the fixed
effects for "within" models (=fixed effects models).
data("Produc", package = "plm") zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state","year")) summary(zz)#> Oneway (individual) effect Within Model #> #> Call: #> plm(formula = log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, #> data = Produc, index = c("state", "year")) #> #> Balanced Panel: n = 48, T = 17, N = 816 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -0.120456 -0.023741 -0.002041 0.018144 0.174718 #> #> Coefficients: #> Estimate Std. Error t-value Pr(>|t|) #> log(pcap) -0.02614965 0.02900158 -0.9017 0.3675 #> log(pc) 0.29200693 0.02511967 11.6246 < 2.2e-16 *** #> log(emp) 0.76815947 0.03009174 25.5273 < 2.2e-16 *** #> unemp -0.00529774 0.00098873 -5.3582 1.114e-07 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 18.941 #> Residual Sum of Squares: 1.1112 #> R-Squared: 0.94134 #> Adj. R-Squared: 0.93742 #> F-statistic: 3064.81 on 4 and 764 DF, p-value: < 2.22e-16# replicates some results from Baltagi (2013), table 3.1 data("Grunfeld", package = "plm") p <- plm(inv ~ value + capital, data = Grunfeld, model = "pooling") wi <- plm(inv ~ value + capital, data = Grunfeld, model = "within", effect = "twoways") swar <- plm(inv ~ value + capital, data = Grunfeld, model = "random", effect = "twoways") amemiya <- plm(inv ~ value + capital, data = Grunfeld, model = "random", random.method = "amemiya", effect = "twoways") walhus <- plm(inv ~ value + capital, data = Grunfeld, model = "random", random.method = "walhus", effect = "twoways") # summary and summary with a funished vcov (passed as matrix, # as function, and as function with additional argument) summary(wi)#> Twoways effects Within Model #> #> Call: #> plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", #> model = "within") #> #> Balanced Panel: n = 10, T = 20, N = 200 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -162.6094 -19.4710 -1.2669 19.1277 211.8420 #> #> Coefficients: #> Estimate Std. Error t-value Pr(>|t|) #> value 0.117716 0.013751 8.5604 6.653e-15 *** #> capital 0.357916 0.022719 15.7540 < 2.2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 1615600 #> Residual Sum of Squares: 452150 #> R-Squared: 0.72015 #> Adj. R-Squared: 0.67047 #> F-statistic: 217.442 on 2 and 169 DF, p-value: < 2.22e-16#> Twoways effects Within Model #> #> Note: Coefficient variance-covariance matrix supplied: vcovHC(wi) #> #> Call: #> plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", #> model = "within") #> #> Balanced Panel: n = 10, T = 20, N = 200 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -162.6094 -19.4710 -1.2669 19.1277 211.8420 #> #> Coefficients: #> Estimate Std. Error t-value Pr(>|t|) #> value 0.117716 0.009712 12.121 < 2.2e-16 *** #> capital 0.357916 0.042931 8.337 2.552e-14 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 1615600 #> Residual Sum of Squares: 452150 #> R-Squared: 0.72015 #> Adj. R-Squared: 0.67047 #> F-statistic: 74.6338 on 2 and 9 DF, p-value: 2.4936e-06#> Twoways effects Within Model #> #> Note: Coefficient variance-covariance matrix supplied: vcovHC #> #> Call: #> plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", #> model = "within") #> #> Balanced Panel: n = 10, T = 20, N = 200 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -162.6094 -19.4710 -1.2669 19.1277 211.8420 #> #> Coefficients: #> Estimate Std. Error t-value Pr(>|t|) #> value 0.117716 0.009712 12.121 < 2.2e-16 *** #> capital 0.357916 0.042931 8.337 2.552e-14 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 1615600 #> Residual Sum of Squares: 452150 #> R-Squared: 0.72015 #> Adj. R-Squared: 0.67047 #> F-statistic: 74.6338 on 2 and 9 DF, p-value: 2.4936e-06#> Twoways effects Within Model #> #> Note: Coefficient variance-covariance matrix supplied: function(x) vcovHC(x, method = "white2") #> #> Call: #> plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", #> model = "within") #> #> Balanced Panel: n = 10, T = 20, N = 200 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -162.6094 -19.4710 -1.2669 19.1277 211.8420 #> #> Coefficients: #> Estimate Std. Error t-value Pr(>|t|) #> value 0.11772 0.01881 6.2582 3.095e-09 *** #> capital 0.35792 0.03178 11.2622 < 2.2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 1615600 #> Residual Sum of Squares: 452150 #> R-Squared: 0.72015 #> Adj. R-Squared: 0.67047 #> F-statistic: 102.013 on 2 and 9 DF, p-value: 6.5484e-07# nested random effect model # replicate Baltagi/Song/Jung (2001), p. 378 (table 6), columns SA, WH # == Baltagi (2013), pp. 204-205 data("Produc", package = "plm") pProduc <- pdata.frame(Produc, index = c("state", "year", "region")) form <- log(gsp) ~ log(pc) + log(emp) + log(hwy) + log(water) + log(util) + unemp summary(plm(form, data = pProduc, model = "random", effect = "nested"))#> Nested effects Random Effect Model #> (Swamy-Arora's transformation) #> #> Call: #> plm(formula = form, data = pProduc, effect = "nested", model = "random") #> #> Balanced Panel: n = 48, T = 17, N = 816 #> #> Effects: #> var std.dev share #> idiosyncratic 0.001352 0.036765 0.191 #> individual 0.004278 0.065410 0.604 #> group 0.001455 0.038148 0.205 #> theta: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> id 0.86492676 0.8649268 0.86492676 0.86492676 0.86492676 0.86492676 #> group 0.03960556 0.0466931 0.05713605 0.05577645 0.06458029 0.06458029 #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.106171 -0.024805 -0.001816 -0.000054 0.019795 0.182810 #> #> Coefficients: #> Estimate Std. Error z-value Pr(>|z|) #> (Intercept) 2.08921088 0.14570204 14.3389 < 2.2e-16 *** #> log(pc) 0.27412419 0.02054440 13.3430 < 2.2e-16 *** #> log(emp) 0.73983766 0.02575046 28.7311 < 2.2e-16 *** #> log(hwy) 0.07273624 0.02202509 3.3024 0.0009585 *** #> log(water) 0.07645327 0.01385767 5.5170 3.448e-08 *** #> log(util) -0.09437398 0.01677289 -5.6266 1.838e-08 *** #> unemp -0.00616304 0.00090331 -6.8227 8.933e-12 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 43.035 #> Residual Sum of Squares: 1.1245 #> R-Squared: 0.97387 #> Adj. R-Squared: 0.97368 #> Chisq: 30152 on 6 DF, p-value: < 2.22e-16#> Nested effects Random Effect Model #> (Wallace-Hussain's transformation) #> #> Call: #> plm(formula = form, data = pProduc, effect = "nested", model = "random", #> random.method = "walhus") #> #> Balanced Panel: n = 48, T = 17, N = 816 #> #> Effects: #> var std.dev share #> idiosyncratic 0.001415 0.037617 0.163 #> individual 0.004507 0.067131 0.520 #> group 0.002744 0.052387 0.317 #> theta: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> id 0.86533240 0.86533240 0.86533240 0.86533240 0.86533240 0.86533240 #> group 0.05409908 0.06154491 0.07179372 0.07023704 0.07867007 0.07867007 #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.105014 -0.024736 -0.001879 -0.000056 0.019944 0.182082 #> #> Coefficients: #> Estimate Std. Error z-value Pr(>|z|) #> (Intercept) 2.08165186 0.15034855 13.8455 < 2.2e-16 *** #> log(pc) 0.27256322 0.02093384 13.0202 < 2.2e-16 *** #> log(emp) 0.74164483 0.02607167 28.4464 < 2.2e-16 *** #> log(hwy) 0.07493204 0.02234932 3.3528 0.0008001 *** #> log(water) 0.07639159 0.01386702 5.5089 3.611e-08 *** #> log(util) -0.09523031 0.01677247 -5.6778 1.365e-08 *** #> unemp -0.00614840 0.00090786 -6.7724 1.267e-11 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 40.423 #> Residual Sum of Squares: 1.1195 #> R-Squared: 0.97231 #> Adj. R-Squared: 0.9721 #> Chisq: 28403.2 on 6 DF, p-value: < 2.22e-16## Hausman-Taylor estimator and Amemiya-MaCurdy estimator ## replicate Baltagi (2005, 2013), table 7.4 data("Wages", package = "plm") ht <- plm(lwage ~ wks + south + smsa + married + exp + I(exp ^ 2) + bluecol + ind + union + sex + black + ed | bluecol + south + smsa + ind + sex + black | wks + married + union + exp + I(exp ^ 2), data = Wages, index = 595, random.method = "ht", model = "random", inst.method = "baltagi") summary(ht)#> Oneway (individual) effect Random Effect Model #> (Hausman-Taylor's transformation) #> Instrumental variable estimation #> (Baltagi's transformation) #> #> Call: #> plm(formula = lwage ~ wks + south + smsa + married + exp + I(exp^2) + #> bluecol + ind + union + sex + black + ed | bluecol + south + #> smsa + ind + sex + black | wks + married + union + exp + #> I(exp^2), data = Wages, model = "random", random.method = "ht", #> inst.method = "baltagi", index = 595) #> #> Balanced Panel: n = 595, T = 7, N = 4165 #> #> Effects: #> var std.dev share #> idiosyncratic 0.02304 0.15180 0.025 #> individual 0.88699 0.94180 0.975 #> theta: 0.9392 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -12.643736 -0.466002 0.043285 0.524739 13.340263 #> #> Coefficients: #> Estimate Std. Error z-value Pr(>|z|) #> (Intercept) 2.9127e+00 2.8365e-01 10.2687 < 2.2e-16 *** #> wks 8.3740e-04 5.9973e-04 1.3963 0.16263 #> southyes 7.4398e-03 3.1955e-02 0.2328 0.81590 #> smsayes -4.1833e-02 1.8958e-02 -2.2066 0.02734 * #> marriedyes -2.9851e-02 1.8980e-02 -1.5728 0.11578 #> exp 1.1313e-01 2.4710e-03 45.7851 < 2.2e-16 *** #> I(exp^2) -4.1886e-04 5.4598e-05 -7.6718 1.696e-14 *** #> bluecolyes -2.0705e-02 1.3781e-02 -1.5024 0.13299 #> ind 1.3604e-02 1.5237e-02 0.8928 0.37196 #> unionyes 3.2771e-02 1.4908e-02 2.1982 0.02794 * #> sexfemale -1.3092e-01 1.2666e-01 -1.0337 0.30129 #> blackyes -2.8575e-01 1.5570e-01 -1.8352 0.06647 . #> ed 1.3794e-01 2.1248e-02 6.4919 8.474e-11 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 243.04 #> Residual Sum of Squares: 4163.6 #> R-Squared: 0.60945 #> Adj. R-Squared: 0.60833 #> Chisq: 6891.87 on 12 DF, p-value: < 2.22e-16am <- plm(lwage ~ wks + south + smsa + married + exp + I(exp ^ 2) + bluecol + ind + union + sex + black + ed | bluecol + south + smsa + ind + sex + black | wks + married + union + exp + I(exp ^ 2), data = Wages, index = 595, random.method = "ht", model = "random", inst.method = "am") summary(am)#> Oneway (individual) effect Random Effect Model #> (Hausman-Taylor's transformation) #> Instrumental variable estimation #> (Amemiya-MaCurdy's transformation) #> #> Call: #> plm(formula = lwage ~ wks + south + smsa + married + exp + I(exp^2) + #> bluecol + ind + union + sex + black + ed | bluecol + south + #> smsa + ind + sex + black | wks + married + union + exp + #> I(exp^2), data = Wages, model = "random", random.method = "ht", #> inst.method = "am", index = 595) #> #> Balanced Panel: n = 595, T = 7, N = 4165 #> #> Effects: #> var std.dev share #> idiosyncratic 0.02304 0.15180 0.025 #> individual 0.88699 0.94180 0.975 #> theta: 0.9392 #> #> Residuals: #> Min. 1st Qu. Median 3rd Qu. Max. #> -12.643192 -0.464811 0.043216 0.523598 13.338789 #> #> Coefficients: #> Estimate Std. Error z-value Pr(>|z|) #> (Intercept) 2.9273e+00 2.7513e-01 10.6399 < 2.2e-16 *** #> wks 8.3806e-04 5.9945e-04 1.3980 0.16210 #> southyes 7.2818e-03 3.1936e-02 0.2280 0.81964 #> smsayes -4.1951e-02 1.8947e-02 -2.2141 0.02682 * #> marriedyes -3.0089e-02 1.8967e-02 -1.5864 0.11266 #> exp 1.1297e-01 2.4688e-03 45.7584 < 2.2e-16 *** #> I(exp^2) -4.2140e-04 5.4554e-05 -7.7244 1.124e-14 *** #> bluecolyes -2.0850e-02 1.3765e-02 -1.5147 0.12986 #> ind 1.3629e-02 1.5229e-02 0.8949 0.37082 #> unionyes 3.2475e-02 1.4894e-02 2.1804 0.02922 * #> sexfemale -1.3201e-01 1.2660e-01 -1.0427 0.29709 #> blackyes -2.8590e-01 1.5549e-01 -1.8388 0.06595 . #> ed 1.3720e-01 2.0570e-02 6.6703 2.553e-11 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Total Sum of Squares: 243.04 #> Residual Sum of Squares: 4160.3 #> R-Squared: 0.60948 #> Adj. R-Squared: 0.60835 #> Chisq: 6879.2 on 12 DF, p-value: < 2.22e-16