rms_calc_comparisons: Calculate estimates (XB or hazard/odds ratios, depending on...

Description Usage Arguments Value See Also Examples

View source: R/rms_calc_comparisons.R

Description

Calculate estimates (XB or hazard/odds ratios, depending on model type) for specified values of a numeric model covariate, or all levels of a factor covariate, vs a reference level. Store in a data frame.

Usage

1
2
rms_calc_comparisons(rmsObj, getRatios, df, vname, refVal, compVals,
  nUnique = 10, compQuant = c(0.1, 0.25, 0.5, 0.75, 0.9), rndRC = 2)

Arguments

rmsObj

Model fit object of class rms.

getRatios

Indicator for whether to calculate ratios (exp(XB)) vs estimates on XB scale. Defaults to TRUE if rmsObj is from cph() or lrm().

df

Data frame from which to get variable class information and, if needed, reference and comparison values.

vname

String; name of variable in both names(df) and a covariate in rmsObj.

refVal

Value or factor level to set reference level of df[,vname] to. Default is median (numeric) or first level (factor).

compVals

Numeric; value(s) to set comparison levels of vname to, if df[,vname] is numeric.

nUnique

Integer; if compVals are not specified and number of unique values of variable is < nUnique, will calculate estimates for every unique value vs reference.

compQuant

Numeric vector; if compVals are not specified, gets these quantiles from df to use as default comparison values. Defaults to c(0.1, 0.25, 0.5, 0.75, 0.9).

rndRC

Integer; number of digits to round reference, comparison columns to for numeric variables. Defaults to 2.

Value

data.frame containing reference, comparison, effect, lower and upper confidence limits, variable name and indicator for whether row contains reference:reference comparison.

See Also

ols, lrm, cph, Gls, summary.rms.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Fit linear regression using ols()
mymod <- ols(Sepal.Length ~ Species + Sepal.Width, data = iris)

## Set datadist
dd.iris <- datadist(iris)
options(datadist = 'dd.iris')

## Continuous covariate, comparing all quantiles to median by default
rms_calc_comparisons(mymod, vname = 'Sepal.Width', df = iris)

## Categorical covariate, comparing all levels to reference
rms_calc_comparisons(mymod, vname = 'Species', df = iris)

jenniferthompson/JTHelpers documentation built on May 19, 2019, 4:04 a.m.