Skip to contents

Implement the generics::tidy() and generics::glance() generics for the fits of twopart(), pangmm(), paniv(), panqr(), panselect(), panfmm(), attgt(), etwfe() and eventstudy(), the hurdle model, and for the test objects of the Hausman, joint Wald and dispersion tests, so that they work with broom and modelsummary.

Usage

# S3 method for class 'panglm_hurdle'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'panglm_hurdle'
glance(x, ...)

# S3 method for class 'twopart'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'twopart'
glance(x, ...)

# S3 method for class 'pangmm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'pangmm'
glance(x, ...)

# S3 method for class 'paniv'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'paniv'
glance(x, ...)

# S3 method for class 'panqr'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'panqr'
glance(x, ...)

# S3 method for class 'panselect'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'panselect'
glance(x, ...)

# S3 method for class 'panfmm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'panfmm'
glance(x, ...)

# S3 method for class 'panglm_attgt'
tidy(
  x,
  conf.int = FALSE,
  conf.level = 0.95,
  type = c("attgt", "simple", "dynamic", "group", "calendar"),
  ...
)

# S3 method for class 'panglm_attgt'
glance(x, ...)

# S3 method for class 'panglm_etwfe'
tidy(
  x,
  conf.int = FALSE,
  conf.level = 0.95,
  type = c("simple", "group", "calendar", "event", "coefficients"),
  ...
)

# S3 method for class 'panglm_etwfe'
glance(x, ...)

# S3 method for class 'panglm_eventstudy'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

# S3 method for class 'panglm_eventstudy'
glance(x, ...)

# S3 method for class 'panglm_hausman'
tidy(x, ...)

# S3 method for class 'panglm_hausman'
glance(x, ...)

# S3 method for class 'panglm_jointtest'
tidy(x, ...)

# S3 method for class 'panglm_jointtest'
glance(x, ...)

# S3 method for class 'panglm_dispersiontest'
tidy(x, ...)

# S3 method for class 'panglm_dispersiontest'
glance(x, ...)

Arguments

x

a fitted model or test object

conf.int

if TRUE, add conf.low/conf.high columns

conf.level

confidence level for the interval

...

further arguments passed to the summary() aggregation (attgt, etwfe), otherwise unused

type

for attgt() and etwfe() fits, which effects to tidy (see Details)

Value

a data.frame: one row per coefficient (or effect) for tidy() of a fit, one row for glance() and for the test objects (see Details).

Details

tidy() returns one row per coefficient with columns term, estimate, std.error, statistic (the Wald z), p.value and, with conf.int = TRUE, the Wald interval conf.low, conf.high. The estimates and standard errors are those of coef() and vcov(), so the interval equals confint(). Extra columns identify the rows where a fit has several blocks of coefficients: component (twopart: "binary" or "positive"; panfmm: "class" or "prior"), class (panfmm), tau (panqr: one row per term and quantile), group, time, event (attgt, etwfe, eventstudy).

For attgt(), type = "attgt" (the default) gives one row per group-time effect ATT(g, t), named as in coef(); the other types are the aggregations of summary.panglm_attgt(). For etwfe(), type = "simple" (the default) gives the overall ATT, "group", "calendar" and "event" the aggregations of summary.panglm_etwfe(), and "coefficients" the coefficients of the underlying regression. For eventstudy() the reference period is a row with estimate and standard error zero and a missing statistic. A statistic is missing whenever its standard error is zero or missing.

For the test objects, tidy() and glance() both return a one-row data frame in the style of broom's htest methods: statistic, p.value, parameter (the degrees of freedom; for an F test also den.df), distribution and method.

glance() returns one row with the estimator, the variance type, the numbers of observations and individuals, the log-likelihood, AIC and BIC where the model is fitted by maximum likelihood (twopart, panfmm), and the specification tests reported by summary() (for example the Sargan, Hansen and Arellano-Bond tests of pangmm(), the pre-trend test of attgt() and eventstudy()).

Validation

Numerical accuracy is checked in the package tests and in the validation suite; see the validation article on the package website.

See also

Examples

data(copd)
if (requireNamespace("generics", quietly = TRUE)) {
  set.seed(1)
  d <- data.frame(id = rep(1:100, each = 5), t = rep(1:5, 100), x = rnorm(500))
  d$y <- d$x + rep(rnorm(100), each = 5) + rnorm(500)
  fit <- panqr(y ~ x, data = d, index = c("id", "t"), tau = c(0.25, 0.75))
  generics::tidy(fit, conf.int = TRUE)
  generics::glance(fit)
}
#>   model vcov.type n.tau nobs n.groups
#> 1 canay bootstrap     2  500      100