# NOT RUN {
# Makes a stanfit object (more precisely its inherited S4 class object)
fit <- fit_Bayesian_FROC(BayesianFROC::dataList.Chakra.1,
ite = 1111,
summary =FALSE,
cha = 2)
# Calculates the chi square discrepancies (Goodness of Fit)
# with the posterior mean as a parameter.
NI <- fit@dataList$NI
NL <- fit@dataList$NL
f.observed <- fit@dataList$f
h.observed <- fit@dataList$h
C <- fit@dataList$C
# p <- rstan::get_posterior_mean(fit, par=c("p"))
# lambda <- rstan::get_posterior_mean(fit, par=c("l"))
# Note that get_posterior_mean is not a number but a matrix when
# Chains is not 1.
# So, instead of it, we use
#
e <- extract_EAP_CI(fit,"l",fit@dataList$C )
lambda <- e$l.EAP
e <- extract_EAP_CI(fit,"p",fit@dataList$C )
p <- e$p.EAP
Chi.Square <- chi_square_goodness_of_fit_from_input_all_param(
h = h.observed,
f = f.observed,
p = p,
lambda = lambda,
NL = NL,
NI = NI
)
# Get posterior mean of the chi square discrepancy.
Chi.Square
# Calculate the p-value for the posterior mean of the chi square discrepancy.
stats::pchisq(Chi.Square,df=1)
# }
# NOT RUN {
# dottest
# }
Run the code above in your browser using DataLab