Hi everyone,
I’m working on a Bayesian Measurement Error Model in Stan and would appreciate your feedback on whether my code is correctly specified. The objective is to account for measurement errors in both x (Method 1) and y (Method 2) while modeling their true relationship using a Bayesian approach.
- Method 1 estimates evapotranspiration,
- Method 2 measures evapotranspiration and is treated as the reference.
Both methods are assumed to have a 10% error. I’d greatly appreciate any insights or suggestions on improving the model specification.
Thank you in advance
Stan code:
data {
int<lower=0> N; // Number of data points (days)
vector[N] x_obs; // Observed values for x (Method 1)
vector[N] y_obs; // Observed values for y (Method 2)
real<lower=0> sigma_x; // Known measurement error in Method 1 (x) (10%)
real<lower=0> sigma_y; // Known measurement error in Method 2 (y) (10%)
}
parameters {
real alpha; // Intercept
real beta; // Slope
real<lower=0> sigma; // Residual standard deviation
}
model {
// Priors
alpha ~ normal (0, 10); // Weakly informative prior for intercept
beta ~ normal (0, 10); // Weakly informative prior for slope
sigma ~ cauchy (0, 5); // Weakly informative prior for residuals
// Structural model with error propagation for both x and y
y_obs ~ normal(alpha + beta * x_obs, sqrt(sigma^2 + sigma_y^2 + beta^2 * sigma_x^2));
}