tlm | R Documentation |
tlm
is the main function of the package. It fits a linear,
logistic or Poisson regression model with transformed variables and creates
an object which can be subsequently used to compute adjusted measures of the
response variable (with MY
) and compute and interpret adjusted
effects of the explanatory variable of interest on the response variable (with
effect
and effectInfo
, respectively), in the natural
scale of the variables. In addition, the fitted model can be visualized with
the plot.tlm
method.
tlm(
formula,
family = gaussian,
data,
ypow = 1,
xpow = 1,
...,
y,
x,
z = "none"
)
## S3 method for class 'tlm'
print(x, ...)
## S3 method for class 'tlm'
plot(x, type = c("original", "transformed", "diagnosis"),
observed = FALSE, xname = "x", yname = "y", level = 0.95, ...)
formula |
model |
family |
the response variable |
data |
a |
ypow |
numeric. Power transformation already done in the response variable. See Details below. |
xpow |
numeric. Power transformation already done in the explanatory variable of interest. See Details below. |
... |
for |
y , z |
old arguments for back compatibility only. To be removed, see Details below. |
x |
for |
type |
For |
observed |
For |
xname , yname |
For |
level |
For |
The transformations already done in the response variable and in the
explanatory variable of interest are passed by ypow
and xpow
,
respectively, and must be numbers. Default is 1, meaning no transformation.
The value 0 corresponds to the logarithmic transformation. If family
is not gaussian
, the response variable is assumed non transformed. If
the explanatory variable of interest is categorical or takes only two different
values, the value of xpow
is assumed to be 1. If the explanatory
variable of interest takes only two different values, it is handled as a
binary variable.
Plots obtained for type = "transformed"
are intended to visually explore
the model goodness of fit and should not be reported because values of the
transformed variables are meaningless (e.g. log(cotinine) has no sense).
Old arguments y
, x
and z
, are deprecated and bugs are
no longer fixed. They will be removed in the first version posterior to 0.2.0.
Use argument formula
instead.
A list with class "tlm
" including the following items:
the fitted model in the transformed space.
the value of ypow
.
the value of xpow
.
Barrera-Gomez J, Basagana X. Models with transformed variables: interpretation and software. Epidemiology. 2015;26(2):e16-17.
MY
, effect
, formula
.
### Linear model with log-log transformation:
### effect of mattress levels on room levels, adjusting for cat:
# model fitting in the transformed space:
data(feld1)
head(feld1)
modcat <- tlm(logroom ~ logmattress + cat, data = feld1, ypow = 0, xpow = 0)
modcat
summary(modcat)
# plot of the geometric mean of the response (original space), adjusting for 'cat':
plot(modcat, xname = "Mattress levels", yname = "room levels")
# plot of the mean of the log of response (transformed space), adjusting for 'cat' and
# adding the observations:
plot(modcat, type = "transformed", xname = "mattress levels", yname = "room levels",
observed = TRUE)
# diagnosis plot:
plot(modcat, type = "diagnosis")
### effect of cat in house on room levels, adjusting for matress levels:
modcat2 <- tlm(logroom ~ cat + logmattress, data = feld1, ypow = 0)
summary(modcat2)
# plot of the geometric mean of the response (original space), adjusting
# for mattress levels:
plot(modcat2, xname = "Cat", yname = "room levels")
# plot of the mean of the log of response (transformed space), adjusting
# for mattress levels:
plot(modcat2, type = "transformed", xname = "Cat", yname = "room levels")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.