[ADMB Users] MVN Example? | Chris Gast | 3/14/12 2:50 PM | Hello, Does anyone have some code to compute the log-likelihood for a multivariate normal model that they're willing to share? I'm having trouble getting matrix determinants and inverses to work.
I found a link to a previous discussion, indicating such an example would be available in Roa's article "A Likelihood-Based Model of Fish Growth With Multiple Length Frequency Data" in JABES, but I'm having trouble accessing the supplementary material.
If I can get this working (a weighted LMM with autocorrelated residuals and spatially-correlated random effects), I'd be happy to add it to the examples list, since I can't seem to find a MVN likelihood example there either.
Thanks, Chris |

Re: [ADMB Users] MVN Example? | Mollie Brooks | 3/14/12 4:39 PM | Hi Chris, I'm doing an MVN model. My procedure section looks like this PROCEDURE_SECTION for(int i=1; i<=ncoeffs; i++) { coeffs(i)=ucoeffs(i)*scale(i); } nLL=0; for(int p=1; p<=nponds; p++) { calc_predictions(p); calc_varcov(p); dvar_vector diff=predictions(p)-obs(p); dvar_matrix tmp_varcov=varcov(p); nLL+=.5*(nobs(p)*log(2*M_PI)+ln_det(tmp_varcov)+ diff*solve2(tmp_varcov,diff)); } The first for loop scales all my coefficients to make it conditioned better. Then I have observations of a bunch of ponds and each pond is assumed to be independent of the others. I defined functions calc_predictions() and calc_varcov() to fill in those objects; the code in these is pretty specific to my problem. The important thing fir efficiency is that my covariates are in a design matrix created using model.matrix() in R. Try using solve() where I have solve2(). If you have a problem with solve, I'll explain the complications of why I used this version. I hope this helps. cheers, Mollie
Mollie Brooks
Ph.D. Candidate NSF IGERT Fellow Biology Department University of Florida mbr...@ufl.edu http://people.biology.ufl.edu/mbrooks _______________________________________________ |

Re: [ADMB Users] MVN Example? | Chris Gast | 3/14/12 4:52 PM | Thanks, Mollie. For some reason, ADMB can't seem to find the ln_det() function. test_mat.obj:test_mat.cpp:(.text+0x13af): undefined reference to `ln_det(df1b2matrix&)'
I'll keep playing with it and see if I can figure it out. Chris |

Re: [ADMB Users] MVN Example? | Chris Gast | 3/14/12 5:55 PM | After changing line 1978 in df1b2fun.h to match the correct function header on line 220 of df1b2ludcmp.cpp, I got your syntax working successfully. I'm not sure who specifically to address regarding making this correction, but hopefully they're reading this thread already....?
Mollie: I'm interested in what complications you experienced with solve(). Is this related to some speed issues which I found noted on previous admb-users posts? Thanks Mollie (and Jim Ianelli for an off-list reply). Chris |

Re: [ADMB Users] MVN Example? | Rubén Roa | 3/15/12 3:30 AM | Rubén H. Roa-Ureta, Ph. D. |