R version 3.6.3. brms version 2.15.0
I would like to use the fitted() function to estimate the fitted model for some new data. However, I am getting NaN and NAs for the response variable of interest in my non-linear model.
fit <- brm(
bf(outcome ~ previousoutcome + throttleM,
throttleM ~ 0 + mi(throttle), nl=TRUE) +
bf(throttle | mi() ~ 1 + previousoutcome + time*treatment),
data = data1, iter=4000, family = gaussian(),
prior = c(
prior(normal(2,0.5), class=sigma, resp="outcome"),
prior(normal(1,0.001), class=b, coef="mithrottle",resp="outcome", nlpar="throttleM"),
prior(normal(0,1), class=b, coef="previousoutcome", resp="throttle"),
prior(normal(0,0.05), class=b, coef="treatment", resp="throttle"),
prior(normal(0,0.05), class=b, coef="time", resp="throttle"),
prior(normal(0,0.05), class=b, coef="time:treatment", resp="throttle"),
prior(normal(5,2), class=Intercept, resp="throttle"),
prior(normal(2,0.5), class=sigma, resp="throttle")
),
control = list(adapt_delta = 0.9999, max_treedepth=15), save_pars = save_pars(all = TRUE)
)
#this works
f <- fitted(fit)
#this gives NaN and NA for 'Estimate.outcome' and 2.5 and 97.5% intervals but gives values for 'Estimate.throttle'
#this happens, even though I use the same dataset as in the above call where newdata=NULL
f <- fitted(fit, newdata=data1)
Does fitted(fit, newdata= newdata) not work for a non-linear model where the response is estimated in part by another response that is missing? @paul.buerkner @martinmodrak
Thanks!!