dlogl <- -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta))) d2logl <- (n/theta^2) - sum((-2y/theta^3)*(1-exp(y/theta))/(1+exp(y/theta))) - sum(((2*y/theta^4)*exp(y/theta))/((1+exp(y/theta))^2)) returns the error message: Error: unexpected symbol in: "dlogl <- -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta))) d2logl" do you know what i have done wrong -- View this message in context: http://www.nabble.com/what-is-wrong-with-this-code--tp23623227p23623227.html Sent from the R help mailing list archive at Nabble.com.
You're missing a ")" off end of the first line. You should consider using an editor (e.g. ESS/Emacs) that does parentheses matching. I found this in less than 5 sec (less time than I'm taking to write you a note) by cut and pasting in Emacs. --sundar On Tue, May 19, 2009 at 12:52 PM, deanj2k <dl120 at le.ac.uk> wrote:> > dlogl <- -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta))) > > d2logl <- (n/theta^2) - sum((-2y/theta^3)*(1-exp(y/theta))/(1+exp(y/theta))) > - sum(((2*y/theta^4)*exp(y/theta))/((1+exp(y/theta))^2)) > > returns the error message: > Error: unexpected symbol in: > "dlogl <- -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta))) > d2logl" > > do you know what i have done wrong > -- > View this message in context: http://www.nabble.com/what-is-wrong-with-this-code--tp23623227p23623227.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
On 19-May-09 19:52:20, deanj2k wrote:> dlogl <- > -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta))) > > d2logl <- (n/theta^2) - > sum((-2y/theta^3)*(1-exp(y/theta))/(1+exp(y/theta))) > - sum(((2*y/theta^4)*exp(y/theta))/((1+exp(y/theta))^2)) > > returns the error message: > Error: unexpected symbol in: > "dlogl <- > -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta))) > d2logl" > > do you know what i have done wrongThe error message strongly suggests that the line beginning "d2logl <-" is being seen as a continuation of the preceding line. Counting parentheses, I find that you are 1 short of what is required to complete the expression in the line beginning "-(n/theta)". In that case, R will continue on to the next line seeking the completion, and will encounter "d2logl" non-syntactically. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 19-May-09 Time: 22:12:40 ------------------------------ XFMail ------------------------------