[R] function of mixture normal with covariates
Tal & Julia Vider
jtvider at 013.net
Wed Dec 31 13:32:36 CET 2008
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: liklihood2stage.pdf
Type: application/pdf
Size: 40055 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081231/446ee3be/attachment.pdf>
More information about the R-help
mailing list