predictions: Compute the predictions and confidence intervals

predictionsR Documentation

Compute the predictions and confidence intervals

Description

The functions compute_predictions and compare_predictions compute predictions and compare them, respectively. In both cases, 95% confidence intervals are computed, and it is possible to account for the random effects by integrating predictions over the entire distribution of such effects. In such a case, the predictions produced thus correspond to marginal predictions.

Usage

compare_predictions(
  fit,
  newdata,
  oddsratio = FALSE,
  random = TRUE,
  nb_boot = 1000L,
  seed = 123L
)

compute_predictions(fit, newdata, random = TRUE, nb_boot = 1000L, seed = 123L)

Arguments

fit

a model fitted (directly or indirectly) with fitme or any fit_xx function from this package

newdata

a data.frame providing the values for the fixed effect predictors

oddsratio

a logical indicating whether the difference in predictions should be expressed as an odds ratio instead of as a simple difference (default = FALSE)

random

a logical indicating whether the predictions should be integrated over random effect(s)

nb_boot

the number of simulations for the parametric bootstrap used to compute the intervals

seed

an integer providing the seed for the random generator

Details

We recommend you to look at the raw R code of these functions on GitHub (file '/R/predictions_and_CI.R') to understand how they work. We commented the code to make this clear. While you could directly look at the code of these functions while using the package, mind that the comments will have been stripped away during the installation process. We kept all the code of each function self contained, instead of writing modular functions to ease the exploration of the code (everything is in one place). One drawback is that it leads to a code full of repetitions.

Value

a list containing the predictions (or differences in predictions) and intervals, as well as the estimates from each bootstrap replicate used to compute the intervals and the object created by boot.ci.

Functions

  • compare_predictions(): compute differences or odds ratio between two predictions

  • compute_predictions(): compute multiple predictions


courtiol/twinR documentation built on July 11, 2024, 12:04 a.m.