Displaying 1 result from an estimated 1 matches for "logfunc".
Did you mean:
logfun
2007 Jun 19
1
Error handling
...which breaks - ideally the program would complete the for loop even though there are errors). Of course this is just an example, in the simulation study the error comes up quite rarely but still it is annoying to handle it manually each time.
Many thanks
Peter
The example:
------------
logfunc <- function (params) {
vutil1 <- as.matrix(x2[,1:3]) %*% params
vutil2 <- as.matrix(x2[,4:6]) %*% params
logl <- 0
for (i in 1:6) {
prob <- log((exp(vutil1[i])*achoices[i,1]+exp(vutil2[i])*achoices[i,2])/(exp(vutil1[i])+exp(vutil2[i])))
logl <- logl + prob
}
return (...