IDEAS home Printed from https://ideas.repec.org/p/inn/wpaper/2017-12.html
   My bibliography  Save this paper

Various Versatile Variances: An Object-Oriented Implementation of Clustered Covariances in R

Author

Listed:
  • Susanne Berger
  • Nathaniel Graham
  • Achim Zeileis

Abstract

Clustered covariances or clustered standard errors are very widely used to account for correlated or clustered data, especially in economics, political sciences, or other social sciences. They are employed to adjust the inference following estimation of a standard least-squares regression or generalized linear model estimated by maximum likelihood. Although many publications just refer to "the" clustered standard errors, there is a surprisingly wide variety of clustered covariances particularly due to different flavors of bias corrections. Furthermore, while the linear regression model is certainly the most important application case, the same strategies can be employed in more general models (e.g. for zero-inflated, censored, or limited responses). In R, functions for covariances in clustered or panel models have been somewhat scattered or available only for certain modeling functions, notably the (generalized) linear regression model. In contrast, an object-oriented approach to "robust" covariance matrix estimation - applicable beyond lm() and glm() - is available in the sandwich package but has been limited to the case of cross-section or time series data. Now, this shortcoming has been corrected in sandwich (starting from version 2.4.0): Based on methods for two generic functions (estfun() and bread()), clustered and panel covariances are now provided in vcovCL(), vcovPL(), and vcovPC(). These are directly applicable to models from many packages, e.g., including MASS, pscl, countreg, betareg, among others. Some empirical illustrations are provided as well as an assessment of the methods' performance in a simulation study.

Suggested Citation

  • Susanne Berger & Nathaniel Graham & Achim Zeileis, 2017. "Various Versatile Variances: An Object-Oriented Implementation of Clustered Covariances in R," Working Papers 2017-12, Faculty of Economics and Statistics, Universität Innsbruck.
  • Handle: RePEc:inn:wpaper:2017-12
    as

    Download full text from publisher

    File URL: https://www2.uibk.ac.at/downloads/c4041030/wpaper/2017-12.pdf
    Download Restriction: no
    ---><---

    References listed on IDEAS

    as
    1. Thompson, Samuel B., 2011. "Simple formulas for standard errors that cluster by both firm and time," Journal of Financial Economics, Elsevier, vol. 99(1), pages 1-10, January.
    2. White,Halbert, 1996. "Estimation, Inference and Specification Analysis," Cambridge Books, Cambridge University Press, number 9780521574464, January.
    3. Zeileis, Achim & Kleiber, Christian & Jackman, Simon, 2008. "Regression Models for Count Data in R," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 27(i08).
    4. Beck, Nathaniel & Katz, Jonathan N., 1995. "What To Do (and Not to Do) with Time-Series Cross-Section Data," American Political Science Review, Cambridge University Press, vol. 89(3), pages 634-647, September.
    5. John C. Driscoll & Aart C. Kraay, 1998. "Consistent Covariance Matrix Estimation With Spatially Dependent Panel Data," The Review of Economics and Statistics, MIT Press, vol. 80(4), pages 549-560, November.
    6. Green, Donald P. & Vavreck, Lynn, 2008. "Analysis of Cluster-Randomized Experiments: A Comparison of Alternative Estimation Approaches," Political Analysis, Cambridge University Press, vol. 16(2), pages 138-152, April.
    7. Cameron, A. Colin & Gelbach, Jonah B. & Miller, Douglas L., 2011. "Robust Inference With Multiway Clustering," Journal of Business & Economic Statistics, American Statistical Association, vol. 29(2), pages 238-249.
    8. A. Colin Cameron & Douglas L. Miller, 2015. "A Practitioner’s Guide to Cluster-Robust Inference," Journal of Human Resources, University of Wisconsin Press, vol. 50(2), pages 317-372.
    9. Daniel Hoechle, 2007. "Robust standard errors for panel regressions with cross-sectional dependence," Stata Journal, StataCorp LP, vol. 7(3), pages 281-312, September.
    10. Whitney K. Newey & Kenneth D. West, 1994. "Automatic Lag Selection in Covariance Matrix Estimation," The Review of Economic Studies, Review of Economic Studies Ltd, vol. 61(4), pages 631-653.
    11. White, Halbert, 1980. "A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity," Econometrica, Econometric Society, vol. 48(4), pages 817-838, May.
    12. ., 2013. "Defending the history of economic thought," Chapters, in: Defending the History of Economic Thought, chapter 5, pages 105-132, Edward Elgar Publishing.
    13. Susanne Berger & Herbert Stocker & Achim Zeileis, 2017. "Innovation and institutional ownership revisited: an empirical investigation with count data models," Empirical Economics, Springer, vol. 52(4), pages 1675-1688, June.
    14. Croissant, Yves & Millo, Giovanni, 2008. "Panel Data Econometrics in R: The plm Package," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 27(i02).
    15. Bates, Douglas & Mächler, Martin & Bolker, Ben & Walker, Steve, 2015. "Fitting Linear Mixed-Effects Models Using lme4," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 67(i01).
    16. Croissant, Yves & Millo, Giovanni, 2008. "Panel Data Econometrics in R: The plm Package," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 27(i02).
    17. Mitchell A. Petersen, 2009. "Estimating Standard Errors in Finance Panel Data Sets: Comparing Approaches," Review of Financial Studies, Society for Financial Studies, vol. 22(1), pages 435-480, January.
    18. Moulton, Brent R., 1986. "Random group effects and the precision of regression estimates," Journal of Econometrics, Elsevier, vol. 32(3), pages 385-397, August.
    19. Arceneaux, Kevin & Nickerson, David W., 2009. "Modeling Certainty with Clustered Data: A Comparison of Methods," Political Analysis, Cambridge University Press, vol. 17(2), pages 177-190, April.
    20. Millo, Giovanni, 2014. "Robust standard error estimators for panel models: a unifying approach," MPRA Paper 54954, University Library of Munich, Germany.
    21. Bailey, Delia & Katz, Jonathan N., 2011. "Implementing Panel-Corrected Standard Errors in R: The pcse Package," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 42(c01).
    22. Moulton, Brent R, 1990. "An Illustration of a Pitfall in Estimating the Effects of Aggregate Variables on Micro Unit," The Review of Economics and Statistics, MIT Press, vol. 72(2), pages 334-338, May.
    Full references (including those not matched with items on IDEAS)

    Citations

    Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.
    as


    Cited by:

    1. Aihounton, Ghislain & Henningsen, Arne & Trifkovic, Neda, 2021. "Pesticide Handling and Human Health: Conventional and Organic Cotton Farming in Benin," 2021 Conference, August 17-31, 2021, Virtual 315407, International Association of Agricultural Economists.
    2. Henningsen, Geraldine & Wiese, Catharina, 2019. "Do Household Characteristics Really Matter? A Meta-Analysis on the Determinants of Households’ Energy-Efficiency Investments," MPRA Paper 101701, University Library of Munich, Germany.
    3. Aihounton, Ghislain & Henningsen, Arne, 2021. "Organic Farming and Food and Nutrition Security," 2021 Conference, August 17-31, 2021, Virtual 315413, International Association of Agricultural Economists.

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. Millo, Giovanni, 2014. "Robust standard error estimators for panel models: a unifying approach," MPRA Paper 54954, University Library of Munich, Germany.
    2. A. Colin Cameron & Douglas L. Miller, 2010. "Robust Inference with Clustered Data," Working Papers 318, University of California, Davis, Department of Economics.
    3. James G. MacKinnon & Matthew D. Webb, 2020. "When and How to Deal with Clustered Errors in Regression Models," Working Paper 1421, Economics Department, Queen's University.
    4. A. Colin Cameron & Douglas L. Miller, 2010. "Robust Inference with Clustered Data," Working Papers 106, University of California, Davis, Department of Economics.
    5. Hansen, Bruce E. & Lee, Seojeong, 2019. "Asymptotic theory for clustered samples," Journal of Econometrics, Elsevier, vol. 210(2), pages 268-290.
    6. Jushan Bai & Sung Hoon Choi & Yuan Liao, 2021. "Feasible generalized least squares for panel data with cross-sectional and serial correlations," Empirical Economics, Springer, vol. 60(1), pages 309-326, January.
    7. Kim, Min Seong & Sun, Yixiao, 2013. "Heteroskedasticity and spatiotemporal dependence robust inference for linear panel models with fixed effects," Journal of Econometrics, Elsevier, vol. 177(1), pages 85-108.
    8. Phetkeo Poumanyvong & Shinji Kaneko & Shobhakar Dhakal, 2012. "Impacts of urbanization on national residential energy use and CO2 emissions: Evidence from low-, middle- and high-income countries," IDEC DP2 Series 2-5, Hiroshima University, Graduate School for International Development and Cooperation (IDEC).
    9. MacKinnon, James G. & Nielsen, Morten Ørregaard & Webb, Matthew D., 2023. "Cluster-robust inference: A guide to empirical practice," Journal of Econometrics, Elsevier, vol. 232(2), pages 272-299.
    10. Fratianni, Michele & Marchionne, Francesco, 2013. "The fading stock market response to announcements of bank bailouts," Journal of Financial Stability, Elsevier, vol. 9(1), pages 69-89.
    11. Elif Guneren Genc & Ozlem Deniz Basar, 2017. "The Impact of OECD Countries¡¯ Macroeconomic Factors on Turkey¡¯s Foreign Trade," Research in World Economy, Research in World Economy, Sciedu Press, vol. 8(1), pages 24-36, June.
    12. Sarmiento-Sabogal, Julio & Sadeghi, Mehdi, 2014. "Unlevered betas and the cost of equity capital: An empirical approach," The North American Journal of Economics and Finance, Elsevier, vol. 30(C), pages 90-105.
    13. Faruk Balli & Syed Basher & Rosmy Jean Louis, 2012. "Channels of risk-sharing among Canadian provinces: 1961–2006," Empirical Economics, Springer, vol. 43(2), pages 763-787, October.
    14. A. Colin Cameron & Douglas L. Miller, 2015. "A Practitioner’s Guide to Cluster-Robust Inference," Journal of Human Resources, University of Wisconsin Press, vol. 50(2), pages 317-372.
    15. Timothy Conley & Silvia Gonçalves & Christian Hansen, 2018. "Inference with Dependent Data in Accounting and Finance Applications," Journal of Accounting Research, Wiley Blackwell, vol. 56(4), pages 1139-1203, September.
    16. Ricardo Duque Gabriel, 2020. "Who should you vote for? Empirical evidence from Portuguese local governments," Portuguese Economic Journal, Springer;Instituto Superior de Economia e Gestao, vol. 19(1), pages 5-31, January.
    17. Andrea Orame, 2020. "The role of bank supply in the Italian credit market: evidence from a new regional survey," Temi di discussione (Economic working papers) 1279, Bank of Italy, Economic Research and International Relations Area.
    18. Rok Spruk & Mitja Kovac, 2018. "Inefficient Growth," Review of Economics and Institutions, Università di Perugia, vol. 9(2).
    19. Klishchuk Bogdan & Zelenyuk Valentin, 2012. "Impact of Services LIberalization on Firm Level Productivity in Eastern Europe and Central Asia," EERC Working Paper Series 12/03e, EERC Research Network, Russia and CIS.
    20. Jank, Stephan & Roling, Christoph & Smajlbegovic, Esad, 2021. "Flying under the radar: The effects of short-sale disclosure rules on investor behavior and stock prices," Journal of Financial Economics, Elsevier, vol. 139(1), pages 209-233.

    More about this item

    Keywords

    clustered data; clustered covariance matrix estimators; object orientation; simulation; R;
    All these keywords.

    JEL classification:

    • C12 - Mathematical and Quantitative Methods - - Econometric and Statistical Methods and Methodology: General - - - Hypothesis Testing: General
    • C52 - Mathematical and Quantitative Methods - - Econometric Modeling - - - Model Evaluation, Validation, and Selection
    • C87 - Mathematical and Quantitative Methods - - Data Collection and Data Estimation Methodology; Computer Programs - - - Econometric Software

    NEP fields

    This paper has been announced in the following NEP Reports:

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:inn:wpaper:2017-12. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Janette Walde (email available below). General contact details of provider: https://edirc.repec.org/data/fuibkat.html .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.