Learn R Programming

plm (version 2.6-4)

plm: Panel Data Estimators

Description

Linear models for panel data estimated using the lm function on transformed data.

Usage

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 plm.list print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), ... )

# 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 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, ...)

Value

An object of class "plm".

A "plm" object has the following elements :

coefficients

the vector of coefficients,

vcov

the variance--covariance matrix of the coefficients,

residuals

the vector of residuals (these are the residuals of the (quasi-)demeaned model),

weights

(only for weighted estimations) weights as specified,

df.residual

degrees of freedom of the residuals,

formula

an object of class "Formula" describing the model,

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,

ercomp

an object of class "ercomp" providing the estimation of the components of the errors (for random effects models only),

aliased

named logical vector indicating any aliased coefficients which are silently dropped by plm due to linearly dependent terms (see also detect.lindep()),

call

the call.

It has print, summary and print.summary methods. The summary method creates an object of class "summary.plm" that extends the object it is run on with information about (inter alia) F statistic and (adjusted) R-squared of model, standard errors, t--values, and p--values of coefficients, (if supplied) the furnished vcov, see summary.plm() for further details.

Arguments

formula

a symbolic description for the model to be estimated,

data

a data.frame,

subset

see stats::lm(),

weights

see stats::lm(),

na.action

see stats::lm(); currently, not fully supported,

effect

the effects introduced in the model, one of "individual", "time", "twoways", or "nested",

model

one of "pooling", "within", "between", "random" "fd", or "ht",

random.method

method of estimation for the variance components in the random effects model, one of "swar" (default), "amemiya", "walhus", "nerlove"; for Hausman-Taylor estimation set to "ht" (see Details and Examples),

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 "bvk", "baltagi", "am", or "bms" (see also Details),

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 "plm",

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 TRUE the updated model is returned, if FALSE the call is returned,

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 TRUE, the within model is plotted,

pooling

if TRUE, the pooling model is plotted,

between

if TRUE, the between model is plotted,

random

if TRUE, the random effect model is plotted,

Author

Yves Croissant

Details

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" SWAM:AROR:72plm (default), "amemiya" AMEM:71plm, "walhus" WALL:HUSS:69plm, or "nerlove" NERLO:71plm (see below for Hausman-Taylor instrumental variable case).

The nested random effect model (BALT:SONG:JUNG:01plm) is estimated by setting model = "random" and effect = "nested", requiring the data to be indexed by a third index in which the "individual" dimension is nested (see section Examples and the vignette "Estimation of error components models with the plm function".)

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 BALE:VARA:87;textualplm,

  • "baltagi" for BALT:81;textualplm,

  • "am" for AMEM:MACU:86;textualplm,

  • "bms" for BREU:MIZO:SCHM:89;textualplm.

The Hausman--Taylor estimator HAUS:TAYL:81plm is computed with arguments random.method = "ht", model = "random", inst.method = "baltagi" (the other way with only model = "ht" is deprecated).

See also the vignettes for introductions to model estimations (and more) with examples.

References

AMEM:71plm

AMEM:MACU:86plm

BALE:VARA:87plm

BALT:81plm

BALT:SONG:JUNG:01plm

BALT:13plm

BREU:MIZO:SCHM:89plm

HAUS:TAYL:81plm

NERLO:71plm

SWAM:AROR:72plm

WALL:HUSS:69plm

See Also

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). predict.plm() for predicted values.

Examples

Run this code

data("Produc", package = "plm")
zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
          data = Produc, index = c("state","year"))
summary(zz)

# 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 furnished vcov (passed as matrix, 
# as function, and as function with additional argument)
summary(wi)
summary(wi, vcov = vcovHC(wi))
summary(wi, vcov = vcovHC)
summary(wi, vcov = function(x) vcovHC(x, method = "white2"))


## 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"))
summary(plm(form, data = pProduc, model = "random", effect = "nested",
            random.method = "walhus"))

## Instrumental variable estimations
# replicate Baltagi (2013/2021), p. 133/162, table 7.1
data("Crime", package = "plm")
FE2SLS <- plm(lcrmrte ~ lprbarr + lpolpc + lprbconv + lprbpris + lavgsen +
                ldensity + lwcon + lwtuc + lwtrd + lwfir + lwser + lwmfg + lwfed +
                lwsta + lwloc + lpctymle + lpctmin + region + smsa + factor(year)
              | . - lprbarr - lpolpc + ltaxpc + lmix,
              data = Crime, model = "within")
G2SLS <- update(FE2SLS, model = "random", inst.method = "bvk")
EC2SLS <- update(G2SLS, model = "random", inst.method = "baltagi")

## Hausman-Taylor estimator and Amemiya-MaCurdy estimator
# replicate Baltagi (2005, 2013), table 7.4; Baltagi (2021), table 7.5
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)

am <- 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)

Run the code above in your browser using DataLab