Hello,
I'm new to using the syntax but familiar with TMB. I was having trouble debugging some code and located the issue. In the code below, any thoughts on why simply adding the probabilistic print statement seem to mess up the estimation but the other way doesn't.
Thanks to anyone who knows,
Brandon
set.seed(10)
data <- list(x = rbinom(100,1,prob=0.2))
parameters <- list(mu = 0)
f <- function(parms){
RTMB::getAll(data,
parms)
x <- OBS(x)
# print(x[1]%~%RTMB::dbinom(1,plogis(mu)))
# print(RTMB::dbinom(1,1,plogis(mu),log=TRUE))
nll <- -sum(dbinom(x,1,plogis(mu),log=TRUE))
return(nll)
}
obj <- RTMB::MakeADFun(f,
parameters,
silent = FALSE)
opt <- nlminb(obj$par,
obj$fn,
obj$gr)
print(opt$par)