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/ac718063/attachment.pdf>
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>
Tal & Julia Vider <jtvider <at> 013.net> writes:> > 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: >You're missing a couple of close-parentheses somewhere -- perhaps after +log(v_pred)). When I add )) after that I get a syntactically correct likelihood function. Of course that does not guarantee that those parentheses are actually in the correct place mathematically (I haven't looked at your PDF in any more detail). In the long run and maybe even in the short run you will make your life easier if you use a programmer's editor of some sort (emacs, Tinn-R, ... depending on your taste and OS) that will let you match parentheses more easily. good luck Ben Bolker