Re: [R] Huber-white cluster s.e. after optim?

From: <Bill.Venables_at_csiro.au>
Date: Thu, 10 Apr 2008 12:02:06 +1000


optim is a general purpose optimiser. You don't reallly use it to 'analyze' data and you cannot get a variance matrix directly from the result, even using vcov. If you ask, it will give you the hessian matrix of the objective function at the optimum value, from which you can get a variance matrix if you wish, provided the objective function that you optimised was the negative of a log-likelihood function.

So the recommended way of going about things in your case is probably a) calculate the negative log-likelihood from the non-independence model that accommodates the kind of clustering you suspect may be happening, b) use optim to optimise it, requesting the hessian and c) invert the hessian to get the variance matrix.

In many cases a) often looks difficult, but on closer inspection turns out to be impossible, (typicall because it involves too much numerical integration). In this case you need to use an alternative approach which probably will not involve using optim at all.

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Peter Muhlberger
Sent: Thursday, 10 April 2008 10:16 AM
To: r-help_at_stat.math.ethz.ch
Subject: [R] Huber-white cluster s.e. after optim?

I've used optim to analyze some data I have with good results, but need to correct the var-cov matrix for possible effects of clustering of observations (respondents) in small groups (non-independence). Is there any function to adjust the matrix? I heard some time ago that the vcovHC function would have a cluster capability added to it, but I don't see that in my fairly recent version.

Cheers, Peter



R-help_at_r-project.org mailing list
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
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. Received on Thu 10 Apr 2008 - 02:28:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Apr 2008 - 03:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive