Title: | Closed Testing Procedure (CTP) |
---|---|
Description: | This is a package for constructing hypothesis trees for treatment comparisons based on the closure principle and analysing the corresponding Closed Testing Procedures (CTP) using adjusted p-values. For reference, see Marcus, R., Peritz, E, and Gabriel, K.R. (1976) <doi:10.2307/2335748> and Bauer, P (1991) <doi:10.1002/sim.4780100609>. |
Authors: | Paul Jordan [aut, cre], Matthias Herpers [aut] |
Maintainer: | Paul Jordan <[email protected]> |
License: | GPL (>=2) |
Version: | 3.0.2 |
Built: | 2024-11-02 03:58:05 UTC |
Source: | https://github.com/openpharma/CTP |
Adjusting p-values, auxiliary function
Adjust_p(ctp.struc, ctp.pval)
Adjust_p(ctp.struc, ctp.pval)
ctp.struc |
Object of class |
ctp.pval |
Data frame with hypothesis names and unadjusted p-values. Output from |
Adjusted p-values
Function that adjusts the raw p-values of the elementary hypotheses of a closed testing procedure. The raw p-values are adjusted according to the closure principle. The adjusted p-value is calculated as the maximum of the raw p-value from the current hypothesis in question and the raw p-values from all subsequent hypotheses that contain the current hypothesis.
Adjust_raw( ctp.struc, p.value, dataset.name = NULL, factor.name = NULL, factor.levels = NULL, model = NULL, test.name = NULL )
Adjust_raw( ctp.struc, p.value, dataset.name = NULL, factor.name = NULL, factor.levels = NULL, model = NULL, test.name = NULL )
ctp.struc |
Object generated by |
p.value |
Vector of raw p-values in the order of the hypotheses created by |
dataset.name |
Character string naming the analysis dataset (optional - only for documentation purposes). |
factor.name |
Character string naming the factor whose levels are compared (optional - only for documentation purposes). |
factor.levels |
Vector of type "character" containing the levels of the treatment factor (optional - only for documentation purposes). |
model |
Model used in the analysis (optional - only for documentation purposes). |
test.name |
Character string naming the statistical test applied. |
An object of oldClass = "ctp"
to be used for summarizing and plotting the results.
IntersectHypotheses
, AnalyseCTP
, Display
,
summary.ctp
Pairwise <- IntersectHypotheses(list(c(1,2), c(1,3), c(1,4), c(2,3), c(2,4), c(3,4))) Display(Pairwise) summary(Pairwise) # the vector of p-values calculated by another software p.val <- c( 0.4374, 0.6485, 0.4103, 0.2203, 0.1302, 0.6725, 0.4704, 0.3173, 0.6762, 0.7112, 0.2866, 0.3362, 0.2871, 0.4633) result <- Adjust_raw(ctp.struc=Pairwise, p.value=p.val) ## details may be documented result <- Adjust_raw(Pairwise, p.value=p.val ,dataset.name="my Data", factor.name="Factor" ,factor.levels=c("A","B","C","D"), model=y~Factor ,test.name="my Test") summary(result) Display(result)
Pairwise <- IntersectHypotheses(list(c(1,2), c(1,3), c(1,4), c(2,3), c(2,4), c(3,4))) Display(Pairwise) summary(Pairwise) # the vector of p-values calculated by another software p.val <- c( 0.4374, 0.6485, 0.4103, 0.2203, 0.1302, 0.6725, 0.4704, 0.3173, 0.6762, 0.7112, 0.2866, 0.3362, 0.2871, 0.4633) result <- Adjust_raw(ctp.struc=Pairwise, p.value=p.val) ## details may be documented result <- Adjust_raw(Pairwise, p.value=p.val ,dataset.name="my Data", factor.name="Factor" ,factor.levels=c("A","B","C","D"), model=y~Factor ,test.name="my Test") summary(result) Display(result)
Calculation of p-values of a closed testing procedure (CTP).
The function returns an object of oldClass "ctp"; summary()
and Display()
can be applied.
AnalyseCTP(ctp.struc, model, data, factor.name = NULL, test.name = "F", ...)
AnalyseCTP(ctp.struc, model, data, factor.name = NULL, test.name = "F", ...)
ctp.struc |
Object generated by the function |
model |
model of the form response~treatment. If |
data |
Dataframe, missing values in the response or treatment variable are not allowed! |
factor.name |
Character string naming the factor whose levels are compared (treatment factor). By default the first variable of the right-hand side of the model formula is used. |
test.name |
One of the following strings
|
... |
Additional arguments for the chosen test. |
The hypothesis tree of the closed testing procedure must be created using IntersectHypotheses
. For more details on the theory and the implementation as well
for many examples, see the vignettes.
An object of old class(ctp
), consisting of a list with:
CTPparms
: List with objects describing the CTP setup.
pvalues
: Dataframe with all tested hypotheses, raw and adjusted p-values.
This procedure is constructed for testing differences and two-sided hypotheses, but not for equivalence tests. It is further based on independent samples from the population involved (i.e. on parallel group designs, but not on cross-over designs).
IntersectHypotheses
, Display
, summary.ctp.str
, summary.ctp
,
Adjust_raw
data(pasi) three.to.first <- IntersectHypotheses(list(1:2,c(1,3),c(1,4))) Display(three.to.first) pasi.ctp.F1 <- AnalyseCTP(three.to.first,pasi.ch~dose,pasi) summary(pasi.ctp.F1) Display(pasi.ctp.F1)
data(pasi) three.to.first <- IntersectHypotheses(list(1:2,c(1,3),c(1,4))) Display(three.to.first) pasi.ctp.F1 <- AnalyseCTP(three.to.first,pasi.ch~dose,pasi) summary(pasi.ctp.F1) Display(pasi.ctp.F1)
A dataframe containing the responders to the treatment with two doses of an experimental drug or a standard treatment.
data(colorectal)
data(colorectal)
A data frame with 104 observations and 2 variables:
dose
a factor with levels control
low
high
responder
a factor with levels no
yes
Library of functions to design and analyse closed testing procedures for the comparison of population parameters based on independent samples.
Library of functions to design and analyse closed testing procedures for treatment comparisons.
The comparison of the population parameters are based on independent samples. The function IntersectHypotheses
creates the hypothesis tree (closure set) of a closed testing procedure. All possible intersecting hypotheses derived from
the list of elementary hypotheses(i.e. the hypotheses to be tested) are produced. The resultant hypothesis tree
will consist of the elementary hypotheses as well as all subsequent intersected hypotheses. The procedure ends when
one hypothesis (the global hypothesis) remains. In this way, for each elementary hypothesis all hypotheses implying
it can be found.
The analysis is performed using AnalyseCTP
. First the raw p-values are computed for all hypotheses of the
hypothesis tree, then the p-values of the elementary hypotheses are adjusted according to the closure principle i.e. the adjusted p-value is
calculated as the maximum of the raw p-value of the hypothesis in question and of the raw p-values of all
hypotheses implying it.
Instead of applying AnalyseCTP
, the raw p-values can be computed
using any other available software. For this purpose, the functions Adjust_raw
is provided.
and
summary.ctp.str
generates a data frame comprising all the hypothesis of the hypothesis tree.
The function Adjust_raw
calculates the p-values for the given hypothesis tree from the raw p-values
provided in the same order as the hypotheses occur in the data frame created by summary.ctp.str
.
The results are presented using the generic functions summary
and Display
.
J. Bock & P.Jordan
Performes all required comparisons of treatment levels
CTPcompare(CTPparms, ...)
CTPcompare(CTPparms, ...)
CTPparms |
Object of class |
... |
Additional arguments for the chosen test |
A data.frame with the hypotheses and the unadjusted p-values
Extracting CTP - parameters
getCTPparms( ctp.struc, model, dataset, factor.name = NULL, test.name = "F", ... )
getCTPparms( ctp.struc, model, dataset, factor.name = NULL, test.name = "F", ... )
ctp.struc |
Object of class |
model |
Formula of the form response~treatment. |
dataset |
Dataframe. |
factor.name |
Character string naming the factor whose levels are compared (treatment factor). By default the first variable of the right-hand side of the model formula is used. |
test.name |
One of the following strings
|
... |
Additional arguments for the chosen test |
A list with CTP parameters
Getting the response vector out of an object of class 'formula'
getResponse(formula, data)
getResponse(formula, data)
formula |
Model formula |
data |
Dataframe |
Vector of response
data(pasi) data(pasi) getResponse(pasi.ch ~ dose, data=pasi) library(survival) data(ovarian) ovarian$subgroups <- as.factor(10*ovarian$ecog.ps+ovarian$rx) surv <- getResponse(Surv(futime,fustat)~rx, data=ovarian) print(surv) class(surv)
data(pasi) data(pasi) getResponse(pasi.ch ~ dose, data=pasi) library(survival) data(ovarian) ovarian$subgroups <- as.factor(10*ovarian$ecog.ps+ovarian$rx) surv <- getResponse(Surv(futime,fustat)~rx, data=ovarian) print(surv) class(surv)
The dataframe glucose
comprises the baseline values of fasting plasma glucose (mmol/L)
and their changes from baseline to the end of the study.
data(glucose)
data(glucose)
A data frame with 89 observations and 3 variables:
GLUCOSE.BLA
Fasting plasma glucose at baseline
GLUCOSE.CHANGE
Changes in fasting plasma glucose from baseline
DOSE
An ordered factor with levels PLACEBO
< LOW
< MEDIUM
< HIGH
Generation of the hypotheses tree of a closed testing procedure (CTP). The function returns an object of oldClass "ctp.str"
;
summary
and Display
can be applied.
IntersectHypotheses(hyplst)
IntersectHypotheses(hyplst)
hyplst |
A list of integer vectors representing the elementary hypotheses. |
Sets of elementary hypotheses are described by lists of integer vectors eg. list(1:2, c(1,3), c(1,4))
if the populations 2, 3 and 4 have to be compared to population 1.
For the generation of the hypothesis tree of a closed testing procedure first all intersections of the elementary hypothese;
then all intersections of these intersections etc. have to be created. The set of hypotheses at each intersection level must be
reduced by deleting double hypotheses and creating unions. The size of the hypothesis tree increases rapidly with growing number of elementary hypotheses,
which can lead to memory and/or time problems!
The intersection procedure ends if a single hypothesis (the global hypothesis) is left.
hypothesis
The hypothesis tree described as lists hypotheses at each intersection level.
relations
The relation structure of the hypotheses tree used for plotting.
hypnames
Character representations of the hypotheses used for summary tables and plotting.
connections
The connections used for calculating the adjusted p-values.
This procedure is constructed for null-hypotheses describing the equality of the same parameter for different populations.
Warning:
The size of the hypothesis tree increases rapidly with growing number of elementary hypotheses. This can lead to memory and/or time problems!
hlist <- list(1:2, c(1,3), c(1,4)) htree <- IntersectHypotheses(hlist) summary(htree) Display(htree) # compare in a set of six means all others to the fourth mean # five.to.fourth <- IntersectHypotheses(list(c(1,4),c(2,4),c(3,4),c(4,5),c(4,6))) Display(five.to.fourth)
hlist <- list(1:2, c(1,3), c(1,4)) htree <- IntersectHypotheses(hlist) summary(htree) Display(htree) # compare in a set of six means all others to the fourth mean # five.to.fourth <- IntersectHypotheses(list(c(1,4),c(2,4),c(3,4),c(4,5),c(4,6))) Display(five.to.fourth)
The dataframe pasi
comprises the changes in PASI-score (Psoirasis Area and Severity Index)
from Baseline within two months in 72 patients treated with different
doses of Etretin or Placebo in a double blind study.
data(pasi)
data(pasi)
A data frame with 72 observations and 3 variables:
a factor with levels Etretin10mg
Etretin25mg
Etretin50mg
Placebo
Changes in PASI score within two months
Dose of Etretin as ordered factor with levels
Placebo
< ET.10mg
< ET.25mg
< ET.50mg
The functions summary.ctp.str
and Display.ctp.str
summarise and plot the hypothesis tree of a closed testing procedure,
whereas the functions summary.ctp
and Display.ctp
summarise and plot the results of a closed testing procedure.
## S3 method for class 'ctp' summary(object, digits = 4, ...) ## S3 method for class 'ctp.str' summary(object, ...) Display(object, ...) ## S3 method for class 'ctp' Display(object, Type = "s", arrow = FALSE, ...) ## S3 method for class 'ctp.str' Display(object, Type = "s", arrow = FALSE, ...)
## S3 method for class 'ctp' summary(object, digits = 4, ...) ## S3 method for class 'ctp.str' summary(object, ...) Display(object, ...) ## S3 method for class 'ctp' Display(object, Type = "s", arrow = FALSE, ...) ## S3 method for class 'ctp.str' Display(object, Type = "s", arrow = FALSE, ...)
object |
Object generated by |
digits |
The minimum number of significant digits to be printed for the p-values in the summary. |
... |
Additional arguments passed to |
Type |
Type of the plotted tree: |
arrow |
If |
@name Generic_Functions
@aliases summary Display
summary.ctp.str
provides lists with dataframes comprising the hypothesis names as strings
and the relationship between the hypotheses.
summary.ctp
provides a table of hypotheses, raw p-values and
adjusted p-values.
Disply.ctp.str
plots the hypothesis tree. Display.ctp
plots the hypothesis
tree together with the unadjusted and adjusted p-values.
IntersectHypotheses
, AnalyseCTP
Testing set for an elementary hypothesis
TestingSet(ctp.struc, Hyp)
TestingSet(ctp.struc, Hyp)
ctp.struc |
Object of class |
Hyp |
Elementary hypothesis (character variable). |
The testing set for the elementary hypothesis (character vector).
Pairwise <- IntersectHypotheses(list(c(1,2), c(1,3), c(1,4), c(2,3), c(2,4), c(3,4))) Set24 <- TestingSet(Pairwise,"[24]") Set24
Pairwise <- IntersectHypotheses(list(c(1,2), c(1,3), c(1,4), c(2,3), c(2,4), c(3,4))) Set24 <- TestingSet(Pairwise,"[24]") Set24