coeftest.cluster: R function for computing two-way cluster-robust standard...

Description Usage

View source: R/cluster2.R

Description

R function for computing two-way cluster-robust standard errors. The code below was adapted by Ian Gow on 2011-05-16 using code supplied via Mitchell Petersen's website by Mahmood Arai, 2008-01-21. Modified on 2014-04-18 to return White (1980) standard errors if no cluster variable is provided and to add links to test code. source: http://iangow.me/~igow/code/cluster2.R Apart from a little cleanup of the code, the main difference between this and the earlier code is in the handling of missing values. Look at the file cluster.test.R to see example usage. Note that care should be taken to do subsetting outside of the call to lm or glm, as it is difficult to recon- struct subsetting of this kind from the fitted model. However, the code does handle transformations of variables in the model (e.g., logs). Please report any bugs, suggestions, or errors to iandgow(at)gmail.com. The output has been tested fairly extensively against output of Mitchell Petersen'scluster2.ado commmand (hence implicitly against the Matlab and SAS code posted elsewhere here), but I have not tested the code against code for non-linear models, such as logit2.ado. For testing code, see here: http://www.iangow.me/~igow/code/cluster_test.Rnw For output, see here:http://www.iangow.me/~igow/code/cluster_test.pdf See: Thompson (2006), Cameron, Gelbach and Miller (2006) and Petersen (2010). and Gow, Ormazabal, and Taylor (2010) for more discussion of this code and two-way cluster-robust standard errors. The arguments of the function are data, fitted model, cluster1 and cluster2 You need to install packages ‘sandwich’ by Thomas Lumley and Achim Zeileis and ‘lmtest’ by Torsten Hothorn, Achim Zeileis, Giovanni Millo and David Mitchell. (For example, type install.packages('sandwich') on the R console.)

Usage

1
2
3
## S3 method for class 'cluster'
coeftest(data, fm, cluster1 = NULL, cluster2 = NULL,
  ret = "test")

pwkraft/pmisc documentation built on May 26, 2019, 11:34 a.m.