[R] Fwd: Using odesolve to produce non-negative solutions

Spencer Graves spencer.graves at pdf.com
Mon Jun 11 18:52:57 CEST 2007


<in line>

Martin Henry H. Stevens wrote:
> Hi Jeremy,
> First, setting hmax to a small number could prevent a large step, if 
> you think that is a problem. Second, however, I don't see how you can 
> get a negative population size when using the log trick. 
SG:  Can lsoda estimate complex or imaginary parameters? 

> I would think that that would prevent completely any negative values 
> of N (i.e. e^-100000 > 0). Can you explain? or do you want to a void 
> that trick? The only other solver I know of is rk4 and it is not 
> recommended.
> Hank
> On Jun 11, 2007, at 11:46 AM, Jeremy Goldhaber-Fiebert wrote:
>
>> Hi Spencer,
>>
>> Thank you for your response. I also did not see anything on the lsoda 
>> help page which is the reason that I wrote to the list.
>>
>>> From your response, I am not sure if I asked my question clearly.
>>
>> I am modeling a group of people (in a variety of health states) 
>> moving through time (and getting infected with an infectious 
>> disease). This means that the count of the number of people in each 
>> state should be positive at all times.
>>
>> What appears to happen is that lsoda asks for a derivative at a given 
>> point in time t and then adjusts the state of the population. 
>> However, perhaps due to numerical instability, it occasionally lower 
>> the population count below 0 for one of the health states (perhaps 
>> because it's step size is too big or something).
>>
>> I have tried both the logarithm trick
<snip>



More information about the R-help mailing list