[R] Help fix last line of my optimization code
Uwe Ligges
ligges at statistik.tu-dortmund.de
Fri Jul 1 14:13:02 CEST 2011
Please
a) read the posting guide
b) really submit reproducible code. Yours is not.
c) read ?optimize and learn to specify the interval
d) you specified an argument init.params, but that is not used in
optimize() nor can it be usefully passed to llik.
Uwe Ligges
On 01.07.2011 02:46, Edward Bowora wrote:
> Hi
>
> I need help figure out how to fix my code.
>
> When I call into R
>> optimize(llik,init.params=F)
> I get this error message
> ####Error in optimize(llik, init.params = F) : element 1 is empty;
> the part of the args list of 'min' being evaluated was:
> (interval)####
>
>
> My data and my code looks like below.
>
>
> R_j R_m
> 0.002 0.026567296
> 0.01 0.003194435
> . .
> . .
> . .
> . .
> 0.0006 0.010281122
>
> a=read.table("D:/ff.txt",header=T)
> attach(a)
> llik=function(R_j,R_m)
> #The parameters al_j, au_j, b_j ,
> and sigma_j need to be estimated and there are no initial estimates to
> them.
> if(R_j< 0)
> {
> LF=sum[log(1/(2*pi*(sigma_j^2)))-(1/(2*(sigma_j^2))*(R_j+al_j-b_j*R_m))^2]
> }else if(R_j>0)
> {
> LF=sum[log(1/(2*pi*(sigma_j^2)))-(1/(2*(sigma_j^2))*(R_j+au_j-b_j*R_m))^2]
> }else
> {
> LF=sum[(log(pnorm((au_j-b_j*R_m)/sigma_j)-pnorm((al_j-b_j*R_m)/sigma_j)))]
> }
> optimize(llik,init.params=F)
> Error in optimize(llik, init.params = F) : element 1 is empty;
> the part of the args list of 'min' being evaluated was:
> (interval)
>
> Thank you
>
> Edward
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list