Hi,
I’m working on a Bayesian ANOVA, where we are analyzing grass production over time at different sites. I’m starting with a basic, two factor ANOVA with no interactions. The model is specified as
y = a + X_t B_t + X_s B_s
where X_t is the design matrix for time (there are four years, so three columns), and X_s is the design matrix for site (six sites, so five columns). I’m calculating the finite population SDs for the residuals, time, and site, and trying to infer which predictors are important. Here is the model:
anova_model = """
data{
int<lower=1> N;
int<lower=1> K1;
int<lower=1> K2;
int<lower=1> K3;
matrix[N,K1] X_T;
matrix[N,K2] X_S;
vector[N] y;
}
parameters{
real alpha;
vector[K1] B_T;
vector[K2] B_S;
vector[K3] B_I;
real<lower=0> sd_y;
real<lower=0> sd_bt;
real<lower=0> sd_bs;
}
transformed parameters{
vector[N] yhat;
yhat = alpha + X_S*B_S + X_T*B_T;
}
model{
y ~ normal(yhat, sd_y);
B_T ~ normal(0, sd_bt);
B_S ~ normal(0, sd_bs);
sd_y ~ cauchy(0, 2.5);
sd_bt ~ cauchy(0, 2.5);
sd_bs ~ cauchy(0, 2.5);
}
generated quantities{
vector[N] e_y;
real s_y;
real s_t;
real s_s;
e_y = y - yhat;
s_y = sd(e_y);
s_t = sd(B_T);
s_s = sd(B_S);
}
"""
And here are the estimates of the finite population SDs (note that they do not change if I remove the intercept and estimate a fully parameterized model):
SD Time 0.17 (0.05 - 0.31
SD Site 0.57 (0.43 - 0.69)
SD Y 0.82 (0.81 - 0.84)
Notice that the residual SD is much higher than the SDs for either time or site. I’m confused as to how this compares to the ANOVA table, which shows strong significant effects of both site and time:
df sum_sq mean_sq F PR(>F)
Site 5.0 59.431515 11.886303 17.553918 1.038023e-14
C(Treat_Year) 3.0 22.505475 7.501825 11.078838 8.090096e-07
Residual 229.0 155.063010 0.677131 NaN NaN
Is the residual SD higher in the Bayesian model because sd(e_y) is using a different df. for residual variance? It’s using N-1 by default, but the ANOVA table would be using N - 9 (1 df. for the mean, 8 for time and site)?
I noticed that in Gelman (2005) - Ann. of Appl. Stat. and in Gelman and Hill (2007), the ANOVA figures don’t display the finite SD for ‘residual error’. I know for sure that, if we submit a figure showing no residual variance, we will be asked that question. How can I infer that effects are important if the residual error is so much higher than the error among sites or years? I guess the question is mostly about inference and how to infer effects are important and why there’s a disconnect between the Bayesian results and the ANOVA table.