Skip to contents

Plots residual leverage, partial leverage and the leave-one-cluster-out regression coefficients

Usage

# S3 method for summclust
plot(x, ...)

Arguments

x

An object of type summclust

...

other optional function arguments

Value

A list containing

residual_leverage

A ggplot of the residual leverages

coef_leverage

A ggplot of the coefficient leverages

coef_beta

A ggplot of the leave-one-out cluster jackknife regression coefficients

Details

Note that the function requires ggplot2 to be installed.

References

MacKinnon, James G., Morten Ørregaard Nielsen, and Matthew D. Webb. "Leverage, influence, and the jackknife in clustered regression models: Reliable inference using summclust." arXiv preprint arXiv:2205.03288 (2022).

Examples


# \donttest{
if(requireNamespace("summclust") && requireNamespace("haven")){

library(summclust)
library(haven)

nlswork <- read_dta("http://www.stata-press.com/data/r9/nlswork.dta")
# drop NAs at the moment
nlswork <- nlswork[, c("ln_wage", "grade", "age", "birth_yr", "union", "race", "msp", "ind_code")]
nlswork <- na.omit(nlswork)

lm_fit <- lm(
  ln_wage ~ union +  race + msp + as.factor(birth_yr) + as.factor(age) + as.factor(grade),
  data = nlswork)

res <- summclust(
   obj = lm_fit,
   params = c("msp", "union"),
   cluster = ~ind_code,
 )

 plot(res)
}
#> Loading required namespace: haven
#> Error in eval(mf, parent.frame()): object 'nlswork' not found
# }