Error in eval(substitute(expr), data, enclos = parent.frame()) : object 'S' not found

optim(par = as.numeric(c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1)), 
+       fn = loglik_function,       
+       dat = reported_data,         
+       control = list(fnscale=-1))

# Where can I start to look Error in eval(substitute(expr), data, enclos = parent.frame()) :    object 'S' not found 

When you hit an error in R, one of the best things to do is run traceback() as this will bring up a sequence of calls that have happened. So the function optim() runs some other functions inside it, the traceback() function looks at these calls to see where the last error occured. This could be a few levels deep. But it will show you what S needs to be in that expression.

It's difficult for someone to help with this issue as loglik_function and reported_data are not provided. It's worth mentioning as well that dat= is not an argument to the optim() function and so is presumably being passed to loglik_function()

If you could provide more context surrounding your issue, helping would be much easier. Or take a look at the {reprex} package to give us reproducible code.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.