Type: | Package |
Title: | Ratios of Coefficients in the General Linear Model |
Version: | 1.4.4 |
Date: | 2025-01-08 |
Author: | Gemechis Djira [aut], Mario Hasler [aut], Daniel Gerhard [aut], Lawrence Segbehoe [aut], Frank Schaarschmidt [aut, cre] |
Maintainer: | Frank Schaarschmidt <schaarschmidt@biostat.uni-hannover.de> |
Depends: | R (≥ 2.12.0) |
Suggests: | nlme |
Imports: | mvtnorm, multcomp, survival, survPresmooth, stats |
Description: | Performs (simultaneous) inferences for ratios of linear combinations of coefficients in the general linear model, linear mixed model, and for quantiles in a one-way layout. Multiple comparisons and simultaneous confidence interval estimations can be performed for ratios of treatment means in the normal one-way layout with homogeneous and heterogeneous treatment variances, according to Dilba et al. (2007) https://cran.r-project.org/doc/Rnews/Rnews_2007-1.pdf and Hasler and Hothorn (2008) <doi:10.1002/bimj.200710466>. Confidence interval estimations for ratios of linear combinations of linear model parameters like in (multiple) slope ratio and parallel line assays can be carried out. Moreover, it is possible to calculate the sample sizes required in comparisons with a control based on relative margins. For the simple two-sample problem, functions for a t-test for ratio-formatted hypotheses and the corresponding confidence interval are provided assuming homogeneous or heterogeneous group variances. |
License: | GPL-2 |
RoxygenNote: | 7.3.1 |
NeedsCompilation: | no |
Packaged: | 2025-01-09 10:16:37 UTC; Schaarschmidt |
Repository: | CRAN |
Date/Publication: | 2025-01-10 16:10:01 UTC |
mratios
Description
With this package, it is possible to perform (simultaneous) inferences for ratios of linear combinations of coefficients in the general linear model. In particular, tests and confidence interval estimations for ratios of treatment means in the normal one-way layout and confidence interval estimations like in (multiple) slope ratio and parallel line assays can be carried out. Moreover, it is possible to calculate the sample sizes required in comparisons with a control based on relative margins. For the simple two-sample problem, functions for a t-test for ratio-formatted hypotheses and Fieller confidence intervals are provided assuming homogeneous or heterogeneous group variances.
Author(s)
Gemechis Dilba Djira, Mario Hasler, Daniel Gerhard, Frank Schaarschmidt
Maintainer: Frank Schaarschmidt <schaarschmidt@biostat.uni-hannover.de>
References
Dilba, G., Bretz, F., and Guiard, V. (2006). Simultaneous confidence sets and confidence intervals for multiple ratios. Journal of Statistical Planning and Inference 136, 2640-2658.
Dilba, G., Bretz, F., Hothorn, L.A., and Guiard, V. (2006). Power and sample size computations in simultaneous tests for non-inferiority based on relative margins. Statistics in Medicine 25, 1131-1147.
Dilba, G., Guiard, V., and Bretz, F. On the efficiency of ratio formatted hypotheses (submitted).
Kieser, M. and Hauschke, D. (2000). Statistical methods for demonstrating equivalence in crossover trials based on the ratio of two location parameters. Drug Information Journal 34, 563-568.
Tamhane, A.C. and Logan, B.R. (2004). Finding the maximum safe dose level for heteroscedastic data. Journal of Biopharmaceutical Statistics 14, 843-856.
Hasler, M. and Hothorn, L.A. (2008). Multiple contrast tests in the presence of heteroscedasticity. Biometrical Journal 50, 793-800.
See Also
Multiple comparisons for differences of means: multcomp
Examples
library(mratios)
############################################################
# # # ttestratio:
# Two-sample test and confidence interval
# for comparison of means, allowing for heteroscedasticity
data(ASAT)
ASAT
ttestratio(ASAT~group, data=ASAT, alternative="less", base=1,
rho=1.25, var.equal=TRUE)
data(Mutagenicity)
boxplot(MN~Treatment, data=Mutagenicity)
# It seems to be inappropriate to assume homogeneous variances:
# 1) comparing whether the active control is more effective
# than vehicle control
ttestratio(MN~Treatment,
data=subset(Mutagenicity, Treatment=="Cyclo25"|Treatment=="Vehicle"),
alternative="greater", rho=1, var.equal=FALSE)
# 2) lowest dose vs. vehicle control
ttestratio(MN~Treatment,
data=subset(Mutagenicity, Treatment=="Hydro30"|Treatment=="Vehicle"),
alternative="greater", rho=1, var.equal=FALSE)
#########################################################
# # # sci.ratio:
# Calculation of simultaneous confidence intervals for ratios
# of linear combinations of treatment means in a one-way ANOVA model
data(BW)
boxplot(Weight~Dose, data=BW)
# Body weights of a 90-day chronic toxicology study on rats
# with a control (1) and three dose groups (2,3,4).
# Calculate upper confidence limits for the ratio of means
# of the three dose groups vs. the control group:
# Which of the doses lead to not more than 90 percent weight loss
# compared to the control group:
m21 <- sci.ratio(Weight~Dose, data=BW, type="Dunnett",
alternative="greater")
summary(m21)
plot(m21, rho0=0.9)
###########################################################
# # # simtest.ratio: Simultaneous tests for ratios of means
## Not run:
data(AP)
boxplot(prepost~treatment, data=AP)
# Test whether the differences of doses 50, 100, 150 vs. Placebo
# are non-inferior to the difference Active Control vs. Placebo
NC <- rbind(
"(D100-D0)" = c(0,-1,1,0,0),
"(D150-D0)" = c(0,-1,0,1,0),
"(D50-D0)" = c(0,-1,0,0,1))
DC <- rbind(
"(AC-D0)" = c(1,-1,0,0,0),
"(AC-D0)" = c(1,-1,0,0,0),
"(AC-D0)" = c(1,-1,0,0,0))
NC
DC
stAP <- simtest.ratio(prepost ~ treatment, data=AP,
Num.Contrast=NC, Den.Contrast=DC, Margin.vec=c(0.9,0.9,0.9))
summary(stAP)
## End(Not run)
#####################################################################
# # # sci.ratio.gen:
# Simultaneous confidence intervals for ratios of coefficients
# in the general linear model:
# Slope-ratio assay, data from Jensen(1989), Biometrical Journal 31,
# 841-853.
data(SRAssay)
SRAssay
# In this problem, the interest is in simultaneous estimation
# of the ratios of slopes relative to the slope of the standard
# treatment.
# First it is needed to carefully define the vector of responses
# and the design matrix of th general linear model:
# The design matrix can be constructed using model.matrix,
# and the vector of the response variable can be extracted
# from the dataframe.
X <- model.matrix(Response~Treatment:Dose, data=SRAssay)
Response <- SRAssay[,"Response"]
# The response vector and the design matrix are:
X
Response
# The following coefficients result:
lm(Response~0+X)
# where the last four coefficients are the estimated slopes
# of the control treatment and the three new treatments
# Contrasts for the ratios of the slopes of the three new treatments
# vs. the control are then defined as:
Num.Contrast <- matrix(c(0,0,1,0,0,
0,0,0,1,0,
0,0,0,0,1),nrow=3,byrow=TRUE)
Den.Contrast <- matrix(c(0,1,0,0,0,
0,1,0,0,0,
0,1,0,0,0),nrow=3,byrow=TRUE)
summary(sci.ratio.gen(Y=Response, X=X,
Num.Contrast=Num.Contrast, Den.Contrast=Den.Contrast))
########################################################################
# # # n.ratio: Sample size computations in comparisons with a
# control based on relative margins.
#
# Example 1: Sample size calculation in tests for non-inferiority
# (two-sample case)(Laster and Johnson (2003),
# Statistics in Medicine 22:187-200)
n.ratio(m=1, rho=0.8, Power=0.8, CV0=0.75, rho.star=1,
alpha=0.05)
#
# Example 2: Sample size calculation in simultaneous tests for
# non-inferiority
# (Dilba et al. (2006), Statistics in Medicine 25: 1131-1147)
n.ratio(m=3, rho=0.7, Power=0.8, CV0=0.5, rho.star=0.95,
alpha=0.05)
Angina pectoris data
Description
A data set is generated (from normal distribution) to imitate the summary statistics in Table II of Bauer et al. (1998). In the experiment, patients with chronic stable angina pectoris were randomized to five treatment arms (placebo, three doses of a new compound, and an active control). The primary endpoint is the difference in the duration of an exercise test before and after treatment.
Usage
data(AP)
Format
A data frame with 303 observations on the following 2 variables.
- prepost
a numeric vector, the difference post treatment measurement minus pre treatment measurement
- treatment
a factor with levels AC (the active control), D0 (the zero dose, placebo), and D50, D100, D150, the three dose groups of the new compound.
Source
Bauer, P., Roehmel, J., Maurer, W., and Hothorn, L. (1998). Testing strategies in multi-dose experiments including active control. Statistics in Medicine 17, 2133-2146.
Examples
library(mratios)
data(AP)
str(AP)
boxplot(prepost ~ treatment, data=AP)
by(AP,AP$treatment, function(x){mean(x$prepost)})
by(AP,AP$treatment, function(x){sd(x$prepost)})
ASAT data
Description
Data from a toxicity study: ASAT values of the serum of female Wistar rats six months after application
Usage
data(ASAT)
Format
A data frame with 34 observations on the following 2 variables.
- group
a factor with two levels KON, and TREAT, where KON is the control group consisting of 19 subjects and TREAT is the treatment group consisting of only 15 subjects due to mortality
- ASAT
a numeric vector containing values of the response variable
Details
The objective is to test that ASAT values of treatment group are not relevantly heightened compared to the control group, where average ASAT value which is more than 25 percent higher than the average of the control group is defined as relevant.
Source
Hauschke, D. (1999). Biometrische Methoden zur Auswertung und Planung von Sicherheitsstudien. Habilitationsschrift, Fachbereich Statistik, Universtaet Dortmund.
Examples
library(mratios)
data(ASAT)
str(ASAT)
boxplot(ASAT~group, data=ASAT)
Body weights measured in a toxicological study
Description
Body weights of a 90-day chronic toxicological study on rats with a control and three dose groups.
Usage
data(BW)
Format
A data frame with 60 observations on the following 2 variables.
- Weight
a numeric vector containing the bodyweights of rats
- Dose
a factor with levels 1, 2, 3, 4, specifying the dose groups, where 1 is the control group
Source
Hothorn, L.A. (2004): Statistische Auswerteverfahren. In: Regulatorische Toxikologie (Reichl, F.X., ed.). Springer Verlag Heidelberg, pp. 167-181.
Examples
library(mratios)
data(BW)
str(BW)
boxplot(Weight~Dose, data=BW)
Serum albumin of diabetic mice
Description
The amounts of nitrogen-bound bovine serum albumen produced by three groups of diabetic mice
Usage
data("DiabeticMice")
Format
A data frame with 57 observations on the following 2 variables.
group
a factor with levels
alloxan
insulin
normal
response
Amounts of nitrogen-bound bovine serum albumen produced by the mice
Details
The 57 observations of the amounts of nitrogen-bound bovine serum albumen produced by three groups of diabetic mice, these being normal, alloxan diabetic and alloxan diabetic treated with insulin.
Source
Hand, D. J., Daly, F., McConway, K., Lunn, D. and Ostrowski, E. (1994). A Handbook of Small Data Sets. Chapman & Hall/CRC, London.
Examples
data(DiabeticMice)
str(DiabeticMice)
boxplot(response~group, data = DiabeticMice)
y <- DiabeticMice$response
f <- DiabeticMice$group
mcpqdci(y, f)
mcpqrci(y, f)
Mutagenicity assay
Description
Mutagenicity assay for 4 doses of a compound (hydroquinone) against a negative (vehicle) control and a positive (active) control (cyclophosphamide). Hydroquinone was applied in doses of 30, 50, 70, 100 mg/kg, positive control was applied with 25mg/kg. Counts of micronuclei in polychromatic erythrocytes after 24h are taken as a measure for the potency to induce chromosome damage. Data of male mice are presented (Hauschke et al., 2005).
Usage
data(Mutagenicity)
Format
A data frame with 31 observations on the following 2 variables.
- Treatment
a factor with levels Cyclo25, Hydro100, Hydro30, Hydro50, Hydro75, Vehicle
- MN
a numeric vector, giving the counts of micronuclei after 24h
Source
Adler, ID, and Kliesch, U (1990). Comparison of single and multiple treatment regiments in the mouse bone marrow micronucleus assay for hydroquinone and cyclophosphamide. Mutation Research 234, 115-123.
References
Hauschke, D, Slacik-Erben, R, Hansen, S, Kaufmann,R (2005). Biostatistical Assessment of mutagenicity studies by including the positive control. Biometrical Journal 47, 82-87.
Examples
data(Mutagenicity)
str(Mutagenicity)
boxplot(MN~Treatment, data=Mutagenicity)
Comparing 6 strains with respect to production of antibiotics
Description
The production of antibiotics of 6 strains (mutants of the same micro organism) was compared. MO were put to holes in agar infected with Bacteria. The diameter of Baceria-free areas around the colonies of the MO was recorded. Each strain was repeated 8 times.
Usage
data(Penicillin)
Format
A data frame with 48 observations on the following 2 variables.
- strain
a numeric veactor, the number identifying the strains
- diameter
a numeric vector, size of the diameter of Bacteria-free area around each colony
Source
Horn, M, Vollandt, R (1995). Multiple Tests und Auswahlverfahren in Biomtrie (Lorenz, RJ, Vollmar, J, eds). Gustav Fischerverlag, Stuttgart Jena New York.
Examples
library(mratios)
data(Penicillin)
str(Penicillin)
boxplot(diameter ~ strain, data=Penicillin)
Slope ratio assay of panthotenic acid contents in plant tissues
Description
Content of panthotenic acid in a standard and three unknown samples were measured. The response variable is the titer of a sample to pH 6.8.
Usage
data(SRAssay)
Format
A data frame with 34 observations on the following 3 variables.
- Response
a numeric vector, containing the response variable (titer to pH 6.8)
- Treatment
a factor with levels St, U1, U2 and U3, specifying the standard and 3 unknown samples, respectively
- Dose
a numeric vector
Source
Jensen, D.R. (1989). Joint confidence sets in multiple dilution assays. Biometrical Journal 31, 841-853.
References
Data originally from Bliss, C.I. (1952). The Statistics of Bioassay. Academic Press, New York.
Examples
library(mratios)
data(SRAssay)
str(SRAssay)
plot(Response~Dose, data=SRAssay)
# library(lattice)
# xyplot(Response~Dose|Treatment, data=SRAssay)
# see ?sci.ratio.gen for the analysis of this dataset
The angina data set
Description
Dose response study of a drug to treat Angina pectoris. Response variable was the duration of pain-free walking after treatment, relative to the values before treatment. Large values indicate positive effects on patients. Data set taken from Westfall et al. (1999), p. 164.
Usage
data(angina)
Format
A data frame with 50 observations on the following 2 variables.
- dose
a factor with levels 0, 1, 2, 3, 4
- response
a numeric vector giving the change from pretreatment as measured in minutes of pain-free walking.
Details
See Westfall et al. (1999, p. 164)
Source
P. H. Westfall, R. D. Tobias, D. Rom, R. D. Wolfinger, Y. Hochberg (1999). Multiple Comparisons and Multiple Tests Using the SAS System. Cary, NC: SAS Institute Inc.
References
angina(multcomp)
Examples
library(mratios)
data(angina)
str(angina)
plot(response~dose, data=angina)
Boron neutron capture therapy (BNCT)
Description
Death times (in days) from a study to determine the efficacy of BNCT in treating therapeutically refractory F98 glioma.
Usage
data("bnct")
Format
A data frame with 30 observations on the following 3 variables.
trt
a numeric vector: Treatment (1=untreated, 2=radiated, 3=radiated + BPA)
time
a numeric vector: Death time or on-study time, days
death
a numeric vector: Death indicator (1=dead, 0=alive)
Details
A right censored data from a study performed to determine the efficacy of boron neutron capture therapy (BNCT) in treating the therapeutically refractory F98 glioma, using boronophenylalanine (BPA) as the capture agent. F98 glioma cells were implanted into the brains of rats. Three groups of rats each with 10 rats were studied. One group went untreated, another was treated only with radiation, and the third group received radiation plus an appropriate concentration of BPA.
Source
Klein and Moeschberger (2006). Survival Analysis: Techniques for Censored and truncated data, 2nd edition. Springer, New York.
Examples
data(bnct)
str(bnct)
with(bnct, mcpqdci(y = time, f = trt, event = death, TRUE))
with(bnct, mcpqrci(y = time, f = trt, event = death, TRUE))
Creates numerator and denominator contrast matrices for ratio-based hypotheses for common multiple comparison and trend test problems
Description
Creates numerator and denominator contrast matrices for some common multiple comparison and trend test problems. These matrices are internally used by the sci.ratio and simtest.ratio functions. The contrMatRatio function is a modification of the function contrMat (multcomp).
Whether the given definitions of contrast matrices for trend test problems in terms of ratios make sense and how they are to be interpreted is to be discussed.
Usage
contrMatRatio(n, type = c("Tukey", "Dunnett", "Sequen",
"AVE", "GrandMean", "Changepoint", "Marcus", "McDermott",
"Williams", "UmbrellaWilliams"), base = 1)
Arguments
n |
integer vector of sample sizes |
type |
the type of multiple contrasts
|
base |
a single integer specifying the control (i.e. denominator) group for "Dunnett"-type contrasts for calculating the ratios to the control |
Details
This is a simple adaption of the contrMat function in the package multcomp for ratio hypotheses.
Value
A list containing:
numC |
the (named) numerator contrast where rows correspond to contrasts |
denC |
the (named) denominator contrast where rows correspond to contrasts |
rnames |
a character vector with names of the contrasts |
and the type of contrast as attr.
Author(s)
Frank Schaarschmidt and Daniel Gerhard by modifying the code of contrMat(multcomp)
See Also
contrMat(multcomp)
Examples
library(mratios)
n=c(A=10,B=20,Z=10,D=10)
contrMatRatio(n=n, type="Dunnett", base=1)
contrMatRatio(n=n, type="Dunnett", base=3)
contrMatRatio(n=n, type="Tukey")
contrMatRatio(n=n, type="Sequen")
contrMatRatio(n=n, type="AVE")
contrMatRatio(n=n, type="GrandMean")
contrMatRatio(n=n, type="Williams")
contrMatRatio(n=n, type="UmbrellaWilliams")
Simultaneous confidence intervals for ratios of linear combinations of parameters.
Description
This function calculates simultaneous confidence intervals for ratios of user-defined linear combinations, given a vector parameter estiamtes and a corresponding variance-covariance matrix. Beside unadjusted intervals, multiplicity adjustments are available using quantiles of a multivariate Normal- or t-distribution. The function provides a more general, but less user-friendly function to calculate ratios of mean parameters from linear (mixed models).
Usage
gsci.ratio(est, vcmat, Num.Contrast, Den.Contrast,
degfree = NULL, conf.level = 0.95, alternative = "two.sided",
adjusted = TRUE)
Arguments
est |
A numeric vector of parameter estimates, for example coefficients of a linear model |
vcmat |
The corresponding variance-covariance matrix (Number of rows and columns should be the same as the length of the parameter vector) |
Num.Contrast |
Numerator contrast matrix, where the number of columns must be the same as the length of the parameter vector, and each row represents one contrast |
Den.Contrast |
Denominator contrast matrix, where the number of columns must be the same as the length of the parameter vector, and each row represents one contrast |
degfree |
Degrees of freedom used for calculating quantiles of a (multivariate) t-distribution. If NULL, Normal approximations are used |
conf.level |
Simultaneous confidence level in case of adjusted == TRUE, and comparisonwise confidence level in case of adjusted == FALSE |
alternative |
a character string: "two.sided" for two-sided intervals, "less" for upper confidence limits, "greater" for lower confidence limits |
adjusted |
If TRUE, the simultaneous confidence level is controlled, otherwise the comparisonwise confidence level is used |
Details
Given a parameter vector and its corresponding covariance matrix from a linera model fit, approximate simultaneous confidence intervals for several ratios of linear combinations of these parameters are calculated. For simultaneous confidence intervals (adjusted=TRUE) the plug-in method is used (plugging the maximum likelihood estimates of the ratios to obtain the correlation matrix for calculating quantiles of a multivariate t or normal distribution).
Linear combinations can be defined by providing matrices for the nominator and the denominator; some pre-defined contrasts can be constructed by the function contrMatRatio. (These may be weighted for different sample sizes.)
Value
An object of class "sci.ratio" and "gsci.ratio", containing a list with elements:
estimate |
point estimates of the ratios |
CorrMat.est |
estimate of the correlation matrix |
Num.Contrast |
matrix of contrasts used for the numerator of ratios |
Den.Contrast |
matrix of contrasts used for the denominator of ratios |
conf.int |
confidence interval estimates of the ratios |
And some further elements to be passed to print and summary functions.
Author(s)
Daniel Gerhard & Frank Schaarschmidt adapting code of Gemechis Dilba Djira
References
The general methodology of constructing inference for ratios of linear model parameters can be found in:
Zerbe G.O., (1978): On Fieller's Theorem and the General Linear Model. The American Statistician 32(3), 103-105.
Young D.A., Zerbe G.O., Hay W.W. (1997): Fieller's Theorem, Scheffe's simultaneous confidence intervals, and ratios of parameters of linear and nonlinear mixed-effect models. Biometrics 53(3), 835-847.
Djira G.D.(2010): Relative Potency Estimation in Parallel-Line Assays - Method Comparison and Some Extensions. Communications in Statistics - Theory and Methods 39(7), 1180-1189.
However, when adjusted=TRUE
, the quantiles are not obtained as described in Zerbe(1978) or Young et al. (1997), but by adapting the 'plug-in' method described for the completely randomized one-way layout in
Dilba, G., Bretz, F., and Guiard, V. (2006): Simultaneous confidence sets and confidence intervals for multiple ratios. Journal of Statistical Planning and Inference 136, 2640-2658.
A simulation study of the performance of these methods in linear mixed models:
Schaarschmidt and Djira(2016): Simultaneous Confidence Intervals for Ratios of Fixed Effect Parameters in Linear Mixed Models. Communications in Statistics - Simulation and Computation 45:5, 1704-1717. DOI: 10.1080/03610918.2013.849741
See Also
glht(multcomp) for simultaneous CI of differences of means, and function sci.ratio.gen(mratios)
Examples
library(mratios)
##############################################################
# A 90-days chronic toxicity assay:
# Which of the doses (groups 2,3,4) do not show a decrease in
# bodyweight more pronounced than 90 percent of the bodyweight
# in the control group?
#############################################################
data(BW)
boxplot(Weight~Dose,data=BW)
lmfit <- lm(Weight~Dose-1, data=BW)
est <- coefficients(lmfit)
vc <- vcov(lmfit)
CMAT <- contrMatRatio(table(BW$Dose), type="Dunnett")
BWnoninf <- gsci.ratio(est, vc, CMAT$numC, CMAT$denC,
alternative="greater", degfree=lmfit$df.residual)
BWnoninf
# Plot
plot(BWnoninf, rho0=0.9)
##############################################################
#### Mixed Model Example
##############################################################
library("nlme")
data(Milk)
# Fit a linear mixed model (maybe there are nicer models available!)
lmefit <- lme(protein ~ Diet-1, data=Milk,
random=~Time|Cow, correlation=corAR1(form=~Time|Cow))
# Extract the parameter estimates and the corresponding
# variance-covariance matrix
estm <- fixef(lmefit)
vcm <- vcov(lmefit)
# Define the matrices defining the ratios of interest for
# all-pair comparisons: CM is the numerator matrix and
# DM is the denominator matrix.
CM <- rbind(c(1,0,0),
c(1,0,0),
c(0,1,0))
DM <- rbind(c(0,1,0),
c(0,0,1),
c(0,0,1))
# Add some row names (This is optional!)
rownames(CM) <- c("b/b+l", "b/l", "b+l/l")
# Calculate and plot simultaneous confidence intervals:
gscimix <- gsci.ratio(estm, vcm, CM, DM, degfree=anova(lmefit)[,2])
plot(gscimix)
Point and variance estimation for quantiles of independent groups of samples
Description
Computes the pth quantile and variances for groups of given samples in one-way anova layout. It has option for right censored data.
Usage
mcpqest(y, f, event = NULL,
Right.Censored = FALSE, p = 0.5, ...)
Arguments
y |
a numeric vector, the response variable. If Right.Censored = True, y is non-negative follow up time for right censored in survival data. |
f |
a factor variable of the same length as y, assigning the observations in y into k groups. |
event |
a binary variable indicating status for right censored data. Usually, 1 if event of interest has occurred (death = 1) and 0 otherwise (alive = 0). |
Right.Censored |
a logical expression indicating right-censored data is being used for constructing simultaneous confidence interval. |
p |
a single numeric value between 0 and 1 indicating the level of quantile for the contrasts. The default is p = 0.5 (the median). |
... |
further arguments to be passed to the internal methods, in particular: |
Details
Mainly for internal use.
Value
a list with elements:
quantileEST |
a numeric vector, the point estimates of quantiles for each factor level. |
varEST |
a numeric vector, the variance estimates for each factor level. |
n |
a numeric vector, the sample size of each factor level |
Author(s)
Lawrence S. Segbehoe, Gemechis Dilba Djira, Frank Schaarschmidt (package inclusion)
Simultaneous confidence intervals for contrasts of quantiles
Description
The following functions construct simultaneous confidence intervals for multiple constrasts of quantiles (for ratios and differences) in a one-way layout. The "mcpqrci" is for ratios and "mcpqdci" is for differences of quantiles. Both functions have also options for right censored data.
Usage
mcpqrci(y, f, event = NULL, Right.Censored = FALSE,
p = 0.5, conf.level = 0.95, type = "Dunnett",
base = 1, Num.cmat = NULL, Den.cmat = NULL,
method = c("Wald", "Fieller"), ...)
mcpqdci(y, f, event = NULL, Right.Censored = FALSE,
p = 0.5, conf.level = 0.95, type = "Dunnett",
base = 1 , cmat = NULL,...)
Arguments
y |
a numeric vector, the response variable. If |
f |
a factor variable of the same length as y, assigning the observations in y into k groups. |
event |
a binary variable indicating status for right censored data. Usually, 1 if event of interest has occurred (death = 1) and 0 otherwise (alive = 0); (optional: only if y is survival data). |
Right.Censored |
a logical expression indicating right-censored data is being used for constructing simultaneous confidence intervals, (optional: only if y is survival data). |
p |
a single numeric value between 0 and 1 indicating the level of quantile for the contrasts. The default is p = 0.5 (the median). |
conf.level |
a single numeric value between 0 and 1 indicating the level of confidence interval. |
type |
a single character string, naming a contrast type, see contrMat and contrMatRatio, for the options; this argument is ignored if a contrast matrix is specified in cmat or Num.cmat and Den.cmat. |
base |
a positive integer specifying the control group for the Dunnett contrasts, ignored otherwise. When base is not given the first group in terms of an alphanumeric order is taken as the control group. |
cmat |
(optional) a matrix with numeric entries, containing contrast coefficients defining differences of quantiles in function |
Num.cmat |
(optional) Numerator contrast matrix for ratios of quantiles in function |
Den.cmat |
(optional) Denominator contrast matrix for ratios of quantiles in function |
method |
a single character string, naming the method by which to compute the confidence intervals for ratios of quantiles. Default is "Wald". Note if the calculated lower confidence limit is negative and the ratio cannot be negative, set the lower confidence limit to zero. |
... |
further arguments to be passed to the internal methods, in particular: dist must be a single character string invoking the use of multivariate normal quantiles; |
Details
The interest is to construct simultaneous confidence intervals for several contrast of quantiles in a one-way layout. An asymptotic approach is used in estimating the variance of estimated quantiles. The mcpqrci
handles ratios of multiple contrasts of quantiles and
mcpqdci
handles differences of multiple contrast of quantiles.
If event
argument is provided and Right.Censored = TRUE
, the functions computes simultaneous confidence intervals for right censored data in y.
The type argument defines the type of contrast matrix to use. Users can also define a preferred contrast matrix, cmat.
Value
a list with elements
cmat |
Matrix of contrast used for contrast differences. |
Num.Contrast |
Matrix of contrast used for the numerator of ratios. |
Den.Contrast |
Matrix of contrast used for the denominator of ratios. |
conf.level |
A numeric value, as input. |
estimate |
a column vector, containing the point estimates of the contrasts. |
std.err |
a column vector, containing the standard error of the contrast estimates. |
conf.int |
a Mx2 matrix of confidence bounds, if M comparisons among the K samples are invoked. |
Author(s)
Lawrence S. Segbehoe, Gemechis Dilba Djira, and Frank schaarschmidt (inclusion in the package)
See Also
sciratio
for simultaneous confidence intervals for ratios of linear combinations of means
Examples
data("DiabeticMice")
response <- DiabeticMice$response
group <- DiabeticMice$group
## Example 1
Num.cmat <- matrix(c(1,1,0,0,0,1,0,0,0),3)
Den.cmat <- matrix(c(0,0,0,1,0,0,0,1,1),3)
mcpqdci(y = response, f = group, cmat = (Num.cmat + -1*Den.cmat))
mcpqdci(y = response, f = group, cmat = (Num.cmat + -1*Den.cmat)[-1,])
mcpqrci(y = response, f = group, Num.cmat = Num.cmat, Den.cmat = Den.cmat )
mcpqrci(y = response, f = group, Num.cmat = Num.cmat[-1,], Den.cmat = Den.cmat[-1,] )
## Example 2
data("bnct")
mcpqrci(y = bnct$time, f = bnct$trt, event = bnct$death, Right.Censored=TRUE)
## Sampled data:
y <- c(rnorm(20),rnorm(16,3),rnorm(24,7,2))
f <- rep(paste0("group", 1:3), c(20,16, 24))
event <- rbinom(60,1,0.8)
mcpqdci(y=y, f=f, method = "Fieller", base = 3)
# mcpqrci(y=abs(y), f=f, event=event, Right.Censored=TRUE,
# Num.cmat = cbind(c(1,1), 0*diag(2)),
# Den.cmat = cbind(c(0,0), diag(2)))
cmat <- cbind(-c(1,1),diag(2))
mcpqdci(y=y, f=f, method = "Fieller", cmat = cmat)
Sample size computation in simultaneous tests for ratios of means
Description
Computes the sample sizes required in simultaneous tests for non-inferiority (or superiority) based on relative margins in multiple comparisons with a control.
Usage
n.ratio(m, rho, Power, CV0, rho.star, alpha, Min.power = TRUE)
Arguments
m |
number of comparisons with a control group |
rho |
relative non-inferiority (or superiority) margin |
Power |
given power (1-beta) |
CV0 |
coefficient of variation of the control group |
rho.star |
the percentage (of the mean of the control group) to be detected |
alpha |
familywise error rate |
Min.power |
if set to TRUE (by default), the minimal power will be controlled, otherwise complete power |
Details
The sample sizes are computed at the least favourable configurations, based on the assumption of no prior information regarding the true configuration of the ratios under the alternative hypotheses. The formula is
n = ((C_1 + C_2)^2) (1 + \rho^2)/((\rho - \rho^*)^2) CV0^2
,
where C_1
is the lower 1-\alpha
equi-coordinate percentage point of an m-variate normal distribution
and C_2
is the quantile of univariate (multivariate) normal distribution depending on the type of power
controlled. In tests for non-inferiority (or superiority) with large response values indicating better
treatment benefit, \rho < \rho^*
, where \rho < 1
for non-inferiority and \rho > 1
for superiority testing.
Whereas, if small response values indicate better treatment benefit, \rho^* < \rho
, where \rho > 1
for non-inferiority
and \rho < 1
for superiority testing.
Author(s)
Gemechis Dilba Djira
References
Dilba, G., Bretz, F., Hothorn, L.A., and Guiard, V. (2006). Power and sample size computations in simultaneous tests for non-inferiority based on relative margins. Statistics in Medicine 25, 1131-1147.
Examples
#
# Example 1: Sample size calculation in tests for non-inferiority
# (two-sample case)(Laster and Johnson (2003),
# Statistics in Medicine 22:187-200)
n.ratio(m=1, rho=0.8, Power=0.8, CV0=0.75, rho.star=1,
alpha=0.05)
#
# Example 2: Sample size calculation in simultaneous tests for
# non-inferiority
# (Dilba et al. (2006), Statistics in Medicine 25:1131-1147)
n.ratio(m=3, rho=0.7, Power=0.8, CV0=0.5, rho.star=0.95,
alpha=0.05)
#
# Example 3: Controlling complete power
#
n.ratio(m=5, rho=1.2, Power=0.8, CV0=0.2, rho.star=1.40,
alpha=0.05, Min.power=FALSE)
Plot output for sci.ratio and sci.ratio.gen
Description
Plot the intervals returned by sci.ratio
Usage
## S3 method for class 'sci.ratio'
plot(x, rho0 = 1, rho0lty=2, rho0lwd=1, rho0col="black",
CIvert = FALSE, CIlty = 1, CIlwd = 1, CIcex = 1, CIpch=16,
main = NULL, ylab = NULL, xlab = NULL, sub = NULL, length=NULL,
sortby=NULL, decreasing=NULL, ...)
Arguments
x |
an object of class "sci.ratio" as can be obtained by calling the function sci.ratio |
rho0 |
a single numeric value or vector of values defining the hypothesized ratio |
rho0lty |
integer values to specify the line type for the rho0 line(s) |
rho0lwd |
integer values to specify the line width for the rho0 line(s) |
rho0col |
character vector to specify the colour for the rho0 line(s) |
CIvert |
logical, CI are plotted horizontal if CIvert=FALSE and vertical otherwise |
CIlty |
numeric value, giving the line type of the plotted confidence interval, see argument lty in ?par |
CIlwd |
numeric value, giving the line width of the plotted confidence interval, see argument lwd in ?par |
CIcex |
a single numeric value: by which amount the symbols in the CI shall be scaled relative to the default (see argument cex in ?par) |
CIpch |
the symbol to be used for the point estimate, see pch in ?points |
main |
character string to be plotted as main title of the plot |
ylab |
character string, label of the y axis (ignored if CIvert=TRUE) |
xlab |
character string, label of the x axis (ignored if CIvert=FALSE) |
sub |
as in plot |
length |
a numeric value, specifying the length/2 of the bars at the ends of the confidence intervals in inches |
sortby |
a character string, one of "estimate", "lower, or "upper"; if specified, the results are ordered by magnitude of estimates, lower or upper limits |
decreasing |
logical, to be passed to |
... |
further arguments to be passed to |
Details
Too long names of the contrasts/comparisons should be avoided, otherwise use par() to change plot parameters.
Value
A plot of the confidence intervals in the sci.ratio object.
Author(s)
Frank Schaarschmidt
References
plot.hmtest(multcomp)
Examples
library(mratios)
data(angina)
aCI<-sci.ratio(response~dose, data=angina, type="Dunnett",
alternative="greater")
# Visualize testing for superiority
plot(aCI, rho0=1.25, rho0lty=3)
Print function for sci.ratio objects
Description
A short print out of the value of a sci.ratio object.
Usage
## S3 method for class 'sci.ratio'
print(x, digits=4,...)
Arguments
x |
an object of class "sci.ratio" as can be obtained by calling the function sci.ratio |
digits |
digits for rounding the output |
... |
arguments to be passed to print |
Value
A print out of the confidence intervals computed by sci.ratio.
See Also
plot.sci.ratio, summary.sci.ratio
Print out the results of simtest.ratio
Description
A short print out of the results of simtest.ratio
Usage
## S3 method for class 'simtest.ratio'
print(x, digits = 4, ...)
Arguments
x |
An object of class "simtest.ratio" as obtained by calling simtest.ratio |
digits |
digits for rounding of the results |
... |
arguments to be passed to print |
Value
A print out, containing the margins, estimates, teststatistics, and p.values computed by simtest.ratio.
Body weight of rats in a toxicity study
Description
Body weights of male rats were compared between a control group and a group which had received a high dose of a chemical in a toxicity study after a period of recovery
Usage
data(rat.weight)
Format
A data frame with 20 observations on the following 2 variables.
- group
a factor with two levels, Dosis and Kon, where Dosis is the high dose group, consisiting of ten individulas and Kon is the control group, consisting of ten individuals
- weight
a numeric vector containing the values of response variable, final body weight in gramm
Details
Aim was to test that application of the chemical does not lead to a relevantly lowered or heightened body weight after a time of recovery. 0.8 and 1.25 were defined as relevance boundaries compared to the mean of control group
Source
Hauschke, D. (1999). Biometrische Methoden zur Auswertung und Planung von Sicherheitsstudien. Habilitationsschrift, Fachbereich Statistik, Universtaet Dortmund.
Examples
library(mratios)
data(rat.weight)
boxplot(weight~group, data=rat.weight)
Simultaneous confidence intervals for ratios of linear combinations of means
Description
This function constructs simultaneous confidence intervals for ratios of linear combinations of normal means in a one-way ANOVA model. Different methods are available for multiplicity adjustment.
Usage
sci.ratio(formula, data, type = "Dunnett", base = 1,
method = "Plug", Num.Contrast = NULL, Den.Contrast = NULL,
alternative = "two.sided", conf.level = 0.95, names=TRUE)
Arguments
formula |
A formula specifying a numerical response and a grouping factor as e.g. response ~ treatment |
data |
A dataframe containing the response and group variable |
type |
type of contrast, with the following options:
Note: type is ignored, if Num.Contrast and Den.Contrast are specified by the user (See below). |
base |
a single integer specifying the control (i.e. denominator) group for the Dunnett contrasts, ignored otherwise |
method |
character string specifying the method to be used for confidence interval construction:
|
Num.Contrast |
Numerator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
Den.Contrast |
Denominator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
alternative |
a character string: "two.sided" for two-sided intervals, "less" for upper confidence limits, "greater" for lower confidence limits |
conf.level |
simultaneous confidence level in case of method="Plug","Bonf", or "MtI", and comparisonwise confidence level in case of method="Unadj" |
names |
logical, indicating whether rownames of the contrast matrices shall be retained in the output |
Details
Given a one-way ANOVA model, the interest is in simultaneous confidence intervals for several ratios of linear combinations of the treatment means. It is assumed that the responses are normally distributed with homogeneous variances. Unlike in multiple testing for ratios, the joint distribution of the likelihood ratio statistics has a multivariate t-distribution the correlation matrix of which depends on the unknown ratios. This means that the critical point needed for CI calculations also depends on the ratios. There are various methods of dealing with this problem (for example, see Dilba et al., 2006). The methods include (i) the unadjusted intervals (Fieller confidence intervals without multiplicity adjustments), (ii) Bonferroni (Fieller intervals with simple Bonferroni adjustments), (iii) MtI (a method based on Sidak and Slepian inequalities for two- and one-sided confidence intervals, respectively), and (iv) plug-in (plugging the maximum likelihood estimates of the ratios in the unknown correlation matrix). The latter method is known to have good simultaneous coverage probabilities. The MtI method consists of replacing the unknown correlation matrix of the multivariate t by an identity matrix of the same dimension.
See the examples for the usage of Numerator and Denominator contrasts. Note that the argument names Num.Contrast and Den.Contrast need to be specified. If numerator and denominator contrasts are plugged in without their argument names, they will not be recognized.
Value
An object of class "sci.ratio", containing a list with elements:
estimate |
point estimates of the ratios |
CorrMat.est |
estimate of the correlation matrix (for the plug-in approach) |
Num.Contrast |
matrix of contrasts used for the numerator of ratios |
Den.Contrast |
matrix of contrasts used for the denominator of ratios |
conf.int |
confidence interval estimates of the ratios |
And some further elements to be passed to print and summary functions.
Author(s)
Gemechis Dilba Djira
References
Dilba, G., Bretz, F., and Guiard, V. (2006): Simultaneous confidence sets and confidence intervals for multiple ratios. Journal of Statistical Planning and Inference 136, 2640-2658.
See Also
glht(multcomp) for simultaneous CI of differences of means, plot.sci.ratio for a plotting function of the intervals
Examples
# # #
# A 90-days chronic toxicity assay:
# Which of the doses (groups 2,3,4) do not show a decrease in
# bodyweight more pronounced than 90 percent of the bodyweight
# in the control group?
data(BW)
boxplot(Weight~Dose,data=BW)
BWnoninf <- sci.ratio(Weight~Dose, data=BW, type="Dunnett",
alternative="greater")
plot(BWnoninf, rho0=0.9)
## Not run:
# # #
# Antibiotic activity of 8 different strains of a micro organisms.
# (Horn and Vollandt, 1995):
data(Penicillin)
boxplot(diameter~strain, data=Penicillin)
allpairs<-sci.ratio(diameter~strain, data=Penicillin, type="Tukey")
plot(allpairs)
summary(allpairs)
## End(Not run)
Simultaneous confidence intervals for ratios of coefficients in the general linear model
Description
Constructs simultaneous confidence intervals for multiple ratios of linear combinations of coefficients in the general linear model.
Usage
sci.ratio.gen(Y, X, Num.Contrast, Den.Contrast,
alternative = "two.sided", conf.level = 0.95,
method="Plug")
Arguments
Y |
A numerical vector, containing the values of the response variable |
X |
A design matrix for the the linear model, defining the parameters to be estimated, must have same number of rows as Y |
Num.Contrast |
Numerator contrast matrix |
Den.Contrast |
Denominator contrast matrix |
alternative |
one of "two.sided", "less", or "greater" |
conf.level |
simultaneous confidence levels |
method |
character string, specifying the method for confidence interval calculation:
|
Details
Given a general linear model, the interest is in simultaneous confidence intervals for several ratios of linear combinations of the coefficients in the model. It is assumed that the responses are normally distributed with homogeneous variances. In this problem, the joint distribution of the likelihood ratio statistics has a multivariate t-distribution the correlation matrix of which depends on the unknown ratios. This means that the critical point needed for CI calculations also depends on the ratios. There are various methods of dealing with this problem (for example, see Dilba et al., 2006). The methods include (i) the unadjusted intervals (Fieller confidence intervals without multiplicity adjustments), (ii) Bonferroni (Fieller intervals with simple Bonferroni adjustments), (iii) MtI (a method based on Sidak and Slepian inequalities for two- and one-sided confidence intervals, respectively), and (iv) plug-in (plugging the maximum likelihood estimates of the ratios in the unknown correlation matrix). The MtI method consists of replacing the unknown correlation matrix by an identity matrix of the same dimension.
Applications include relative potency estimations in multiple parallel line or slope-ratio assays. Users need to define the design matrix of the linear model and the corresponding contrast matrices in an appropriate way.
Value
A list containing
estimate |
point estimates for the ratios |
CorrMat.est |
estimates of the correlation matrix (for the plug-in approach) |
Num.Contrast |
matrix of contrasts used for the numerator of ratios |
Den.Contrast |
matrix of contrasts used for the denominator of ratios |
conf.int |
confidence interval estimates of the ratios |
Y |
response vector |
X |
design matrix |
fit |
the model fit, an object of class "lm" |
and some further input arguments, to be passed to print and summary functions.
Author(s)
Gemechis Dilba Djira
References
Dilba, G., Bretz, F., and Guiard, V. (2006). Simultaneous confidence sets and confidence intervals for multiple ratios. Journal of Statistical Planning and Inference 136, 2640-2658.
See Also
glht(multcomp) for multiple comparisons of parameters from lm, glm,..., sci.ratio for confidence intervals for ratios of means in a one-way-layout, simtest.ratio for simultaneous tests for ratios of means in a one-way-layout, plot.sci.ratio for plotting the confidence intervals.
Examples
################################################
# Slope-ratio assay on data from Jensen(1989),
# Biometrical Journal 31, 841-853.
# Definition of the vector of responses and
# the design matrix can be done directly as
# follows:
Y0 <- c(1.3, 1.7, 2.4, 2.7, 3.6, 3.6, 4.7, 5.0, 6.1, 6.3)
Y1 <- c(2.8, 2.9, 4.1, 3.7, 5.5, 5.5, 6.4, 6.7)
Y2 <- c(2.2, 2.1, 3.2, 3.2, 3.8, 3.9, 4.7, 4.9)
Y3 <- c(2.3, 2.3, 3.2, 3.0, 4.2, 4.2, 4.6, 5.1)
Y <- c(Y0,Y1,Y2,Y3) # the response vector
xi <- rep(1,34)
x0 <- c(0,0, gl(4,2),rep(0,8*3))
x1 <- c(rep(0,10),gl(4,2), rep(0,8*2))
x2 <- c(rep(0,18),gl(4,2), rep(0,8))
x3 <- c(rep(0,26),gl(4,2))
X <- cbind(xi,x0,x1,x2,x3) # the design matrix
# Have a look at the response vector:
Y
# and the design matrix:
X
# Internally in sci.ratio.gen, the following model is fitted
Fiti <- lm(Y ~ X - 1)
Fiti
summary(Fiti)
# In this problem, interest is simultaneous estimation of
# the ratios of slopes relative to the slope of the standard
# treatment. Therefore, the appropriate contrast matrices are:
Num.Contrast <- matrix(c(0,0,1,0,0,
0,0,0,1,0,
0,0,0,0,1),nrow=3,byrow=TRUE)
Den.Contrast <- matrix(c(0,1,0,0,0,
0,1,0,0,0,
0,1,0,0,0),nrow=3,byrow=TRUE)
SlopeRatioCI <- sci.ratio.gen(Y=Y, X=X,
Num.Contrast=Num.Contrast, Den.Contrast=Den.Contrast)
SlopeRatioCI
# Further details of the fitted model and the contrasts used:
summary(SlopeRatioCI)
plot(SlopeRatioCI)
#########################################################
## Not run:
# If one starts with a dataframe, the function model.matrix
# can be used to create the design matrix:
data(SRAssay)
SRAssay
# Create the design matrix using model.matrix
X <- model.matrix(Response~Treatment:Dose, data=SRAssay)
Response <- SRAssay[,"Response"]
# The response vector and the design matrix are now:
X
Response
# The following coefficients result from fitting this model:
lm(Response~0+X)
# The same contrasts as above are used:
Num.Contrast <- matrix(c(0,0,1,0,0,
0,0,0,1,0,
0,0,0,0,1),nrow=3,byrow=TRUE)
Den.Contrast <- matrix(c(0,1,0,0,0,
0,1,0,0,0,
0,1,0,0,0),nrow=3,byrow=TRUE)
summary(sci.ratio.gen(Y=Response, X=X, Num.Contrast, Den.Contrast))
## End(Not run)
Approximate simultaneous confidence intervals for ratios of means when variances are heterogeneous
Description
This function constructs simultaneous confidence intervals for ratios of linear combinations of normal means in a one-way model, allowing that the variances differ among groups. Different methods are available for multiplicity adjustment.
Usage
sci.ratioVH(formula, data,
type = "Dunnett", base = 1, method = "Plug",
Num.Contrast = NULL, Den.Contrast = NULL,
alternative = "two.sided", conf.level = 0.95,
names = TRUE)
Arguments
formula |
A formula specifying a numerical response and a grouping factor as e.g. response ~ treatment |
data |
A dataframe containing the response and group variable |
type |
type of contrast, with the following options: "Dunnett" for many-to-one comparisons, with control in the denominator; "Tukey" for all-pair comparisons; "Sequen" for comparisons of consecutive groups, where the group with lower order is the denominator; "AVE" for comparison of each group with average of all others, where the average is taken as denominator; "Changepoint": ratio of averages of groups of higher order divided by averages of groups of lower order; "Marcus": Marcus contrasts as ratios; "McDermott": McDermott contrasts as ratios; "Williams": Williams contrasts as ratios. Note that type is ignored, if Num.Contrast and Den.Contrast are specified by the user |
base |
a single integer specifying the control (i.e. denominator) group for the Dunnett contrasts, ignored otherwise |
method |
a character string, specifying the method to be used for the multiplicity adjustment of the confidence intervals: "Plug": Plug-in of ratio estimates to obtain the correlation matrix of contrasts (default); "Bonf": Simple Bonferroni-adjustment of Fieller confidence intervals for the ratios; "MtI": Sidak- or Slepian- adjustment for two-sided and one-sided confidence intervals, respectively; "Unadj": Unadjusted Fieller confidence intervals for the ratios |
Num.Contrast |
Numerator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
Den.Contrast |
Denominator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
alternative |
a character string: "two.sided" for two-sided intervals; "less" for upper confidence limits: "greater" for lower confidence limits |
conf.level |
simultaneous confidence level in case of method="Plug","Bonf", or "MtI", and comparisonwise confidence level in case of method="Unadj" |
names |
logical, indicating whether rownames of the contrast matrices shall be retained in the output |
Details
Given a one-way ANOVA model, the interest is in simultaneous confidence intervals for several ratios of linear combinations of the treatment means. It is assumed that the responses are normally distributed with possibly heterogeneous variances. Multivariate t-distributions are applied with a correlation matrix depending on the unknown ratios and sample variances and degress of freedom according to Satterthwaite (1946).
Using method="Unadj" results in the methods described in Hasler, Vonk and Hothorn (2007).
Value
An object of class "sci.ratio", containing a list with elements:
estimate |
the point estimates of the ratios |
CorrMat.est |
the estimated correlation matrix |
Num.Contrast |
matrix of contrasts used for the numerator of ratios |
Den.Contrast |
matrix of contrasts used for the denominator of ratios |
conf.int |
the estimated confidence intervals |
NSD |
a logical indicating whether any denominator occured, which were not significantly difference from 0 |
and some of the input arguments.
Author(s)
Mario Hasler
References
Simultaneous confidence intervals:
Hasler, M. and Hothorn, L.A. (2008). Multiple contrast tests in the presence of heteroscedasticity. Biometrical Journal 50, 793-800.
Marginal (unadjusted) confidence intervals:
Hasler M, Vonk R, Hothorn LA (2007). Assessing non-inferiority of a new treatment in a three-arm trial in the presence of heteroscedasticity. Statistics in Medicine 27, 490-503.
Satterthwaite, FE (1946). An approximate distribution of estimates of variance components. Biometrics 2, 110-114.
See Also
plot.sci.ratio for plots of confidence intervals and simtest.ratioVH for raw and multiplicity-adjusted p-values
Examples
data(Mutagenicity, package="mratios")
boxplot(MN~Treatment, data=Mutagenicity)
# Unless it is hard to assume Gaussian distribution
# in this example this is an attempt to take
# heterogeneous variances into account.
# Comparisons to the vehicle control,
# Proof of Hazard, using multiplicity adjusted
# confidence intervals:
## Not run:
sci.ratioVH(MN~Treatment, data=Mutagenicity,
type="Dunnett", base=6, method="Plug")
# Unadjusted confidence intervals for an
# intersection union test to proof safety
# for all doses of the compound.
sci.ratioVH(MN~Treatment, data=Mutagenicity,
type="Dunnett", base=6, method="Unadj", alternative="less")
# # # #
# User-defined contrasts:
# Mutagenicity of the doses of the new compound,
# expressed as ratio (DoseX-Vehicle)/(Cyclo25-Vehicle):
# Check the order of the factor levels:
levels(Mutagenicity$Treatment)
# numerators:
NC<-rbind(
"Hydro30-Vehicle"=c(0,0,1,0,0,-1),
"Hydro50-Vehicle"=c(0,0,0,1,0,-1),
"Hydro75-Vehicle"=c(0,0,0,0,1,-1),
"Hydro100-Vehicle"=c(0,1,0,0,0,-1)
)
DC<-rbind(
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1),
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1),
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1),
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1)
)
colnames(NC)<-colnames(DC)<-levels(Mutagenicity$Treatment)
NC
DC
CIs<-sci.ratioVH(MN~Treatment, data=Mutagenicity,
Num.Contrast=NC,
Den.Contrast=DC)
# # # #
# Unadjusted confidence intervals for multiple ratios
# of means assuming heterogeneous group variances.
# The following code produces the results given in Table
# V of Hasler, Vonk and Hothorn (2007).
# The upper confidence limits in Table V can produced
# by calling:
sci.ratioVH(formula=MN~Treatment, data=Mutagenicity,
Num.Contrast=NC, Den.Contrast=DC,
method="Unadj", alternative="less", conf.level=0.95)
## End(Not run)
Simultaneous tests for ratios of normal means
Description
Performs simultaneous tests for several ratios of linear combinations of treatment means in the normal one-way ANOVA model with homogeneous variances.
Usage
simtest.ratio(formula, data, type = "Dunnett", base = 1,
alternative = "two.sided", Margin.vec = NULL, FWER = 0.05,
Num.Contrast = NULL, Den.Contrast = NULL, names = TRUE)
Arguments
formula |
A formula specifying a numerical response and a grouping factor (e.g., response ~ treatment) |
data |
A dataframe containing the response and group variable |
type |
type of contrast, with the following options:
Note: type is ignored if Num.Contrast and Den.Contrast are specified by the user (See below). |
base |
a single integer specifying the control (i.e. denominator) group for the Dunnett contrasts, ignored otherwise |
alternative |
a character string:
|
Margin.vec |
a single numerical value or vector of Margins under the null hypotheses, default is 1 |
FWER |
a single numeric value specifying the family-wise error rate to be controlled |
Num.Contrast |
Numerator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
Den.Contrast |
Denominator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
names |
a logical value: if TRUE, the output will be named according to names of user defined contrast or factor levels |
Details
Given a one-way ANOVA model, the interest is in simultaneous tests for several ratios of linear combinations of the treatment means.
Let us denote the ratios by \gamma_i, i=1,...,r
, and let \psi_i, i=1,...,r
, denote the relative margins against which we compare the ratios.
For example, upper-tail simultaneous tests for the ratios are stated as
H_0i: \gamma_i <= \psi_i
versus
H_1i: \gamma_i > \psi_i, i=1,...,r
.
The associated likelihood ratio test statistic T_i
has a t-distribution.
For multiplicity adjustments, we use the joint distribution of the T_i
, i=1,...,r
,
which under the null hypotheses follows a central r-variate t-distribution.
Adjusted p-values can be calculated by adapting the results of Westfall et al. (1999) for ratio formatted hypotheses.
Value
An object of class simtest.ratio containing:
estimate |
a (named) vector of estimated ratios |
teststat |
a (named) vector of the calculated test statistics |
Num.Contrast |
the numerator contrast matrix |
Den.Contrast |
the denominator contrast matrix |
CorrMat |
the correlation matrix of the multivariate t-distribution calculated under the null hypotheses |
critical.pt |
the equicoordinate critical value of the multi-variate t-distribution for a specified FWER |
p.value.raw |
a (named) vector of unadjusted p-values |
p.value.adj |
a (named) vector of p-values adjusted for multiplicity |
Margin.vec |
the vector of margins under the null hypotheses |
and some other input arguments.
Author(s)
Gemechis Dilba Djira
References
Dilba, G., Bretz, F., and Guiard, V. (2006). Simultaneous confidence sets and confidence intervals for multiple ratios. Journal of Statistical Planning and Inference 136, 2640-2658.
Westfall, P.H., Tobias, R.D., Rom, D., Wolfinger, R.D., and Hochberg, Y. (1999). Multiple comparisons and multiple tests using the SAS system. SAS Institute Inc. Cary, NC, 65-81.
See Also
While print.simtest.ratio produces a small default print-out of the results,
summary.simtest.ratio can be used to produce a more detailed print-out, which is recommended if user-defined contrasts are used,
sci.ratio for constructing simultaneous confidence intervals for ratios in oneway layout
See summary.glht(multcomp) for multiple tests for parameters of lm, glm.
Examples
library(mratios)
########################################################
# User-defined contrasts for comparisons
# between Active control, Placebo and three dosage groups:
data(AP)
AP
boxplot(prepost~treatment, data=AP)
# Test whether the differences of doses 50, 100, 150 vs. Placebo
# are non-inferior to the difference of Active control vs. Placebo
# User-defined contrasts:
# Numerator Contrasts:
NC <- rbind(
"(D100-D0)" = c(0,-1,1,0,0),
"(D150-D0)" = c(0,-1,0,1,0),
"(D50-D0)" = c(0,-1,0,0,1))
# Denominator Contrasts:
DC <- rbind(
"(AC-D0)" = c(1,-1,0,0,0),
"(AC-D0)" = c(1,-1,0,0,0),
"(AC-D0)" = c(1,-1,0,0,0))
NC
DC
noninf <- simtest.ratio(prepost ~ treatment, data=AP,
Num.Contrast=NC, Den.Contrast=DC, Margin.vec=c(0.9,0.9,0.9),
alternative="greater")
summary( noninf )
#########################################################
## Not run:
# Some more examples on standard multiple comparison procedures
# stated in terms of ratio hypotheses:
# Comparisons vs. Control:
many21 <- simtest.ratio(prepost ~ treatment, data=AP,
type="Dunnett")
summary(many21)
# Let the Placebo be the control group, which is the second level
# in alpha-numeric order. A simultaneous test for superiority of
# the three doses and the Active control vs. Placebo could be
# done as:
many21P <- simtest.ratio(prepost ~ treatment, data=AP,
type="Dunnett", base=2, alternative="greater", Margin.vec=1.1)
summary(many21P)
# All pairwise comparisons:
allpairs <- simtest.ratio(prepost ~ treatment, data=AP,
type="Tukey")
summary(allpairs)
#######################################################
# Comparison to grand mean of all strains
# in the Penicillin example:
data(Penicillin)
CGM <- simtest.ratio(diameter~strain, data=Penicillin, type="GrandMean")
CGM
summary(CGM)
## End(Not run)
Approximate simultaneous tests for ratios of normal means with heterogeneous variances
Description
Performs simultaneous tests for several ratios of linear combinations of treatment means in a normal one-way layout, assuming normal distribution of the data allowing heterogeneous variances.
Usage
simtest.ratioVH(formula, data,
type = "Dunnett", base = 1, alternative = "two.sided",
Margin.vec = NULL, FWER = 0.05,
Num.Contrast = NULL, Den.Contrast = NULL,
names = TRUE)
Arguments
formula |
a formula specifying a numerical response and a grouping factor (e.g., response ~ treatment) |
data |
a dataframe containing the response and group variable |
type |
type of contrast, with the following options: "Dunnett" for many-to-one comparisons, with control in the denominator; "Tukey" for all-pair comparisons; "Sequen": comparison of consecutive groups, where the group with lower order is the denominator; "AVE": comparison of each group with average of all others, where the average is taken as denominator; "Changepoint": ratio of averages of groups of higher order divided by averages of groups of lower order; "Marcus": Marcus contrasts as ratios; "McDermott": McDermott contrasts as ratios; "Williams": Williams contrasts as ratios. Note that type is ignored if Num.Contrast and Den.Contrast are specified by the user (See below). |
base |
a single integer specifying the control (i.e. denominator) group for the Dunnett contrasts, ignored otherwise |
alternative |
a character string: "two.sided" for two-sided tests, "less" for lower tail tests, "greater" for upper tail tests |
Margin.vec |
a single numerical value or vector of Margins under the null hypotheses, default is 1 |
FWER |
a single numeric value specifying the family-wise error rate to be controlled |
Num.Contrast |
Numerator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
Den.Contrast |
Denominator contrast matrix, where columns correspond to groups and rows correspond to contrasts |
names |
a logical value: if TRUE, the output will be named according to names of user defined contrast or factor levels |
Details
The associated ratio test statistic T[i] has a t-distribution. Multiplicity adjustment is achieved by using quantiles of r r-variate t-distributions, which differ in the degree of freedom and share the correlation structure. The compariso-specific degrees of freedom are derived using the approximation according to Satterthwaite (1946).
Value
An object of class simtest.ratio containing:
estimate |
a (named) vector of estimated ratios |
teststat |
a (named) vector of the calculated test statistics |
Num.Contrast |
the numerator contrast matrix |
Den.Contrast |
the denominator contrast matrix |
CorrMat |
the correlation matrix of the multivariate t-distribution calculated under the null hypotheses |
critical.pt |
the equicoordinate critical value of the multi-variate t-distribution for a specified FWER |
p.value.raw |
a (named) vector of unadjusted p-values |
p.value.adj |
a (named) vector of p-values adjusted for multiplicity |
Margin.vec |
the vector of margins under the null hypotheses |
and some other input arguments.
Author(s)
Mario Hasler
References
Simultaneous tests (adjusted p-values)
Hasler, M. and Hothorn, L.A. (2008): Multiple contrast tests in the presence of heteroscedasticity. Biometrical Journal 50, 793-800.
Unadjusted tests (raw p-values)
Hasler M, Vonk R, Hothorn LA (2007). Assessing non-inferiority of a new treatment in a three-arm trial in the presence of heteroscedasticity. Statistics in Medicine 27, 490-503.
Satterthwaite, FE (1946). An approximate distribution of estimates of variance components. Biometrics 2, 110-114.
See Also
sci.ratioVH for corresponding confidence intervals
Examples
###############################################
data(Mutagenicity, package="mratios")
boxplot(MN~Treatment, data=Mutagenicity)
## Not run:
simtest.ratioVH(MN~Treatment, data=Mutagenicity,
type="Dunnett", base=6, Margin.vec=1.2, alternative="less")
###############################################
# Unadjusted confidence intervals for multiple ratios
# of means assuming heterogeneous group variances.
# The following code produces the results given in Table
# V of Hasler, Vonk and Hothorn (2007).
# The upper confidence limits in Table V can produced
# by calling:
# Mutagenicity of the doses of the new compound,
# expressed as ratio (DoseX-Vehicle)/(Cyclo25-Vehicle):
# Check the order of the factor levels:
levels(Mutagenicity$Treatment)
# numerators:
NC<-rbind(
"Hydro30-Vehicle"=c(0,0,1,0,0,-1),
"Hydro50-Vehicle"=c(0,0,0,1,0,-1),
"Hydro75-Vehicle"=c(0,0,0,0,1,-1),
"Hydro100-Vehicle"=c(0,1,0,0,0,-1)
)
DC<-rbind(
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1),
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1),
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1),
"Cyclo25-Vehicle"=c(1,0,0,0,0,-1)
)
colnames(NC)<-colnames(DC)<-levels(Mutagenicity$Treatment)
NC
DC
# The raw p-values are those presented in Table V:
simtest.ratioVH(formula=MN~Treatment, data=Mutagenicity,
Num.Contrast=NC, Den.Contrast=DC,
alternative="less", Margin.vec=0.5, FWER=0.05)
## End(Not run)
Summary function for sci.ratio
Description
Detailed print out for sci.ratio objects.
Usage
## S3 method for class 'sci.ratio'
summary(object, digits=4, ...)
Arguments
object |
an object of class "sci.ratio" or "sci.ratio.gen" as can be obtained by calling the function sci.ratio |
digits |
digits for rounding the output |
... |
arguments to be passed to print |
Value
A more detailed print output of the results and some computational steps used in sci.ratio.
See Also
print.sci.ratio, plot.sci.ratio
Examples
data(BW)
RES <- sci.ratio(Weight~Dose, data=BW, type="Dunnett", alternative="greater")
summary(RES)
Summary function for simtest.ratio
Description
A detailed print out of the results of simtest.ratio
Usage
## S3 method for class 'simtest.ratio'
summary(object, digits = 4, ...)
Arguments
object |
An object of class "simtest.ratio" as obtained by calling simtest.ratio |
digits |
digits for rounding of the results |
... |
arguments to be passed to print |
Value
A print out, containing the numerator and denominator contrast matrices, the correlation under the null-hypothesis, margins, estimates, teststatistics, and p.values computed by simtest.ratio.
t-test for the ratio of two means
Description
Performs t-test for the ratio of means of two independent samples from two gaussian distributions. In case of heterogeneous variances a Satterthwaite approximation of the degrees of freedom is used (Tamhane & Logan, 2004).
Usage
## Default S3 method:
ttestratio(x, y, alternative = "two.sided",
rho = 1, var.equal = FALSE, conf.level = 0.95,
iterativeCI=FALSE, ul=1e+10, ll=-1e+10, ...)
## S3 method for class 'formula'
ttestratio(formula, data, base=2, ...)
Arguments
x |
A numeric vector (group in the numerator of the ratio) |
y |
A numeric vector (group in the denominator of the ratio) |
formula |
A two-sided formula specifying a numeric response variable and a factor with two levels |
data |
A dataframe containing the variables specified in formula. Note: the first group in alpha-numeric order will appear in the denominator of the ratio |
alternative |
character string defining the alternative hypothesis, one of "two.sided", "less" or "greater" |
rho |
a single numeric value: the margin or ratio under the null hypothesis |
var.equal |
logical, if set TRUE, a ratio-t-test assuming equal group variances is performed, otherwise (default) unequal variances are assumed |
conf.level |
confidence level of Fieller's interval for the ratio of two means |
base |
if formula is used: a single numeric value specifying whether the first or second group (according to alpha-numeric order) is to be used as denominator |
iterativeCI |
a single logical, indicating whether the confidence limits shall be found with based on Fiellers formula (default) or by iteratively inverting the test (if TRUE); ignored when var.equal=TRUE |
ul |
a single numeric, defining the upper limit for searching the upper confidence bound in uniroot, if iterativeCI=TRUE and var.equal=FALSE, ignored otherwise |
ll |
a single numeric, defining the lower limit for searching the lower confidence bound in uniroot, if iterativeCI=TRUE and var.equal=FALSE, ignored otherwise |
... |
arguments to be passed to ttestratio.default |
Details
This function implements the t-test for the ratio of two means and Fiellers confidence interval for the ratio of two means assuming mutually independent Gaussian errors with homogeneous variances, e.g. in Hauschke, Kieser, Hothorn (1999), when the argument var.equal=TRUE. With the argument var.equal=FALSE (default), the t-test for the ratio of two means assuming mutually independent Gaussian errors and possibly heterogeneous group variances (Tamhane and Logan, 2004) is implemented. When iterativeCI = FALSE (default) the corresponding confidence limits are obtained by using Fiellers formula with plug-in of the Satterthwaites degree of freedom calculated with the sample estimates for ratio and variances (not published). These bounds perform quite well but do not necessarily exactly coincide with the test decision. Setting iterativeCI = TRUE invokes interatively searching for the confidence limits by inverting Tamhane and Logans test using the function uniroot. If the confidence set is unbounded or gives irregular upper and/or lower bounds, a warning and NAs for the confidence limits are returned.
Note that when the mean of the denominator of the ratio is close to zero, confidence intervals might be degenerated and are not returned.
Value
An object of class "htest"
Author(s)
Frank Schaarschmidt
References
Hauschke, D., Kieser, M., Hothorn, L.A. (1999). Proof of safety in toxicology based on the ratio of two means for normally distributed data. Biometrical Journal 41, 295-304.
Tamhane, A.C., Logan, B.R. (2004). Finding the maximum safe dose level for heteroscedastic data. Journal of Biopharmaceutical Statistics 14, 843-856.
Examples
library(mratios)
####################################################
# ASAT values of female rats in a toxicity study
# (Hauschke, 1999).
data(ASAT)
ASAT
ttestratio(ASAT~group, data=ASAT, alternative="less",
base=1, rho=1.25, var.equal=TRUE)
######################################################
# Bodyweights of male rats in a toxicity study.
# Objective was to show equivalence between the high
# dose group (Dosis) and the control group (Kon).
# Equivalence margins are set to 0.8 and 1.25. The
# type-I-error to show equivalence is set to alpha=0.05.
data(rat.weight)
# two one-sided tests:
ttestratio(weight~group, data=rat.weight, alternative="less",
rho=1.25, var.equal=TRUE)
ttestratio(weight~group, data=rat.weight, alternative="greater",
rho=0.8, var.equal=TRUE)
# For rho=1, ttestratio corresponds to a simple t.test
# with the difference of means under the null set to zero
# (,i.e. mu=0).
ttestratio(ASAT~group, data=ASAT, alternative="less",
rho=1, var.equal=TRUE)
t.test(ASAT~group, data=ASAT, alternative="less",
mu=0, var.equal=TRUE)
# Ratio of means bewtween negative and positive control in the
# mutagenicity data set, allowing heterogeneous variances:
data(Mutagenicity)
DM<-subset(Mutagenicity, Treatment=="Vehicle"|Treatment=="Cyclo25")
# 95%-CI using the Fieller formula, Satterthwaite df with plug-in of
# ratio estimate
ttestratio(MN~Treatment, data=DM, alternative="two.sided",
var.equal=FALSE, iterativeCI=FALSE)
# 95%-CI based on directly inverting Tamhane and Logans test
# (Satterthwaite df, avoiding simple plug-in of the ratio estimate)
ttestratio(MN~Treatment, data=DM, alternative="two.sided",
var.equal=FALSE, iterativeCI=TRUE)