Hi, I found this <https://thetarzan.wordpress.com/2011/06/11/clustered-standard-errors-in-r/> post from 2011 for doing clustered standard errors in R. Is there any update to the lm package that allows to do this without having to write your own function? In STATA is as simple as adding cluster to the reg command. Thanks a lot for the help! Ignacio [[alternative HTML version deleted]]
Updates to lm() would be documented in the manual page for the function. Reading the link it appears that you do not have to write your own function, Mahmood Ara in Stockholm University has already done it for you. You just have to learn how to copy a function from a web site and paste it into an R script file. Given the cost of a single business license for STATA in the US for moderate-sized datasets of $1,195 (perpetual) versus the cost of R, $0 (perpetual), it would seem to be worth the bother. ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ignacio Martinez Sent: Monday, November 16, 2015 9:28 AM To: r-help Subject: [R] Clustered Standard Errors? Hi, I found this <https://thetarzan.wordpress.com/2011/06/11/clustered-standard-errors-in-r/> post from 2011 for doing clustered standard errors in R. Is there any update to the lm package that allows to do this without having to write your own function? In STATA is as simple as adding cluster to the reg command. Thanks a lot for the help! Ignacio [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On Mon, 16 Nov 2015, Ignacio Martinez wrote:> Hi, > > I found this > <https://thetarzan.wordpress.com/2011/06/11/clustered-standard-errors-in-r/> > post > from 2011 for doing clustered standard errors in R. > > Is there any update to the lm package that allows to do this without > having to write your own function? In STATA is as simple as adding > cluster to the reg command.For "lm" objects, the easiest solution is to use the "multiwayvcov" package on CRAN. Additionally, the "plm" package on CRAN offers further options beyond the simple clustered standard errors.> Thanks a lot for the help! > > Ignacio > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Hi Ignacio, following this link: http://www.ne.su.se/polopoly_fs/1.216115.1426234213!/menu/standard/file/clustering1.pdf you can download a documentation for Arai's cl-function that is mentioned in the link in your email. I used it several times and it works quite well. Just copy the function into your script and call it after you calculated your regression using the following command: cl(data, regression-model, cluster-variable) Best Jen -----Urspr?ngliche Nachricht----- Von: R-help [mailto:r-help-bounces at r-project.org] Im Auftrag von Achim Zeileis Gesendet: Montag, 16. November 2015 18:48 An: Ignacio Martinez <ignacio82 at gmail.com> Cc: r-help <r-help at r-project.org> Betreff: Re: [R] Clustered Standard Errors? On Mon, 16 Nov 2015, Ignacio Martinez wrote:> Hi, > > I found this > <https://thetarzan.wordpress.com/2011/06/11/clustered-standard-errors- > in-r/> > post > from 2011 for doing clustered standard errors in R. > > Is there any update to the lm package that allows to do this without > having to write your own function? In STATA is as simple as adding > cluster to the reg command.For "lm" objects, the easiest solution is to use the "multiwayvcov" package on CRAN. Additionally, the "plm" package on CRAN offers further options beyond the simple clustered standard errors.> Thanks a lot for the help! > > Ignacio > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.