clusterInf: Post-inference for clustered data

Description Usage Arguments Value References See Also Examples

View source: R/clusterInf.R

Description

Correct standard-errors to account for clustered data, doing either a degrees of freedom correction or using a heteroskedasticidty-cluster robust covariance matrix possibly on the range specified by bandwidth

Usage

1
clusterInf(object, clusterVar, vcov. = NULL, type = c("df-adj", "HC"), ...)

Arguments

object

Object of class lm, from which rdd_reg also inherits.

clusterVar

The variable containing the cluster attributions.

vcov.

Specific covariance function to pass to coeftest. See help of sandwich

type

The type of cluster correction to use: either the degrees of freedom, or a HC matrix.

...

Further arguments passed to coeftest

Value

The output of the coeftest function, which is itself of class coeftest

References

Wooldridge (2003) Cluster-sample methods in applied econometrics. AmericanEconomic Review, 93, p. 133-138

See Also

vcovCluster, which implements the cluster-robust covariance matrix estimator used by cluserInf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(house)
house_rdd <- rdd_data(y=house$y, x=house$x, cutpoint=0)
reg_para <- rdd_reg_lm(rdd_object=house_rdd)

# here we just generate randomly a cluster variable:
nlet <- sort(c(outer(letters, letters, paste, sep='')))
clusRandom <- sample(nlet[1:60], size=nrow(house_rdd), replace=TRUE)

# now do post-inference:
clusterInf(reg_para, clusterVar=clusRandom)
clusterInf(reg_para, clusterVar=clusRandom, type='HC')

Example output

Loading required package: AER
Loading required package: car
Loading required package: carData
Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich
Loading required package: survival
Loading required package: np
Nonparametric Kernel Methods for Mixed Datatypes (version 0.60-9)
[vignette("np_faq",package="np") provides answers to frequently asked questions]
[vignette("np",package="np") an overview]
[vignette("entropy_np",package="np") an overview of entropy-based methods]

t test of coefficients:

             Estimate Std. Error  t value  Pr(>|t|)    
(Intercept) 0.4329479  0.0042758 101.2544 < 2.2e-16 ***
D           0.1182314  0.0056799  20.8159 < 2.2e-16 ***
x           0.2969065  0.0115464  25.7142 < 2.2e-16 ***
x_right     0.0459776  0.0135015   3.4054  0.001184 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


t test of coefficients:

             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 0.4329479  0.0048119 89.9750  < 2e-16 ***
D           0.1182314  0.0057901 20.4196  < 2e-16 ***
x           0.2969065  0.0186630 15.9089  < 2e-16 ***
x_right     0.0459776  0.0210773  2.1814  0.02919 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

rddtools documentation built on Jan. 10, 2022, 5:07 p.m.