Karl, You may want to look at the paper by Dwyer on "Some applications of matrix derivatives in multivariate analysis" (JASA 1967), especially the Table 2 on p. 617.
Ravi. ---------------------------------------------------------------------------- ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml ---------------------------------------------------------------------------- -------- -----Original Message----- From: Karl Ove Hufthammer [mailto:karl.huftham...@math.uib.no] Sent: Monday, June 22, 2009 12:12 PM To: r-h...@stat.math.ethz.ch Cc: Ravi Varadhan Subject: Re: [R] The gradient of a multivariate normal density with respect toits parameters 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.