Hi,
I have encountered some problems when running a simple model to estimate adjusted prevalence. I was wondering if the experts in this forum could give me some advice on how to remove the warning messages or make other suggestions.
The simple model is set as follows:
- the random variable (n) for the number of patients with positive test results following a binomial distribution with a probability (denoted by theta) in the total N patients
- the adjusted prevalence (p) is related to Theta by the formula “theta = p*sensitivity + (1 - p)*specificity”
- p has a prior distribution of Beta (1,1)
- sensitivity has a prior distribution of Beta, where the shape parameters are set so that the expectation value is equal to the value derived from the research data and the SD is small enough (around 0.05).
- specificity has a prior distribution of Beta, where the shape parameters are set so that the expectation value is equal to the value derived from the research data, and the SD is small enough (0.005).
Given that the dataset with N = (xxx, xxx) and n (xxx), the “rstan” code (provided in the end) was implemented. However, I have the warning messages shown below.
I wonder whether you have any advice on whether to remove the warning messages. Should I try other prior distributions for sensitivity and specificity (such as a truncated normal distribution) instead?
I look forward to receiving replies soon; thank you very much.
<< Warning messages: >>
Warning: There were 5676 divergent transitions after warmup.
See https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup to find out why this is a problem and how to eliminate them.
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. Running the chains for more iterations may help.
See https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. Running the chains for more iterations may help.
See https://mc-stan.org/misc/warnings.html#tail-ess
<< rstan code: >>
prev <- data.frame(Total = 1xx,xxx, Case = 2xx)
model <- 'data {
int N;
int n; }
parameters{
real <lower=0, upper=1> p;
real <lower=0, upper=1> sens;
real <lower=0, upper=1> spec; }
transformed parameters {
real <lower=0, upper=1> theta;
theta = p * sens + (1 - p) * (1 - spec); }
model {
sens ~ beta(xx, 51);
spec ~ beta(xx, 0.1);
target += uniform_lpdf(p | 0, 1);
target += binomial_lpmf(n | N, theta); }'
Data <- list(
N = prev$Total,
n = prev$Case)
fit <- stan(model_code = model,
data = Data,
chains = 4,
warmup = 3000,
iter = 8000,
cores = 1,
refresh = 0,
seed = 12345)