why i have different results in the estimated coefficients?
data {
int<lower=0> N; // number of observations
int<lower=0,upper=1> y[N]; // setting the dependent variable (damage) as binary
vector[N] x; // independent variable
}
parameters {
real alpha; // intercept
real beta; // beta for thermal
}
model {
beta ~ normal(0,1);
for (n in 1:N)
y[n] ~ bernoulli(inv_logit(alpha + beta * x[n]));
}
'
thermal = c(53,57,58,63,66,67,67,67,68,69,70,70,70,70,72,73,75,75,76,76,78,79,81)
damage = c(1,1,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0)
rings = data.frame(thermal,damage);head(rings)
data = list(N = nrow(rings), y = rings$damage, x= rings$thermal)
fit = stan(model_code = nasa, data = data, iter = 4000, chains = 4,
seed = sample.int(.Machine$integer.max, 1),
control = list(max_treedepth = 15))
print(fit, digits = 3)
plot(fit)
fit1 <- stan_glm(damage ~ thermal, data = rings,
family = binomial(link = "logit"))
print(fit1)
}