Learn R Programming

The plm Package - Linear Models and Tests for Panel Data

About

plm is a package for panel data econometrics for the R statistical computing environment. The package includes functions for model estimation, testing, robust covariance matrix estimation, panel data manipulation and information. It was first published on CRAN in 2006.

Be sure to read the NEWS on CRAN (or in the development repository) for any changes in new releases (new features, bugfixes, other improvements, ...).

Non-exhaustive function overview:

  • Functions to estimate models:

    • plm: panel data estimators (within/fixed effects, random effects, between, first-difference, nested random effects), incl. instrumental-variable estimation techniques (IV) and Hausman-Taylor-style models,
    • pgmm: generalized method of moments (GMM) estimation for panel data,
    • pggls: estimation of general feasible generalized least squares models,
    • pmg: mean groups (MG), demeaned MG and common correlated effects (CCEMG) estimators,
    • pcce: estimators for common correlated effects mean groups (CCEMG) and pooled (CCEP) for panel data with common factors,
    • pvcm: variable coefficients models,
    • pldv: panel estimators for limited dependent variables.
  • Testing functions:

    • model specification (phtest, pFtest, pooltest, plmtest, pwaldtest, piest, aneweytest, mtest, sargan),
    • serial correlation (pbgtest, pwfdtest, pbnftest, pdwtest, pwartest, pbsytest, pbltest),
    • cross-sectional dependence (pcdtest),
    • panel unit root (purtest, cipstest, phansitest),
    • panel Granger (non-)causality (pgrangertest).
  • Robust covariance matrix estimators (incl. various weighting schemes for small sample adjustment):

    • vcovHC: Arellano (1987), White (1980),
    • vcovBK: Beck and Katz (1995) (PCSE),
    • vcovNW: Newey and West (1987),
    • vcovDC: double-clustering robust (Thompson (2011), Cameron et al. (2011)),
    • vcovSCC: Driscoll and Kraay (1998).
  • An enhanced data frame, called pdata.frame, to deal with data sets for which observations are identified by a combination of two indexes.

  • Panel data transformation functions (e.g., Within, Between, between, lag, lead, diff).

  • Other functions relating to panel data sets, e.g.:

    • checks for panel data dimensions (individual, time, group) and balancedness (pdim),
    • checks for panel balancedness (is.pbalanced) and consecutiveness (regularity) (is.pconsecutive) as well as functions to change data to conform to these properties (make.pbalanced, make.pconsecutive),
    • measures for unbalancedness of data (punbalancedness) (Ahrens/Pincus (1981)).

Installation

To install the released version from CRAN:

install.packages("plm")

The package's CRAN website is https://cran.r-project.org/package=plm.

The development of package plm takes place on GitHub at https://github.com/ycroissant/plm. To install the development version from GitHub, use, e.g.:

# install.packages("remotes") # remove '#' if pkg 'remotes' is not installed
remotes::install_github("ycroissant/plm")

Documentation

Package plm comes with documentation: Besides the usual help pages for each function, the vignettes provide a gentle introduction to the package and some functions. Vignettes are available at the package's CRAN website https://cran.r-project.org/package=plm and can be browsed from within R by browseVignettes("plm").

New package users are advised to start with the first vignette Panel data econometrics in R: the plm package for an overview of the package. A more in-depth treatment of estimation of error component models and instrument variable models is in the second vignette Estimation of error component models with the plm function.

Further, many textbooks treat package plm and/or use it in their examples:

  • Croissant/Millo, Panel Data Econometrics with R, 2019, John Wiley & Sons, Hoboken.

  • Kleiber/Zeileis, Applied Econometrics with R, 2008, Springer, New York. Esp. chapter 3.6.

  • Hanck/Arnold/Gerber/Schmelzer, Econometrics with R, online book https://www.econometrics-with-r.org/. Esp. chapter 10.

  • Heiss, Using R for Introductory Econometrics, 2nd edition, 2020, Independent Publishing, Düsseldorf, also available online at http://www.urfie.net/. A companion book using R to Wooldridge, Introductory Econometrics, esp. chapters 13-14.

Copy Link

Version

Install

install.packages('plm')

Monthly Downloads

36,447

Version

2.6-5

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Kevin Tappe

Last Published

January 17th, 2025

Functions in plm (2.6-5)

Gasoline

Gasoline Consumption
fixef.plm

Extract the Fixed Effects
LaborSupply

Wages and Hours Worked
Hedonic

Hedonic Prices of Census Tracts in the Boston Area
Crime

Crime in North Carolina
Cigar

Cigarette Consumption
Males

Wages and Education of Young Males
pbsytest

Bera, Sosa-Escudero and Yoon Locally--Robust Lagrange Multiplier Tests for Panel Models and Joint Test by Baltagi and Li
ercomp

Estimation of the error components
has.intercept

Check for the presence of an intercept in a formula or in a fitted model
detect.lindep

Functions to detect linear dependence
SumHes

The Penn World Table, v. 5
is.pseries

Check if an object is a pseries
Wages

Panel Data of Individual Wages
make.pconsecutive

Make data consecutive (and, optionally, also balanced)
Grunfeld

Grunfeld's Investment Data
Parity

Purchasing Power Parity and other parity relationships
pcdtest

Tests of cross-section dependence for panel models
is.pconsecutive

Check if time periods are consecutive
pFtest

F Test for Individual and/or Time Effects
lag.plm

lag, lead, and diff for panel data
index.plm

Extract the indexes of panel data
make.pbalanced

Make data balanced
RiceFarms

Production of Rice in Indonesia
r.squared

R squared and adjusted R squared for panel models
pbgtest

Breusch--Godfrey Test for Panel Models
pht

Hausman--Taylor Estimator for Panel Data
Produc

US States Production
pdata.frame

pdata.frame: a data.frame for panel data
Snmesp

Employment and Wages in Spain
pseriesfy

Turn all columns of a pdata.frame into class pseries.
plm-deprecated

Deprecated functions of plm
phtest

Hausman Test for Panel Models
sargan

Hansen--Sargan Test of Overidentifying Restrictions
pwtest

Wooldridge's Test for Unobserved Effects in Panel Models
plm

Panel Data Estimators
cortab

Cross--sectional correlation matrix
cipstest

Cross-sectionally Augmented IPS Test for Unit Roots in Panel Models
pbltest

Baltagi and Li Serial Dependence Test For Random Effects Models
aneweytest

Angrist and Newey's version of Chamberlain test for fixed effects
vcovNW

Newey and West (1987) Robust Covariance Matrix Estimator
pbnftest

Modified BNF--Durbin--Watson Test and Baltagi--Wu's LBI Test for Panel Models
within_intercept

Overall Intercept for Within Models Along its Standard Error
vcovSCC

Driscoll and Kraay (1998) Robust Covariance Matrix Estimator
pgrangertest

Panel Granger (Non-)Causality Test (Dumitrescu/Hurlin (2012))
pggls

General FGLS Estimators
EmplUK

Employment and Wages in the United Kingdom
make.dummies

Create a Dummy Matrix
pcce

Common Correlated Effects estimators
model.frame.pdata.frame

model.frame and model.matrix for panel data
plm.fast

Option to Switch On/Off Fast Data Transformations
phansitest

Simes Test for unit roots in panel data
plmtest

Lagrange FF Multiplier Tests for Panel Models
piest

Chamberlain estimator and test for fixed effects
punbalancedness

Measures for Unbalancedness of Panel Data
mtest

Arellano--Bond Test of Serial Correlation
summary.plm.list

Summary for plm objects
pwartest

Wooldridge Test for AR(1) Errors in FE Panel Models
pwfdtest

Wooldridge first--difference--based test for AR(1) errors in levels or first--differenced panel models
pldv

Panel estimators for limited dependent variables
pgmm

Generalized Method of Moments (GMM) Estimation for Panel Data
plm-package

plm package: linear models for panel data
pmg

Mean Groups (MG), Demeaned MG and CCE MG estimators
pmodel.response

A function to extract the model.response
vcovG

Generic Lego building block for Robust Covariance Matrix Estimators
is.pbalanced

Check if data are balanced
pvcm

Variable Coefficients Models for Panel Data
purtest

Unit root tests for panel data
vcovDC

Double-Clustering Robust Covariance Matrix Estimator
vcovHC.plm

Robust Covariance Matrix Estimators
vcovBK

Beck and Katz Robust Covariance Matrix Estimators
pooltest

Test of Poolability
ranef.plm

Extract the Random Effects
pwaldtest

Wald-style Chi-square Test and F Test
pdim

Check for the Dimensions of the Panel
re-export_functions

Functions exported from other packages
nobs.plm

Extract Total Number of Observations Used in Estimated Panelmodel
pdwtest

Durbin--Watson Test for Panel Models
pseries

panel series
predict.plm

Model Prediction for plm Objects
pvar

Check for Cross-Sectional and Time Variation