Hello,
Try using an equal sign after 'sigma':
algo=maxNR(loglikelihood,
start=c(sigma=8.686603,beta1=-4.976215,beta2=7.313875))
Hope this helps,
Rui Barradas
?
Citando Emma MONTARSOLO <emsolo at hotmail.fr>:
> Hi !
>
> I use maxNR function (from maxLik package) to estimate parameters
> via maximum likelihood and Newton?Raphson method.
>
> Context :
> I have a variable Y which follows a Gumbel distribution of
> parameters Beta1X1 + Beta2X2 (location parameter) and sigma (scale
> parameter).
> I have to estimate sigma, beta1 and beta2
>
> The following errors appear when I run maxNR :
>> algo=maxNR(loglikelihood,
>> start=c(sigma:8.686603,beta1=-4.976215,beta2=7.313875))
>
> Iteration 1
> Parameter:
> ? ? ? ? ? ? ? ? ?beta1? ? ? ?beta2
> ? 4.251275 -249.985063? ? 5.376905
> ? ? beta1 beta2
> NaN? ?NaN? ?NaN
> Error in maxNRCompute(fn = function (theta, fnOrig, gradOrig = NULL,
> hessOrig = NULL,? :
> NA in gradient
> In addition: There were 15 warnings (use warnings() to see them)
>> warnings()
>
> Messages d'avis :
> 1: In log(sigma) : NaNs produced
> 2: In log(sigma) : NaNs produced
> 3: In log(sigma) : NaNs produced
> 4: In log(sigma) : NaNs produced
> 5: In log(sigma) : NaNs produced
> 6: In log(sigma) : NaNs produced
> 7: In log(sigma) : NaNs produced
> 8: In log(sigma) : NaNs produced
> 9: In log(sigma) : NaNs produced
> 10: In log(sigma) : NaNs produced
> 11: In log(sigma) : NaNs produced
> 12: In log(sigma) : NaNs produced
> 13: In log(sigma) : NaNs produced
> 14: In log(sigma) : NaNs produced
> 15: In log(sigma) : NaNs produced
>
> My code is the following :
>
> n=length(data_reg$y)
>
> loglikelihood<-function(parameters)
> {
> sigma<-parameters[1]
> beta1<-parameters[2]
> beta2<-parameters[3]
>
> Z=(data_reg$y-(beta1*data_reg$x1)-(beta2*data_reg$x2))/sigma
> ll=-(n*log(sigma))+sum(Z+exp(-Z))
> ll
> }
>
> algo=maxNR(loglikelihood,
> start=c(sigma:8.686603,beta1=-4.976215,beta2=7.313875))
>
> I use results from a previous estimation method as starting values.
>
> Thanks for your help. ??
>
> EM
>
> ? ? ? ? [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.htmland provide commented,
> minimal, self-contained, reproducible code.
?
[[alternative HTML version deleted]]