[ADMB Users] matrix not positive definite

dave fournier davef at otter-rsch.com
Sun Feb 10 14:09:11 PST 2013


On 13-02-10 01:54 PM, Mollie Brooks wrote:


Safe mode may initialize variables so that if you are using unitialized 
variables
you could get different results between the two. In fact it is a good 
test for that.
It appears that in your case temp_varcov is not initialized.

    //CALCULATE VARCOV
         dvar_matrix temp_varcov(2,nobs(p),2,nobs(p));

//  !!!!    right here


         for(int k=2; k<=2; k++)
         {
                 for(int l=k; l<=nobs(p); l++)//l>=k
                 {
                         for(int b= obsdates(1,p)+1; b<= obsdates(k,p); b++)
                         {
temp_varcov(k,l)+=sigmaSq*(pow(rho,
tk_minus_b(p,b,k)+
tk_minus_b(p,b,l)));
                         }
                         temp_varcov(l,k)=temp_varcov(k,l);
                 }
         }




> A collaborator proved that the measurement error only 
> variance-covariance matrix was positive definite, but didn't get 
> around to the process error version. I was hoping they were similar 
> enough.
>
> I don't have a great understanding of what it takes for a matrix to be 
> positive definite. I at least can say that as long as rho and sigmaSq 
> are positive, then all of the matrix elements should be positive. So 
> it's strange that they would ever go negative.
>
> I thought that maybe I had gotten the indices wrong, so I tried 
> compiling in safe mode. In safe mode, none of the elements go negative 
> and it seems to be positive-definite. I didn't think safe-mode to 
> change the behaviour like this. I thought it would just give errors.
>
> thanks,
> Mollie
>
>
> On 10 Feb 2013, at 2:00 PM, dave fournier wrote:
>
>> On 13-02-10 10:39 AM, Mollie Brooks wrote:
>>
>> Its pretty complicated, but the first question would be why should it 
>> be positive definite.
>> Without understanding the special structure all I see is a way of 
>> parameterizing a
>> symmetric matrix via a bunch of parameters.  since S_ij = S_ji  by
>> construction it is symmetric, but why positive definite.
>>
>>
>>
>>> Thanks for the response.
>>>
>>> I'm attaching the code and a tiny simulated data set. I can send a larger simulated dataset if it helps. I also attached the R code I used to simulate the data.
>>>
>>> The attached pdf contains the formula for the variance covariance matrix as "Process Error". The "Predictions" are temporally autocorrelated latent variables that determine the Bernoulli process of whether or not there is water in the pond.
>>> thanks,
>>> Mollie
>>>
>>>
>>>
>>>
>>>   
>>>
>>> Mollie Brooks
>>> Postdoctoral Researcher, Ponciano Lab
>>> Biology Department, University of Florida
>>> http://people.biology.ufl.edu/mbrooks
>>>
>>>
>>> On 10 Feb 2013, at 11:54 AM, dave fournier wrote:
>>>
>>>> Hard to say much that isn't probably wrong without seeing your code etc.
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at admb-project.org
>>>> http://lists.admb-project.org/mailman/listinfo/users
>>>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20130210/f6454864/attachment.html>


More information about the Users mailing list