model <- stan(data = input.data,
chains = 0,
iter = 0,
model_code = "
data{
int <lower = 1> N;
vector[N] tStartExposure;
vector[N] tEndExposure;
vector[N] tSymptomOnset;
}
parameters{
real<lower = 0> alphaInc; // Shape parameter of weibull distributed incubation period
real<lower = 0> sigmaInc; // Scale parameter of weibull distributed incubation period
vector<lower = 0, upper = 1>[N] uE; // Uniform value for sampling between start and end exposure
}
transformed parameters{
vector[N] tE; // infection moment
tE = tStartExposure + uE .* (tEndExposure - tStartExposure);
}
model{
// Contribution to likelihood of incubation period
target += weibull_lpdf(tSymptomOnset - tE | alphaInc, sigmaInc);
}
generated quantities {
// likelihood for calculation of looIC
vector[N] log_lik;
for (i in 1:N) {
log_lik[i] = weibull_lpdf(tSymptomOnset[i] - tE[i] | alphaInc, sigmaInc);
}
}
"
)
stanfit <- stan(fit = model, data = input.data,
init = "random",
warmup = 4000,
iter = 14000,
chains = 8)
error:SAMPLING FOR MODEL ‘anon_model’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”
[1] "error occurred during calling the sampler; sampling not done