Learn R Programming

tlm (version 0.2.0)

MY: Expected Adjusted Median or Generalized Mean

Description

Computes expected measures of the response variable under a linear, logistic or Poisson regression fitted model with transformed variables. Measures can be reported in both the original and the transformed space. The function automatically provides the name of the measure depending on the fitted model.

Usage

MY(
  object,
  x = NULL,
  npoints = 10,
  space = c("original", "transformed"),
  level = 0.95
)

# S3 method for MY print(x, ...)

Value

A list with class "MY" including the following items:

M

adjusted measure of the response variable. See Details below.

ymeasure

the type of measure for M.

ypow

numeric power transformation assumed in the response variable. See tlm.

xpow

numeric power transformation assumed in the explanatory variable of interest. See tlm.

Arguments

object

object of class tlm, a result of a call to tlm.

x

For MY, a number or a numeric vector containing the values of the explanatory variable of interest for which the expected measure of the response variable are required. Default is NULL. For print.MY, an object of class "MY" (an output of the MY function).

npoints

numeric. If x is NULL, the number of points where the measure should be measured. Default is 10. See Details below.

space

character. If "original" (default), the measure is reported in the original space of the variables. If "transformed", the measure is reported in the transformed space of the variables, where the model is fitted.

level

numeric. The confidence level for measures. Default is 0.95.

...

additional arguments for print.MY.

Details

In order to compute adjusted measures, all explanatory variables in the model different than the explanatory variable of interest are set at their means.

If space is "original", then the mean (for Poisson response) or the probability (for binary response) is computed. For gaussian response, the mean is computed if the response variable is not transformed; otherwise, the geometric mean (for log transformation in the response) or the median (for power transformation) is computed.

If space is "transformed", then the mean (for Poisson response or transformed gaussian response), or the logodds (for binary response) is computed.

If x argument in MY is NULL, the measure is computed in npoints values of the explanatory variable of interest. Those values are chosen to be in arithmetic progression in the given space, inside the observed range of the explanatory variable.

References

Barrera-Gomez J, Basagana X. Models with transformed variables: interpretation and software. Epidemiology. 2015;26(2):e16-17.

See Also

tlm, effectInfo, effect.

Examples

Run this code
data(feld1)
head(feld1)

# Linear model with log-log transformation, adjusting for variable 'cat':
modcat <-  tlm(logroom ~ logmattress + cat, data = feld1, ypow = 0, xpow = 0)
summary(modcat)

# Geometric mean of the response as a function of the explanatory variable,
# adjusted for 'cat':  
MY(modcat)
MY(modcat, npoints = 3)
# computed at 1st and 3rd quartiles of the explanatory variable:
MY(modcat, x = quantile(feld1$mattress, probs = c(1, 3)/4))

# Mean of the log(response) as a function of the log explanatory variable,
# adjusted for 'cat':  
MY(modcat, space = "transformed")

Run the code above in your browser using DataLab