Dear all,
I ran my model in the RSTAN as follow.
fit.total06 ← stan(“dependencymodel.stan”,data = da,iter=iter, warmup=warmup, cores =2,chains = 2, thin = 1, init = “random”, control = list(c(adapt_delta = 0.99,max_treedepth = 15)))
Now, When I want to calculate the loo and WAIC from the loo package, I get the following error.
extract_log_lik (fit.total06, parameter_name = “log_lik”, merge_chains = TRUE)
Error is as below:
“”
Error in extract_log_lik(fit.total06, parameter_name = “log_lik”, merge_chains = TRUE) :
could not find function “extract_log_lik”
“”
Could someone help me to solve this problem?
extract_log_lik(fit.total06, parameter_name = "log_lik", merge_chains = TRUE) will only work if you have a variable in your model called log_lik. If it’s not called log_lik then you can change the name in the parameter_name argument, but it needs to be able to find the log likelihood values computed in the Stan program. For more info on this check out this vignette in the loo package, which demonstrates how to write a Stan program compatible with loo: