Title: | Tukeys Trend Test via Multiple Marginal Models |
---|---|
Description: | Provides wrapper functions to the multiple marginal model function mmm() of package 'multcomp' to implement the trend test of Tukey, Ciminera and Heyse (1985) <DOI:10.2307/2530666> for general parametric models. |
Authors: | Frank Schaarschmidt [aut, cre], Christian Ritz [aut], Ludwig Hothorn [ctb] |
Maintainer: | Frank Schaarschmidt <[email protected]> |
License: | GPL-2 |
Version: | 0.7 |
Built: | 2024-12-11 07:17:34 UTC |
Source: | CRAN |
Transfers output of functions tukeytrendfit and tukeytrendformula to glht.
asglht(object, df = "mean", ...)
asglht(object, df = "mean", ...)
object |
an object of class 'tukeytrend' as results from functions |
df |
defines whether and how/which degrees of freedom are passed to |
... |
further arguments to be passed to |
Passes the elements $mmm
from tukeytrend output to glht
, argument model
, and $mlf
to argument linfct
, computes summary statistics for the vector of degrees of freedom in tukeytrend and passes it to glht
, argument df
. All other arguments are passed via ...
to glht
; be aware that mis-spelled arguments may be lost in glht
.
An object of class glht
.
data(litter, package="multcomp") dl <- litter dl$dosen <- as.numeric(as.character(dl$dose)) fit <- lm(weight ~ dosen + number, data=dl) ttlitter <- tukeytrendfit(fit, dose="dosen", scaling=c("ari", "ord", "log")) # instead of transferring individual elements from the # tukeytrend output into the arguments of glht , ... # comp1 <- glht(model=ttlitter$mmm, linfct=ttlitter$mlf, # df=round(mean(ttlitter$df)), alternative="less") # summary(comp1) # ... you can just use: comp2 <- asglht(ttlitter, alternative="less") summary(comp2)
data(litter, package="multcomp") dl <- litter dl$dosen <- as.numeric(as.character(dl$dose)) fit <- lm(weight ~ dosen + number, data=dl) ttlitter <- tukeytrendfit(fit, dose="dosen", scaling=c("ari", "ord", "log")) # instead of transferring individual elements from the # tukeytrend output into the arguments of glht , ... # comp1 <- glht(model=ttlitter$mmm, linfct=ttlitter$mlf, # df=round(mean(ttlitter$df)), alternative="less") # summary(comp1) # ... you can just use: comp2 <- asglht(ttlitter, alternative="less") summary(comp2)
Concatenate several objects of class 'tukeytrend', for example to perform inference for multiple marginal models with different endpoints or including different covariates.
combtt(...)
combtt(...)
... |
names of tukeytrend objects (for multiple endpoinst, or with different covariates), separated by comma |
Same structure as output of tuketrendfit, see tukeytrendfit
, tukeytrendformula
# Simulated data for normal and binomial response dat <- data.frame(y = rnorm(20,0,1), succ=rbinom(n=20, size=10, prob=0.3), dose=rep(c(0,1,2,5,10), each=4)) # linear models with 3 different # scalings of the dose variable fitn <- lm(y~dose, data=dat) ttn <- tukeytrendfit(fitn, dose="dose", scaling=c("ari", "ord", "arilog")) # generalized linear models with 3 # different scalings of the dose variable fitb <- glm(cbind(succ, 10-succ)~dose, data=dat, family=binomial) ttb <- tukeytrendfit(fitb, dose="dose", scaling=c("ari", "ord", "arilog")) # concatenate the normal and binomial models ttnb <- combtt(ttn, ttb) # joint inference for the 6 regression slopes summary(asglht(ttnb))
# Simulated data for normal and binomial response dat <- data.frame(y = rnorm(20,0,1), succ=rbinom(n=20, size=10, prob=0.3), dose=rep(c(0,1,2,5,10), each=4)) # linear models with 3 different # scalings of the dose variable fitn <- lm(y~dose, data=dat) ttn <- tukeytrendfit(fitn, dose="dose", scaling=c("ari", "ord", "arilog")) # generalized linear models with 3 # different scalings of the dose variable fitb <- glm(cbind(succ, 10-succ)~dose, data=dat, family=binomial) ttb <- tukeytrendfit(fitb, dose="dose", scaling=c("ari", "ord", "arilog")) # concatenate the normal and binomial models ttnb <- combtt(ttn, ttb) # joint inference for the 6 regression slopes summary(asglht(ttnb))
Add rescaled dose variables to a data.frame.
dosescalett(data, dose, scaling = c("ari", "ord", "log", "arilog"), sep = "", d0shift = 1)
dosescalett(data, dose, scaling = c("ari", "ord", "log", "arilog"), sep = "", d0shift = 1)
data |
a data.frame |
dose |
a single charcater string, naming the (numeric) variable in |
scaling |
A vector of character strings, naming the options for rescaling the variable specified in |
sep |
an optional separator for the names of the rescaled variables |
d0shift |
an optional factor, that is multiplied with the interpolated dose score for |
A list containing
data |
the input data.frame, with rescaled variables added as colummns |
transnam |
a vector of names of the re-scaled variables |
scaling |
the scaling options, as input |
Coerce fitted mixed effect models of class lmerMod or lme to an lm-like object using a pseudo data approach (Ritz et al., 2017)
lmer2lm(lmerFit)
lmer2lm(lmerFit)
lmerFit |
a fitted object of class |
The returned object resembles a fitted model of class "lm" such that its asymptotic representation corresponds to that of the originally fitted mixed model, see Ritz et al. (2017) for details.
Christian Ritz
Christian Ritz, Rikke Pilmann Laursen and Camilla Trab Damsgaard (2017): Simultaneous inference for multilevel linear mixed models - with an application to a large-scale school meal study: Appl. Statist. 66, Part 2, pp. 295-311.
Wrapper function to re-fit a given model after different rescalings of a single dose variable. The refitted models are combined into a list that is suitable as input to the multiple marginal model function of package multcomp, mmm.
tukeytrendfit(fit, dose, scaling = c("ari", "ord", "log", "arilog", "highvslow", "treat"), ctype = NULL, ddf = c("residual", "KR", "PB"), d0shift = 1)
tukeytrendfit(fit, dose, scaling = c("ari", "ord", "log", "arilog", "highvslow", "treat"), ctype = NULL, ddf = c("residual", "KR", "PB"), d0shift = 1)
fit |
A fitted model object, currently, the classes |
dose |
A single character string, naming a numeric variable in the models formula. This variable is rescaled acc. to the options in |
scaling |
A vector of character strings, naming the options for rescaling the variable specified in |
ctype |
optional character string naming a contrast type for multiple comparisons between dose levels, when |
ddf |
single character string, defining the option for the degree of freedom in inference after model fitting. By default, |
d0shift |
an optional factor, that is multiplied with the interpolated dose score for |
A list with elements
mmm |
a list of fitted models, after rescaling the |
mlf |
a list of matrices defining a linear functions of model parameters for each model in |
df |
a vector of degrees of freedom, one for each model in |
and information of the model typ and call of the initial model
Frank Schaarschmidt and Christian Ritz (providing internal functions to interface objects of class "lmerMod"
and "lme"
)
Tukey JW, Ciminera JL, Heyse JF (1985). Testing the statistical certainty of a response to increasing doses of a drug. Biometrics 41(1), 295-301.
Pipper CB, Ritz C, Bisgaard H (2012). A versatile methode for confirmatory evaluation of the effects of a covariate in multiple models. JRSSC - Applied Statistics 61, 315-326.
Functions glht
and mmm
in package multcomp
;
tukeytrendformula
for starting with a model formula and data.frame;
combtt
for concatenating several objects resulting from this function, e.g. for multiple endpoints or with different covariates;
asglht
for direct conversion to a glht-object
data(litter, package="multcomp") # variable of interest is 'dose', but # we may want to include 'number' as a covariate dl <- litter dl$dosen <- as.numeric(as.character(dl$dose)) fit <- lm(weight ~ dosen + number, data=dl) # as it is unclear on which scale of dosage, # dose-response-shape is met best, we may try different # re-scalings of the dose variable, including Dunnett- type multiple contrast test ttlitter <- tukeytrendfit(fit, dose="dosen", scaling=c("ari", "ord", "log", "treat"), ctype="Dunnett") summary(asglht(ttlitter))
data(litter, package="multcomp") # variable of interest is 'dose', but # we may want to include 'number' as a covariate dl <- litter dl$dosen <- as.numeric(as.character(dl$dose)) fit <- lm(weight ~ dosen + number, data=dl) # as it is unclear on which scale of dosage, # dose-response-shape is met best, we may try different # re-scalings of the dose variable, including Dunnett- type multiple contrast test ttlitter <- tukeytrendfit(fit, dose="dosen", scaling=c("ari", "ord", "log", "treat"), ctype="Dunnett") summary(asglht(ttlitter))
Wrapper function to fit a given model after different rescalings of a single dose variable. The fitted models are combined into a list that is suitable as input to the multiple marginal model function of package multcomp, mmm.
tukeytrendformula(formula, data, model = "lm", dose, scaling = c("ari", "ord", "log", "arilog", "treat", "treatHL"), ctype = NULL, ddf = c("residual", "KR", "PB"), d0shift = 1, ...)
tukeytrendformula(formula, data, model = "lm", dose, scaling = c("ari", "ord", "log", "arilog", "treat", "treatHL"), ctype = NULL, ddf = c("residual", "KR", "PB"), d0shift = 1, ...)
formula |
formula object suitable for the model function specified in |
data |
data.frame containing the variables of interest |
model |
character string, naming the function for model fitting, currently |
dose |
A single character string, naming a numeric variable in the models formula. This variable is rescaled acc. to the options in |
scaling |
A vector of character strings, naming the options for rescaling the variable specified in |
ctype |
optional character string naming a contrast type for multiple comparisons between dose levels, when |
ddf |
single character string, defining the option for the degree of freedom in inference after model fitting. By default, |
d0shift |
an optional factor, that is multiplied with the interpolated dose score for |
... |
arguments passed to the model fitting function named in |
A list with elements
mmm |
a list of fitted models, after rescaling the |
mlf |
a list of matrices defining a linear functions of model parameters for each model in |
df |
a vector of degrees of freedom, one for each model in |
and information of the model type and call of the initial model
Frank Schaarschmidt and Christian Ritz (providing internal functions to interface objects of class "lmerMod"
and "lme"
)
Tukey JW, Ciminera JL, Heyse JF (1985). Testing the statistical certainty of a response to increasing doses of a drug. Biometrics 41(1), 295-301.
Pipper CB, Ritz C, Bisgaard H (2012). A versatile methode for confirmatory evaluation of the effects of a covariate in multiple models. JRSSC - Applied Statistics 61, 315-326.
data(litter, package="multcomp") # compare dl <- litter dl$dosen <- as.numeric(as.character(dl$dose)) ttlitter <- tukeytrendformula(weight ~ dosen + number, data=dl, model="lm", dose="dosen", scaling=c("ari", "ord", "log", "treat"), ctype="Dunnett") summary(asglht(ttlitter))
data(litter, package="multcomp") # compare dl <- litter dl$dosen <- as.numeric(as.character(dl$dose)) ttlitter <- tukeytrendformula(weight ~ dosen + number, data=dl, model="lm", dose="dosen", scaling=c("ari", "ord", "log", "treat"), ctype="Dunnett") summary(asglht(ttlitter))