Model not running with error processing

Hello,

I’m trying to run a model and am getting an error that’s hard to interpret.

error

StatusERROR:cmdstanpy:Chain [4] error: error during processing Operation not permitted
                                                                                                                                                                                                                                                                                                                                
ERROR:cmdstanpy:Chain [1] error: error during processing Operation not permitted
ERROR:cmdstanpy:Chain [2] error: error during processing Operation not permitted
ERROR:cmdstanpy:Chain [3] error: error during processing Operation not permitted
chain 1 |██████████| 00:00 Sampling completed
chain 2 |██████████| 00:00 Sampling completed
chain 3 |██████████| 00:00 Sampling completed
chain 4 |██████████| 00:00 Sampling completed
INFO:cmdstanpy:CmdStan done processing.
Traceback (most recent call last):
  File "C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\decile_analysis\cancellation_rate_hier.py", line 54, in <module>
    fit = my_model.sample(data=data_dict, iter_warmup=200, iter_sampling =5000,
  File "c:\users\jordan.howell.gitdir\src\cmdstanpy\cmdstanpy\model.py", line 1085, in sample
    raise RuntimeError(msg)
RuntimeError: Error during sampling:
Command and output files:
RunSet: chains=4, chain_ids=[1, 2, 3, 4], num_processes=4
 cmd (chain 1):
	['C:\\Users\\JORDAN.HOWELL.GITDIR\\PycharmProjects\\decile_analysis\\cancellation_hier.exe', 'id=1', 'random', 'seed=15303', 'data', 'file=C:\\Users\\JORDAN~1.GIT\\AppData\\Local\\Temp\\tmpxox6w8d4\\xff2dxlh.json', 'output', 'file=D:\\Stan\\cancellation_hier-20220308141823_1.csv', 'method=sample', 'num_samples=5000', 'num_warmup=200', 'algorithm=hmc', 'adapt', 'engaged=1']
 retcodes=[1, 1, 1, 1]
 per-chain output files (showing chain 1 only):
 csv_file:
	D:\Stan\cancellation_hier-20220308141823_1.csv
 console_msgs (if any):
	D:\Stan\cancellation_hier-20220308141823_0-stdout.txt
INFO:cmdstanpy:deleting tmpfiles dir: C:\Users\JORDAN~1.GIT\AppData\Local\Temp\tmpxox6w8d4
INFO:cmdstanpy:done

Here is my model. I don’t think it’s the model as this has ran for other data before.

functions {
real half_normal_rng(real mu, real sigma) {
    real p = normal_cdf(0, mu, sigma);  // cdf for bounds
    real u = uniform_rng(p, 1);
    return (sigma * inv_Phi(u)) + mu;  // inverse cdf for value
}
}

data {
    int<lower=1> N;           // number of observations
    vector<lower=0>[N] loss_ratio; //target
    vector[N] cancel_rate;  //monthly cancel rate
    int<lower=1> p;
}

parameters {
    real alpha;               // intercept
    real beta;                // slope
    real<lower=0> sigma;      // scatter
}

transformed parameters {
    // Any variable declared here is part of the output produced for draws.
    vector[N] mu;
    mu = alpha + beta * cancel_rate;
}

model {
    // priors
    alpha ~ normal(0,5);  // prior for intercept
    beta ~ normal(0,5);     // prior for cancellation rate
    sigma ~ normal(0,5);    // prior for sigma
    // likelihood
    for (i in 1:N) {
    loss_ratio[i] ~ normal(mu, sigma) T[0,];
}
}

generated quantities {
    vector[p] loss_ratio_ppc;
    for (i in 1:p) {loss_ratio_ppc[i] = half_normal_rng(mu[i], sigma);}
}

instead of

model{
vector[N] mu = alpha+beta*x;
y~normal(mu,sigma);
}

Is there anything in that error statement I’m missing?

I got the same cryptic message and it turns out to be because I’d set show_console = False in the call to .sample(). The root cause was a failure to initialize.