Skip to content

Commit

Permalink
version 1.4-6
Browse files Browse the repository at this point in the history
  • Loading branch information
thothorn authored and cran-robot committed Jul 14, 2016
1 parent e709bb9 commit 3a68321
Show file tree
Hide file tree
Showing 20 changed files with 392 additions and 150 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: multcomp
Title: Simultaneous Inference in General Parametric Models
Version: 1.4-5
Date: 2016-05-03
Version: 1.4-6
Date: 2016-07-14
Authors@R: c(person("Torsten", "Hothorn", role = c("aut", "cre"),
email = "[email protected]"),
person("Frank", "Bretz", role = "aut"),
Expand All @@ -15,7 +15,7 @@ Description: Simultaneous tests and confidence intervals
The package includes demos reproducing analyzes presented
in the book "Multiple Comparisons Using R" (Bretz, Hothorn,
Westfall, 2010, CRC Press).
Depends: stats, graphics, mvtnorm (>= 1.0-3), survival (>= 2.35-7),
Depends: stats, graphics, mvtnorm (>= 1.0-3), survival (>= 2.39-4),
TH.data (>= 1.0-2)
Imports: sandwich (>= 2.3-0), codetools
Suggests: lme4 (>= 0.999375-16), nlme, robustbase, coin, MASS, car,
Expand All @@ -25,7 +25,7 @@ URL: http://multcomp.R-forge.R-project.org The publishers web page is
LazyData: yes
License: GPL-2
NeedsCompilation: no
Packaged: 2016-05-04 08:33:40 UTC; hothorn
Packaged: 2016-07-14 12:11:59 UTC; hothorn
Author: Torsten Hothorn [aut, cre],
Frank Bretz [aut],
Peter Westfall [aut],
Expand All @@ -34,4 +34,4 @@ Author: Torsten Hothorn [aut, cre],
Susan Scheibe [ctb]
Maintainer: Torsten Hothorn <[email protected]>
Repository: CRAN
Date/Publication: 2016-05-04 12:46:48
Date/Publication: 2016-07-14 16:52:32
36 changes: 19 additions & 17 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
f367aeafdfcab9f9e6458c363d1deb45 *DESCRIPTION
a5a607001fcab63475acab8a26b4c3fb *DESCRIPTION
6f1c37daef616f400da863d7c86124f6 *NAMESPACE
04d2a926addbc79ec5839ed9b86b63a0 *R/cld.R
fb371dc9bf3a59db5b2045f190fbd296 *R/contrMat.R
1d53ca49bf1b85e692a9d49b627d68db *R/expressions.R
1c948a62c4c91197df9053eec2d0c652 *R/expressions.R
b2bcdf05c0c07e95b2c537a0ba6a7894 *R/glht.R
db675272bddabc11f1d37698a34537a5 *R/helpers.R
7b056af5b25a6293586bc9a214d79f92 *R/helpers.R
9dba312a1100ead0426531dc7ef25732 *R/maxsets.R
6306519f879a15332f0cf3dac083d030 *R/mcp.R
2a908b5885569f86726f01ed479e104d *R/methods.R
Expand All @@ -13,14 +13,14 @@ db675272bddabc11f1d37698a34537a5 *R/helpers.R
89a738f023fdbe16cff5ed42b8c313e3 *R/plot.R
e563b6c9b7b80b6969789187b72e032e *R/pqfunctions.R
9b032ed24188c147c36282dbcdcfa503 *R/print.R
c0176fdef11d3c9eb21cef32335f67db *build/vignette.rds
c31d5c4efffeb5ff2bd1174d5bd46c28 *build/vignette.rds
591f052540e1edca9c1d4181661bce2e *cleanup
e47d77ece20d7b6bd5360908b8cb9821 *data/adevent.rda
899a8f48a099bf1e6b51cec946cc7371 *data/cholesterol.rda
a697f10b44adb18bd0f617b728c12c89 *data/cholesterol.rda
592dcf8253e902597f2de495e6bc48ec *data/cml.rda
72a8a2a4a8edb1b8ff35ce0148db1307 *data/detergent.rda
e8a33847c94deda1b7df7c0c522cf887 *data/fattyacid.rda
9384b5f573a3cc38cf15657dab46ed8b *data/litter.rda
56c04e2d56dfb2b4b22874e3baf8b726 *data/litter.rda
9bea2474d2f805a25420293991b6c531 *data/mtept.rda
c298df5ee9c95d89980ac42b97e7a837 *data/recovery.rda
f3033fee09f12f3cfad26e8fccf308ec *data/sbp.rda
Expand All @@ -38,20 +38,20 @@ c330e0321b00523651d707a8b4399020 *inst/MCMT/MCMT.R
5ccc54941334fbd572cd4891c2009ccc *inst/MCMT/MCMT.Rout.save
26ccee8d5d8bc87c503e43bde27e282f *inst/MCMT/MCMT.rda
abd0ee3bb82571b7fb64e8a2e1cf03a2 *inst/MCMT/multcomp.sas
4e98c19efd9e0836e430190954e4a45c *inst/NEWS
e548a9cea022165606a0f375e617dd0d *inst/NEWS
09ce7512593c1be00ee89ee431ca6112 *inst/deprecated/deprecated.R
fe4cbe4e17edf996147191527f7e9efa *inst/deprecated/multcomp-deprecated.Rd
4fcad824fe2a0c192b10a18cd7da2146 *inst/deprecated/multcomp-oldtests.R
6f2f2667a0374a4f82e3a01067e18b11 *inst/deprecated/multcomp-oldtests.Rout.save
3218dcf4f93b9f33cb0bf21e2d768131 *inst/doc/chfls1.R
624888bf9e4e1fcb49a0de92f401239d *inst/doc/chfls1.Rnw
2fc2016639b3ebed9049861eabd895fa *inst/doc/chfls1.pdf
1e7520daabc69db30ecb805fb12b32f4 *inst/doc/chfls1.pdf
38df3029ad9a35883c803f71fe8728d0 *inst/doc/generalsiminf.R
01edc2335733d9ff0091c32567ebb9eb *inst/doc/generalsiminf.Rnw
5e18f65c02a7346b010951742fff64b0 *inst/doc/generalsiminf.pdf
206014fe38e565f854395901b14e0c70 *inst/doc/generalsiminf.Rnw
6f9ea9e8032a084da57c40ff3fd88298 *inst/doc/generalsiminf.pdf
ebfe06d5557e1d187ff34d3cb5abe225 *inst/doc/multcomp-examples.R
3a8b15057cde66a53b6919441ca87c9b *inst/doc/multcomp-examples.Rnw
337cf8223c691d8602d7063e59180d60 *inst/doc/multcomp-examples.pdf
463781e9409e74f4118148d21d2807d5 *inst/doc/multcomp-examples.pdf
b8db88a39fe73ccefbd7deaaffdec3cd *inst/multcomp_VA.R
625d3532deb47821fb6964cc748cd343 *inst/multcomp_coxme.R
02a0956bb972a95339c890c34435a986 *man/adevent.Rd
Expand All @@ -74,25 +74,27 @@ f485e831baba6270104f2e3bca3ac144 *man/recovery.Rd
760f47a9610cfb8556b849bd4b55925c *man/sbp.Rd
fd77916439e541d1243818afc0a2f88a *man/trees513.Rd
e39aa3a890fbaa03f75ef666c4a5c3d7 *man/waste.Rd
eb1581be3ef517921de3656458fc298b *tests/Examples/multcomp-Ex.Rout.save
3470178805033fa44c37d1dc84943b97 *tests/Examples/multcomp-Ex.Rout.save
65ae23422858c188a5b0d9d99e4be34d *tests/angina.rda
1f6c3a1ec3633d909d788224596b328c *tests/bugfix.R
185b1b333ff90c326bcc18ee4bcefb70 *tests/bugfix.Rout.save
9d813c2ef56e9c68e04908c9fa92f298 *tests/bugfix.R
f8d8b6dd33fef15ee2448de3d967c563 *tests/bugfix.Rout.save
25dab2fe897a4579c79eb6ec500a7e3b *tests/regtest-Tukey.R
2285c7643c596d62d5a409ecf4d8864f *tests/regtest-Tukey.Rout.save
eaec357b3c7f0e242eec323eb03566b7 *tests/regtest-anova.R
67f624f17a93659b2bbd9a3acd22e3c9 *tests/regtest-anova.Rout.save
c7fadb28cbd8c5d3a1c7d6a37c95303c *tests/regtest-interface-extended.R
fd4c0874384390c5618ec9e6fe9575e7 *tests/regtest-interface-extended.Rout.save
2c8fbf836f9c847dd4192f875e2826aa *tests/regtest-interface-extended.R
b47c078cc6786e9cfc52e5cdec0c6e6c *tests/regtest-interface-extended.Rout.save
3962ab7fab999b367a876b09d65f0180 *tests/regtest-interface.R
0c474d0d7f5b9e3246a82f9dba84144e *tests/regtest-interface.Rout.save
99c02a131f3e08cda0eb32b39ed01c2a *tests/regtest-lme.R
9dfe571f92df8f8a6a76b7870917c5f6 *tests/regtest-lme.Rout.save
b7ba1b07cdad488d5c3e7c2507da63ee *tests/regtest-mmm.R
d4e6e453d241422254fd05e6e0ffe357 *tests/regtest-mmm.Rout.save
42d2043f60f504cc7f508420c4e92671 *tests/regtest-survival.R
41580f53d6aa4f9ccf4dd6021f208b0e *tests/regtest-survival.Rout.save
624888bf9e4e1fcb49a0de92f401239d *vignettes/chfls1.Rnw
acba174d6aa504f44510e772ea82825c *vignettes/chfls1.bib
01edc2335733d9ff0091c32567ebb9eb *vignettes/generalsiminf.Rnw
206014fe38e565f854395901b14e0c70 *vignettes/generalsiminf.Rnw
a00274f4317eb18540f0f4e38eb9da2f *vignettes/header.tex
3a8b15057cde66a53b6919441ca87c9b *vignettes/multcomp-examples.Rnw
8547da24406ebd4b24b4130195bc3e1e *vignettes/multcomp.bib
Expand Down
101 changes: 44 additions & 57 deletions R/expressions.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# $Id: expressions.R 435 2016-05-04 01:46:55Z sks $
# $Id: expressions.R 438 2016-05-06 19:11:07Z sks $

### determine if an expression `x' can be interpreted as numeric
is_num <- function(x) {
Expand All @@ -14,49 +14,18 @@ as.char <- function(ex) {
if (length(ex) == 3 && ex[[1]] == ":")
return(paste(as.char(ex[[2]]), ":",
as.char(ex[[3]]), sep = ""))
stop("Failed to convert expression ", ex, " to character")
}

### extract coefficients and variable names
coefs <- function(ex) {

### `a'
if (length(ex) == 1 && !is_num(ex))
return(list(coef = 1, var = as.char(ex)))

### `-a'
if (length(ex) == 2 && (ex[[1]] == "-" && !is_num(ex[[2]])))
return(list(coef = -1, var = as.char(ex[[2]])))

if (length(ex) == 3) {

### x:y
if (ex[[1]] == ":")
return(list(coef = 1,
var = as.char(ex)))

### `2 * a'
if (ex[[1]] == "*" && (is_num(ex[[2]]) && !is_num(ex[[3]])))
return(list(coef = eval(ex[[2]]), var = as.char(ex[[3]])))

cf <- coefs(ex[[3]])
if (ex[[1]] == "-")
cf$coef <- cf$coef * (-1)

return(cf)
}
stop("cannot interpret expression ", sQuote(ex), " as linear function")
stop("multcomp::as.char: Failed to convert expression ", ex, " to character")
}

### extract left hand side of an expression
lhs <- function(ex) {

if (length(ex) != 1)
stop("expression is not of length 1")
stop("multcomp:::lhs: expression is not of length 1", call. = FALSE )

if (length(ex[[1]]) != 3)
stop("expression ", sQuote(ex),
" does not contain a left and right hand side")
stop("multcomp:::lhs: expression ", sQuote(ex),
" does not contain a left and right hand side", call. = FALSE )

return(ex[[1]][[2]])
}
Expand All @@ -65,15 +34,15 @@ lhs <- function(ex) {
rhs <- function(ex) {

if (length(ex) != 1)
stop("expression is not of length 1")
stop("multcomp:::rhs: expression is not of length 1", call. = FALSE )

if (length(ex[[1]][[3]]) == 2)
return(-ex[[1]][[3]][[2]])

rhs <- ex[[1]][[3]]
if (!is_num(rhs) || length(rhs) > 1)
stop("right hand side of expression ", sQuote(ex),
" is not a scalar numeric")
stop("multcomp:::rhs: right hand side of expression ", sQuote(ex),
" is not a scalar numeric", call. = FALSE )
return(rhs)
}

Expand All @@ -82,7 +51,7 @@ side <- function(ex) {

side <- as.char(ex[[1]][[1]])
if (!(side %in% c("<=", ">=", "==", "=")))
stop("does not contain ", sQuote("<=, >=, =="))
stop("multcomp:::side: does not contain ", sQuote("<=, >=, =="), call. = FALSE )
alternative <- switch(side,
"<=" = "greater",
">=" = "less",
Expand Down Expand Up @@ -242,17 +211,34 @@ expression2coef <- function(ex, vars, debug = F) {
if ( sum ) {
w$fatal('sub','forming a difference between a constant and ',
'an effect as in ', sQuote(deparse(v)), ' ',
"is not a sensible operation")
"is not supported")
}

symbols
},

# ': a b ' -- support for interaction of effects as in A:B:C:D
# `:` `a` `b` -- support for interaction of effects as in A:B:C:D
# `:` `-a` `b` -- also support one or more signs before the first term
ita = function(v,w) {
if ( debug ) w$trace('ita',v,w)

res <- w$setCoef(as.name(deparse(v)), w$getCoef(v) )
tmp <- deparse(v)
prefix <- gsub('^([+-]*)(.*)','\\1',tmp)
name <- gsub('^([+-]*)(.*)','\\2',tmp)
sign <- 1

if ( prefix != '' ) {
for ( x in base::unlist(base::strsplit(prefix,'')) ) {
sign <- sign * switch( x,
'-' = -1,
'+' = 1,
w$fatal('ita', 'strange character ', sQuote(x),
' seen in ', sQuote(deparse(v))))

}
}

res <- w$setCoef(as.name(name), sign*w$getCoef(v) )

if ( debug ) {
dumped <- lapply(res, function(x,w) paste(x, 'with coef =', w$getCoef(x)),w)
Expand Down Expand Up @@ -319,7 +305,7 @@ expression2coef <- function(ex, vars, debug = F) {

if ( sum ) {
w$fatal('add','adding up a constant and an effect ',
"as in ", sQuote(deparse(v)), " is not a sensible operation")
"as in ", sQuote(deparse(v)), " is not supported")
}

# associate expression coefficient with all leafs
Expand Down Expand Up @@ -369,7 +355,7 @@ expression2coef <- function(ex, vars, debug = F) {
# allow the multiplication effects by a constant
if ( length(symbols) > 1 && all(unlist(lapply(res,is.symbol)) ) ) {
w$fatal('mul','the multiplication of effects ', w$enum(symbols),' ',
"as in ", sQuote(deparse(v)), " is not a sensible operation")
"as in ", sQuote(deparse(v)), " is not supported")
}

# associate the folded real valued literals as a coefficient with all symbols
Expand Down Expand Up @@ -477,7 +463,7 @@ expression2coef <- function(ex, vars, debug = F) {
},

fatal = function(name,...) {
stop(paste0("expression2coef::walkCode::",name),": ", ...)
stop(paste0("multcomp:::expression2coef::walkCode::",name),": ", ..., call. = FALSE )
},

trace = function(fn,v,w) {
Expand All @@ -492,23 +478,23 @@ expression2coef <- function(ex, vars, debug = F) {


if ( any(idx <- is.numeric(effects) ) ) {
stop("expression2coef",": The lhs expression ", sQuote(deparse(m.lhs)), " ",
stop("multcomp:::expression2coef: The lhs expression ", sQuote(deparse(m.lhs)), " ",
'contains a numeric offset term evaluating to ', paste0(effects[idx],collapse=', '), '. ',
'This is either an internal error or a misspecification from your part. ',
"If so, please pull these offsets to the right-hand side of the equation")
"If so, please pull these offsets to the right-hand side of the equation", call. = FALSE )
}

effect.names <- c()
effect.coeffs <- c()
effect.coefs <- c()

# There might be only a single effect as in 'Agriculture = 0'. Thus use
# c(effects) to prevent the for loop from running into an error condition
for ( effect in c(effects) ) {
effect.names <- c( effect.names, as.character(effect))
effect.coeffs <- c( effect.coeffs, attr(effect,"coef"))
effect.coefs <- c( effect.coefs, attr(effect,"coef"))
}

list( coef = effect.coeffs,
list( coef = effect.coefs,
names = effect.names,
m = m.rhs,
alternative = side(ex),
Expand All @@ -519,10 +505,10 @@ expression2coef <- function(ex, vars, debug = F) {
chrlinfct2matrix <- function(ex, var) {

if (!is.character(ex))
stop("argument ", sQuote(ex), " is not of type character")
stop("multcomp:::chrlinfct2matrix: argument ", sQuote(ex), " is not of type character", call. = FALSE )

if (!is.character(var))
stop("argument ", sQuote(var), " is not of type character")
stop("multcomp:::chrlinfct2matrix: argument ", sQuote(var), " is not of type character", call. = FALSE )

K <- matrix(0, nrow = length(ex), ncol = length(var))
colnames(K) <- var
Expand All @@ -533,13 +519,14 @@ chrlinfct2matrix <- function(ex, var) {

expr <- parse(text = ex[i])
if (length(expr[[1]]) != 3)
stop("argument ", sQuote(ex[i]),
" cannot be interpreted as expression")
stop("multcomp:::chrlinfct2matrix: argument ", sQuote(ex[i]),
" cannot be interpreted as expression", call. = FALSE )

tmp <- expression2coef(expr,vars=var)

if (!all(tmp$names %in% var))
stop("variable(s) ", paste(sQuote(tmp$names[!tmp$names %in% var]),collapse=', '), " not found")
stop("multcomp:::chrlinfct2matrix: variable(s) ",
paste(sQuote(tmp$names[!tmp$names %in% var]),collapse=', '), " not found", call. = FALSE )

for (n in tmp$names)
K[i, var == n] <- tmp$coef[tmp$names == n]
Expand All @@ -550,7 +537,7 @@ chrlinfct2matrix <- function(ex, var) {
alternative <- tmp$alternative
} else {
if (tmp$alternative != alternative)
stop("mix of alternatives currently not implemented")
stop("multcomp:::chrlinfct2matrix: mix of alternatives currently not implemented", call. = FALSE )
}

rownames(K)[i] <- paste0(tmp$lhs, collapse = "")
Expand Down
Loading

0 comments on commit 3a68321

Please sign in to comment.