Learn R Programming

tlm (version 0.2.0)

effect: Effects Estimate in Linear, Logistic and Poisson Regression Models with Transformed Variables

Description

Estimates the effect of a explanatory variable of interest on a response variable, under a fitted linear, logistic or Poisson regression model with transformed variables. The effect is reported in the original scale of the variables.

Usage

effect(
  object,
  x1 = NULL,
  x2 = NULL,
  c = NULL,
  q = NULL,
  r = NULL,
  npoints = NULL,
  level = 0.95,
  nboot = 999,
  seed = 4321,
  verbose = TRUE
)

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

Value

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

effect

point estimate and confidence interval for the effect size.

info

information on how to interpret the effect. Used by the function effectInfo.

Arguments

object

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

x1

numeric. The values of the explanatory variable where the effect should be computed. See Details below.

x2

numeric. The alternative values of the explanatory variable (changing from x1) for which the effect should be computed. See Details below.

c

numeric. The additive change in the explanatory variable. See Details below.

q

numeric. The multiplicative change in the explanatory variable. See Details below.

r

numeric. The percent change in the explanatory variable. See Details below.

npoints

numeric. The number of points where the effect should be computed. See Details below.

level

numeric. Confidence level for the effect estimate. Default is 0.95.

nboot

numeric. The number of non parametric bootstrap samples to compute confidence intervals. Default is 999. See Details below.

seed

numeric. A single value, the seed for bootstrapping. Default is 4321.

verbose

logical. Whether to print detailed progress on R prompt. Default is TRUE.

x

for print.effect, an object of class "effect" (an output of the effect function).

...

additional arguments for print.effect.

Details

In order to compute the effect, both the initial and the final values of the explanatory should be provided. It can be done in several ways. For instance, providing, x1 and x2; x1 and one of c, q or r; x1, npoints and one of c, q or r. Only one of the arguments c, q or r is used, prevailing c and then q. If no enough arguments are passed, the interquartile range will be considered and a summary effect is computed, if it exists.

Confidence intervals are computed by transforming the endpoints of the intervals in the transformed scale when it is possible, while non-parametric bootstrap is used otherwise.

References

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

See Also

tlm, effectInfo, MY.

Examples

Run this code
### Linear model with log transformation in the response variable:
data(imt)
head(imt)

# model fitting:
modimt <- tlm(logimt ~ age, data = imt, ypow = 0)
modimt

# information on interpreting the effect:
effectInfo(modimt)

# the function effect provides as default the expected change in IMT
# for an additive change in age equal to the interquartile range:
effect(modimt)

# other effects:
(minage <- min(imt$age))
(maxage <- max(imt$age))
effect(modimt, c = maxage - minage)

if (FALSE) {
 effect(modimt, x1 = minage, r = 50, npoints = 3)}

Run the code above in your browser using DataLab