[FLR-list] Hockey stick

Laurie lauriekell at googlemail.com
Wed Mar 21 10:30:06 CET 2012


On 03/20/2012 11:10 PM, Iago Mosqueira wrote:
> On 03/21/2012 02:45 AM, Luis Ridao wrote:
>> FLR-help,
>>
>> I'm fitting a Hockey-stick function with following:
>>
>> fsai.segreg <- fsaiSR
>> model(fsai.segreg) <- segreg()
>> fsai.segreg <- fmle(fsai.segreg)
>>
>> and the parameter estimates are as follows:
>>
>> > params(fsai.segreg)
>> An object of class "FLPar"
>> params
>>         a        b
>>   0.63387 45.31551
>> units:  NA
>>
>> However I want to use the parameter estimates from ADMB
>> which are something like :
>>
>> a = 0.6060456
>> b = 56.51466
>>
>> How can i set the ADMB-estimates in the 'fsai.segreg' object and 
>> recalculate
>> the residuals and log-likelihood based on these estimates?
>>
>> I do something like:
>> > model(fsai.segreg3) <- segreg(FLpar(a = exp(-0.5008), b = 
>> exp(4.0345)))
>> Error in segreg(FLpar(a = exp(-0.5008), b = exp(4.0345))) :
>>
>> and :
>>
>> > model(fsai.segreg3) <- segreg(params=list(FLpar(a = exp(-0.5008), b =
>> exp(4.0345))))
>> Error in segreg(params = list(FLpar(a = exp(-0.5008), b = 
>> exp(4.0345)))) :
>>    unused argument(s) (params = list(FLpar(a = exp(-0.5008), b =
>> exp(4.0345))))
>>
>>
>> Thanks in advance
>
> params(fasi.segreg3) <- FLPar(a = exp(-0.5008), b = exp(4.0345))
>
> should get you the parameter values into the object. Then you will 
> have to calculate the estimated values residuals and get them into the 
> fitted and residuals slots. For the logLik, we simply report the value 
> returned by optim.
>
> Cheers,
>
>
> Iago
>
> _______________________________________________
> flr-list mailing list
> flr-list at flr-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/flr-list

You will have tom use methods to calculate values conditional on your 
new parameters, e.g.

If you use predict() then you will have your predicted values and obs 
are found by rec() so residuals are found by

log(rec(x)/predict(x))

predict()

computeLogLik() will calculate your new likelihood.

I think we should add computeMethods for each slot so that you can 
either look up what is in a slot or recalculate the values.

Laurie








More information about the flr-list mailing list