Learn R Programming

clusterSEs (version 1.0)

cluster.im: Cluster-Adjusted Standard Errors and p-Values for GLM

Description

Computes p-values and standard errors for GLM models based on cluster-specific model estimation (Ibragimov and Muller 2010). A separate model is estimated in each cluster, and then p-values are computed based on a t/normal distribution of the cluster-specific estimates.

Usage

cluster.im(mod, dat, cluster, report = TRUE, se = FALSE, drop = FALSE)

Arguments

mod
A model estimated using glm.
dat
The data set used to estimate mod.
cluster
A formula of the clustering variable.
report
Should a table of results be printed to the console?
se
Should standard errors be returned?
drop
Should clusters within which a model cannot be estimated be dropped?

Value

  • A list with the elements
  • p.valuesA matrix of the estimated p-values.
  • seThe estimated standard errors (if requested).

References

Ibragimov, Rustam, and Ulrich K. Muller. 2010. "t-Statistic Based Correlation and Heterogeneity Robust Inference." Journal of Business & Economic Statistics 28(4): 453-468.

Examples

Run this code
# predict whether respondent has a university degree
require(effects)
data(WVS)
logit.model <- glm(degree ~ religion + gender + age, data=WVS, family=binomial(link="logit"))
summary(logit.model)

# compute cluster-adjusted p-values
clust.p <- cluster.im(logit.model, WVS, ~ country, report = T, se = TRUE, drop = FALSE)

# compute 95% confidence intervals
ci.lo <- coefficients(logit.model) - qt(0.975, df=3)*clust.p$se
ci.hi <- coefficients(logit.model) + qt(0.975, df=3)*clust.p$se
ci <- cbind(ci.lo, ci.hi)
colnames(ci) <- c("95% lower bound", "95% upper bound")
ci

Run the code above in your browser using DataLab