I was wondering if it is possible to subset the posterior prediction for a specific predictor value (here `hp = 93`

) from `posterior_predict()`

?

`fit <- stan_glm(mpg ~ hp, data = mtcars)`

`pred <- posterior_predict(fit)`

I was wondering if it is possible to subset the posterior prediction for a specific predictor value (here `hp = 93`

) from `posterior_predict()`

?

`fit <- stan_glm(mpg ~ hp, data = mtcars)`

`pred <- posterior_predict(fit)`

```
fit <- stan_glm(mpg ~ hp, data = mtcars)
pred <- posterior_predict(fit, newdata = data.frame(hp = 93))
```

Thank you so much! Maybe this sounds like programming but is it possible to locate the exact location (i.e., which row which column) of the sample that is stored in `pred`

below in the entire `posterior_predict(fit)`

?

`fit <- stan_glm(mpg ~ hp, data = mtcars)`

`pred <- posterior_predict(fit, newdata = data.frame(hp = 93))`

You mean

```
fit <- stan_glm(mpg ~ hp, data = mtcars)
pred <- posterior_predict(fit)[ , mtcars$hp == 93, drop = FALSE]
```

?

I mean where is the sample stored in `pred <- posterior_predict(fit, newdata = data.frame(hp = 93))`

located in the larger sample from `posterior_predict(fit)`

? Could we find the predictions for a specific value of predictor by knowing the row or a column number in the larger sample from `posterior_predict(fit)`

instead of using `newdata`

?

Other than the ways outlined above, no.

The columns are always in the same order as the rows of newdata (or, if not specified, the original data). I think that should be enough to find anything you want, right? Sorry if I’m misunderstanding.