data {
int<lower=1> N; // number of observations
int<lower=1> Q; // number of quarters
int<lower=1> J; // number of variables
int<lower=1> D; // number of district-seasons
...
}
parameters {
real beta[J, Q + 1];
real intercept;
real districtseason_eff[D];
real<lower=.0001, upper=10000> sig[J];
}
transformed parameters {
districtseason_eff[1] <- 0;
}
model {
...
for(k in 2:D)
districtseason_eff[k] ~ normal(0,10000)T(-10,10);
...
}districtseason_eff[2:D] ~ normal(0,10000)T(-10,10);
I want to set districseason_eff[1] <- 0 as the base case and and estimate the other elements of the vector, but I'm not exactly sure in which section to make the assignment of the first element. Currently I have it in transformed parameters
parameters {
real beta[J, Q + 1];
real intercept;
real<lower=-10,upper=10> districtseason_eff[D-1]; // note added constraints
real<lower=.0001, upper=10000> sig[J];
}
model {
real Districtseason_eff[D];
Districtseason_eff[1] <- 0.0;
for (d in 2:D)
Districtseason_eff[d] <- districtseason_eff[d-1];
for(d in 1:(D-1))
districtseason_eff[d] ~ normal(0,10000)T(-10,10);
...
}
districtseason_eff? traum_injuries ~ poisson(exp(log_total_hours_worked + intercept + beta[1,qtr] * any_union + ... // other covariates + beta[31,qtr] * mean_bed_thickness_A4_dum + districtseason_eff[districtseason]);Marcus, with your method, can I use districtseason_eff later in the model? I also havetraum_injuries ~ poisson(exp(log_total_hours_worked+ intercept+ beta[1,qtr] * any_union+ ... // other covariates+ beta[31,qtr] * mean_bed_thickness_A4_dum+ districtseason_eff[districtseason]);districtseason is the data vector containing the district-season for each observation as an integer 1,...,D. Will this still work with your method? I'm not familiar with the order that Stan executes assignments and parameter transformations.