make_predict_df: Using 'glm' results, predict outcomes for each individual at...

View source: R/make_predict_df.R

make_predict_dfR Documentation

Using glm results, predict outcomes for each individual at each level of treatment/exposure

Description

Using glm results, predict outcomes for each individual at each level of treatment/exposure

Usage

make_predict_df(
  glm.res,
  df,
  X,
  subgroup = NULL,
  offset = NULL,
  rate.multiplier = 1
)

Arguments

glm.res

(Required) A fitted object of class inheriting from "glm" that will be used with new dataset for prediciton.

df

(Required) A new data frame in which to look for variables with which to predict. This is equivalent to the newdata argument in predict.glm.

X

(Required) Character argument which provides variable identifying exposure/treatment group assignment.

subgroup

(Optional) Default NULL. Character argument of the variable name to use for subgroup analyses. Variable automatically transformed to a factor within the function if not supplied as such.

offset

(Optional, only applicable for rate/count outcomes) Default NULL. Character argument which specifies the variable name to be used as the person-time denominator for rate outcomes to be included as an offset in the Poisson regression model. Numeric variable should be on the linear scale; function will take natural log before including in the model.

rate.multiplier

(Optional, only applicable for rate/count outcomes). Default 1 Numeric variable signifying the person-time value to use in predictions; the offset variable will be set to this when predicting under the counterfactual conditions. This value should be set to the person-time denominator desired for the rate difference measure and must be inputted in the units of the original offset variable (e.g. if the offset variable is in days and the desired rate difference is the rate per 100 person-years, rate.multiplier should be inputted as 365.25*100).

Value

A data.frame of predicted outcomes for each level of treatment/exposure. Additional columns are provided for each subgroup *x*treatment, if specified.


riskCommunicator documentation built on June 1, 2022, 1:07 a.m.