Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unexpected symbol" in R [closed]

Tags:

r

I can't figure out why I keep getting this error

Error: unexpected symbol in:
"  ans <- logver(theta)-logver(est)
  return exp"
> }
Error: unexpected '}' in "}"

This is my code:

n <- 27
sum <- 30 + 28 + 26 + 22 + 26 + 27 + 25 + 18 + 34 + 33 + 20 + 25 + 27 + 33 + 31 + 27 + 21 + 30 + 26 + 24 + 30 + 33 + 17 + 28 + 21 + 30 + 27


precision<-0.1                #precision de la rejilla
intervalo<-1                  #parámetro del tamaño del intervalo a graficar

logver <- function (theta) {
  return -27 * theta + log (theta) * sum
}

est<- sum / n;
VR <- function (theta) {              #Verosimilitud Relativa (RV)
  ans <- logver(theta)-logver(est)
  return exp(ans)
}

Although, it works fine if I remove the "exp" function call.

like image 881
Eduardo Avatar asked Nov 25 '25 14:11

Eduardo


1 Answers

You have no parenthesis for the return

return(exp(ans))
like image 140
Matthew Lundberg Avatar answered Nov 27 '25 08:11

Matthew Lundberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!