Hello,

My name is Julia and I'm doing my phd on roc analysis.

I'm trying to write a maximization function for the likelihood attached in
the document.

For some reason it's not working I keep getting \this error:

Error: unexpected symbol in:

"    +log(v_pred))

return"

> }

Error: unexpected '}' in "}"

> 

> opp<-optim(c(meany0,meany1,stdy0,stdy1,dx,V,d),logl)

Error in optim(c(meany0, meany1, stdy0, stdy1, dx, V, d), logl) : 

  function cannot be evaluated at initial parameters

> 

 

This is what I wrote

 

# maximizing the log likelihood function

logl<-function(param,y,x)

{

mu0=param[1]

mu1=param[2]

sdy0=param[3]

sdy1=param[4]

pix_pred=param[5]

v_pred=param[6]

dxynew=param[7]

 

f3=-(sum(dxynew*(log(pix_pred)-log(sdy1)-0.5*((y-mu1-(rho*sdy1*x)/sdy1)^2))+

    sum((1-dxynew)*(log(1-pix_pred)-log(sdy0)
-0.5*((y-mu0-(rho*sdy0*x)/sdy0)^2))

    +log(v_pred))

return (-f3)

}

 

Need help please.

Thank u

Julia

Attachment: liklihood2stage.pdf
Description: Adobe PDF document

______________________________________________
[email protected] 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.

Reply via email to