Description Usage Arguments Value Note See Also Examples

View source: R/posterior_linpred.R

Extract the posterior draws of the linear predictor, possibly transformed by
the inverse-link function. This function is occasionally useful, but it
should be used sparingly. Inference and model checking should generally be
carried out using the posterior predictive distribution (i.e., using
`posterior_predict`

).

1 2 3 4 |

`object` |
A fitted model object returned by one of the
rstanarm modeling functions. See |

`transform` |
Should the linear predictor be transformed using the
inverse-link function? The default is |

`newdata, draws, re.form, offset` |
Same as for |

`XZ` |
If |

`...` |
Currently ignored. |

The default is to return a `draws`

by `nrow(newdata)`

matrix of simulations from the posterior distribution of the (possibly
transformed) linear predictor. The exception is if the argument `XZ`

is set to `TRUE`

(see the `XZ`

argument description above).

For models estimated with `stan_clogit`

, the number of
successes per stratum is ostensibly fixed by the research design. Thus,
when calling `posterior_linpred`

with new data and ```
transform =
TRUE
```

, the `data.frame`

passed to the `newdata`

argument must
contain an outcome variable and a stratifying factor, both with the same
name as in the original `data.frame`

. Then, the probabilities will
condition on this outcome in the new data.

`posterior_predict`

to draw from the posterior
predictive distribution of the outcome, which is typically preferable.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```
if (!exists("example_model")) example(example_model)
print(family(example_model))
# linear predictor on log-odds scale
linpred <- posterior_linpred(example_model)
colMeans(linpred)
# probabilities
probs <- posterior_linpred(example_model, transform = TRUE)
colMeans(probs)
# not conditioning on any group-level parameters
probs2 <- posterior_linpred(example_model, transform = TRUE, re.form = NA)
apply(probs2, 2, median)
``` |

rstanarm documentation built on Oct. 4, 2019, 1:04 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.