I am fitting a model (very much simplified for reproducible) like so:
library(datasets) library(rstanarm)
set.seed(42)
rm(list = ls(all = TRUE))
prediction_data1 <- data.frame(
Petal.Length = 1.4
)
prediction_data2 <- data.frame(
Petal.Length = 1.4
)
model <- stan_glm(
Petal.Width ~ Petal.Length
, data = iris
, chains = 3
, iter = 1000
, warmup = 100
)
new_predictions1 <- as.data.frame(posterior_predict(model, newdata = prediction_data1))
new_predictions2 <- as.data.frame(posterior_predict(model, newdata = prediction_data2))
colnames(new_predictions1) <- c('Petal.Width')
colnames(new_predictions2) <- c('Petal.Width')
median(new_predictions1$Petal.Width)
median(new_predictions2$Petal.Width)
I guess I should not expect the same median for both equal 'simulation' datasets (e.g. 0.2216209 and 0.2177802)? However is the above skeleton code a correct approach to simulate different scenarios ( e.g. Petal.Length = 1.4 versus Petal.Length = 2.4)?