Generalized Linear Models for Panel Data

Provides generalized linear models for panel data, including pooled, fixed-effects, and random-effects estimators for continuous, binary, count, ordinal, positive (gamma), and bounded (beta) outcomes, with the fixed-effects ordered logit of Baetschmann, Staub and Winkelmann (2015) and beta regression (Ferrari and Cribari-Neto 2004) . Also offers correlated random effects (Mundlak 1978) , dynamic models with the Wooldridge (2005) initial conditions solution, observation weights, average partial effects, regression-spline curves and linearity tests, difference-in-differences and event studies, and two-part models for costs (Duan et al. 1983) , including correlated random intercepts (Van Ourti 2004) . Estimators and tests follow standard panel-data references, including Hausman (1978) , Chamberlain (1980) , Allison and Waterman (2002) , and Croissant and Millo (2008) . Core numerical routines are implemented using 'Rcpp', 'RcppArmadillo', and 'RcppParallel'.


panglm panglm logo

CRANstatus R-CMD-check License:MIT

panglm fits regression models for panel data (pooled, fixed effects, random effects and the estimators built on them) for the outcomes and designs of applied health econometrics, from one formula interface and one set of post-estimation tools (robust and cluster covariances, partial effects, specification tests, prediction and tidy output).

Installation

# release from CRAN
install.packages("panglm")

# development version from GitHub
# install.packages("remotes")
remotes::install_github("ielbadisy/panglm")

What it fits

Task Function
Continuous, binary, count, ordered, positive, bounded and censored outcomes (pooled, within, between, random effects) panglm()
Random slopes panglm(model = "random", random = ~ x)
Costs with zeros (two-part model) twopart()
Counts with structural zeros panhurdle()
Difference-in-differences and event studies did(), eventstudy()
Staggered adoption attgt(), etwfe()
Instrumental variables and Hausman-Taylor paniv()
Dynamic panels (difference and system GMM) pangmm()
Sample selection panselect()
Quantile regression panqr()
Latent classes panfmm(), panfmmselect()
Specification tests panhausman(), pandispersiontest(), jointtest(), lineartest()

Numerical accuracy is documented in the validation article.

Example

Exacerbation counts of 60 COPD patients over five visits, with a random-effects Poisson model, cluster-robust standard errors, a Hausman test against fixed effects and average partial effects:

library(panglm)
data(copd)

re <- panglm(exacerbations ~ crp + treatment + age, data = copd,
             index = c("id", "visit"), model = "random",
             family = "poisson", vcov = "cluster")
summary(re)
#> 
#> Call:
#> panglm(formula = exacerbations ~ crp + treatment + age, data = copd, 
#>     index = c("id", "visit"), model = "random", family = "poisson", 
#>     vcov = "cluster")
#> 
#> Family: poisson  Link: log  Model: random  Effect: individual 
#> N = 300  groups = 60  vcov: cluster 
#> 
#> Coefficients:
#>              Estimate Std. Error z value Pr(>|z|)    
#> (Intercept) -1.840104   0.525745  -3.500 0.000465 ***
#> crp          0.040731   0.020385   1.998 0.045711 *  
#> treatment   -0.309009   0.168576  -1.833 0.066795 .  
#> age          0.037769   0.007959   4.745 2.08e-06 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Log-likelihood: -517.8 
#> Dispersion parameter: 4.215 
#> Residual df: 295  Iterations: 4

fe <- panglm(exacerbations ~ crp, data = copd,
             index = c("id", "visit"), model = "within", family = "poisson")
panhausman(fe, re)
#> 
#>  Hausman specification test (fixed vs. random effects)
#> 
#> chisq = 3.211 , df = 1 , p-value = 0.07312 
#> alternative hypothesis: one model is inconsistent

partialeffects(re)
#> 
#> Average partial effects
#> Delta-method standard errors, vcov: cluster 
#> 
#>       term contrast estimate std.error statistic   p.value  conf.low conf.high
#>        crp    dY/dX  0.08660   0.04280     2.023 0.0430500  0.002708   0.17050
#>  treatment    1 - 0 -0.63650   0.34350    -1.853 0.0638500 -1.310000   0.03667
#>        age    dY/dX  0.08031   0.01837     4.372 0.0000123  0.044310   0.11630

Learn more

panglm is the software of a forthcoming book on panel data methods for health econometrics, whose examples it runs throughout.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.