Hi @martinmodrak, thanks for your suggestions, they are very helpful. I was wondering, though, if you had any issues with collinearity between eta and y0 when you fit the alternative parameterisation?
I had a go at fitting the model, although I am still quite new to model building so I might have made a mistake. Here is the equation:
\mu=f(x,(y_{0},\beta,\eta))=\frac{y_{0}(1 +e^{\eta\beta})}{1+e^{-\beta(\eta - x)}}
\tilde{y}_{i}\sim normal(\mu_{i},\sigma)
Priors:
Hardiness has been multipled with -1 to be positive, and air temp has been standardized (mean is 0)
beta \sim Normal(10,5)
eta \sim Normal(0, 0.35)
y_{0} \sim halfNormal(15,5)
\sigma \sim normal(0,5)
Stan Code:
data {
int<lower=1> N; // Number of observations
vector[N] x; // Dose values (air temperature)
vector[N] y; //winter hardiness, *-1 to eb positive
}
// Sampling space
parameters {
real beta; // slope
real eta; // infelction point of x.
real<lower=0> y0; // y intercept (where x is 0)
real<lower=0> sigma_g; //error around the estimated hardiness
}
// Calculate posterior
model {
vector[N] mu_y;
// Priors on parameterssimLTEPos <- simLTE * -1
beta ~ normal(10, 5); // centred around no hardiness, could be as high as -20
eta ~ normal(0, 0.35); // centred around 0 (x mid point), but can range around all x values, but strongly constrained to sit around the mean
sigma_g ~ normal(0, 5); //
y0 ~ normal(15, 5); // constraining y0 to fall inside normal hardiness values
//liklyhood function
for (i in 1:N) {
mu_y[i] = (y0*(1 + exp(beta*eta))/ (1 + exp(beta*(eta-x[i]))));
}
y ~ normal(mu_y, sigma_g); // I dont know why, but this was a poisson distribution in the original model
}
generated quantities {
// Simulate model configuration from prior model (get mu_y)
vector[N] mu_y; // Simulated mean data from likelyhood
vector[N] y_sim; //Simulated Data
//liklyhood function
for (i in 1:N) {
mu_y[i] = (y0*(1 + exp(beta*eta))/ (1 + exp(beta*(eta-x[i]))));
}
// Simulate data from observational model
for (n in 1:N) y_sim[n] = normal_rng(mu_y[n], sigma_g);
}
The model doesn’t give any warnings and predicts the values well for my simulated data so I may be worrying about nothing, but I think that the pairs plot suggests strong collinearity between eta and y0. Did you see this problem also, or is it likely to be a miss-specification on my part?