MY: Expected Adjusted Median or Generalized Mean

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/MY.R

Description

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

Usage

1
2
3
4
MY(object, x = NULL, npoints = 10, space = c("original", "transformed"),
   level = 0.95)
## S3 method for class 'MY'
print(x, ...)

Arguments

object

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

x

for MY: numeric. 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", a result of a call to MY.

npoints

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

space

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

level

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

...

further additional arguments for the print.MY method.

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 is NULL, the measure is computed in npoints values of the explanatory variable of interest. Those values are choosen to be in arithmetic progression in the given space, inside the observed range of the explanatory variable.

Value

M

adjusted measure of the response variable. See ‘Details’.

ymeasure

the type of measure for M.

space

space where measures has been computed ("original" or "transformed").

ypow

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

xpow

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

Author(s)

Barrera-Gomez J and Basagana X.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(feld1)
head(feld1)

# Linear model with log-log transformation, adjusting for variable 'cat':
modcat <- tlm(y = logroom, x = logmattress, z = 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")

tlm documentation built on May 2, 2019, 2:11 p.m.