Ravi Varadhan skreiv:
I am not aware of any. May I ask what your purpose is? You don't really need this if you are going to use it in optimization, since most optimizers use a simple finite-difference approximation if you don't provide the gradient. Using the numerical approximation from "numDeriv" will be quite time-consuming in an optimization routine, since numDeriv uses a high-order Richardosn extrapolation to compute an accurate approximation of the gradient.
No, I don’t use it in an optimisation. The expression is part of a more complicated formula used for calculating some estimates in a special nonparametric model.
I won’t use the numerical approximation; the alternative would be to calculate the analytical expressions myself. It’s not too difficult, but tedious, and the expressions I end up with may not be the fastest or most numerically accurate, so if there was a package implementing them in a good way, it would be nice. :)
Regardless of your purpose, there is a small bug in your function. You should change `dmvnorm(cbind(x,y),mu,sig)' to `dmvnorm(cbind(xx,yy),mu,sig)'.
Yes, of course. I originally used x and y when creating the example, but then discovered that the jacobian() function already used x as an argument for something else, so I renamed them to xx and yy (though obviously not everywhere!). I really should have tested it in a completely clean environment before posting.
-- Karl Ove Hufthammer ______________________________________________ R-help@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.