Currently I am using numerical optimization in
R via the
optim() function to estimate some parameters in a complicated likelihood function. I know that
optim can return the "Hessian" matrix which can be used to calculate model-based standard errors for my estimated parameters, however, I am wondering if it is possible to calculate robust-sandwich standard errors instead for my estimated parameters by purely using numerical optimization?
I am interested in using numerical optimization for estimation and inference. While an analytic solution to the robust sandwich error estimator may be available, it may not be possible to derive in all cases where I am using
optim() for estimation. Is there some general way I can get robust standard errors in R by numerical optimization of a likelihood function? Or perhaps this is not possible and hence why
optim only returns the Hessian.