Thanks John. Appreciate the insights.
On 9/17/2023 9:43 AM, John Fox wrote:
Dear Robert,
Anova() calls linearHypothesis(), also in the car package, to compute
sums of squares and df, supplying appropriate hypothesis matrices.
linearHypothesis() usually tries to express the hypothesis matrix in
symbolic equation form for printing, but won't do this if coefficient
names include arithmetic operators, in your case - and +, which can
confuse it.
The symbolic form of the hypothesis isn't really relevant for Anova(),
which doesn't use the printed representation of each hypothesis, and
so, despite the warnings, you get the correct ANOVA table. In your
case, where the data are balanced, with 4 cases per cell, Anova(mod)
and summary(mod) are equivalent, which makes me wonder why you would
use Anova() in the first place.
To elaborate a bit, linearHypothesis() does tolerate arithmetic
operators in coefficient names if you specify the hypothesis
symbolically rather than as a hypothesis matrix. For example, to test,
the interaction:
------- snip --------
> linearHypothesis(mod,
+ c("TreatmentDabrafenib:ExpressionCD271+ = 0",
+ "TreatmentTrametinib:ExpressionCD271+ = 0",
+ "TreatmentCombination:ExpressionCD271+ = 0"))
Linear hypothesis test
Hypothesis:
TreatmentDabrafenib:ExpressionCD271+ = 0
TreatmentTrametinib:ExpressionCD271+ = 0
TreatmentCombination:ExpressionCD271+ = 0
Model 1: restricted model
Model 2: Viability ~ Treatment * Expression
Res.Df RSS Df Sum of Sq F Pr(>F)
1 27 18966
2 24 16739 3 2226.3 1.064 0.3828
------- snip --------
Alternatively:
------- snip --------
> H <- matrix(0, 3, 8)
> H[1, 6] <- H[2, 7] <- H[3, 8] <- 1
> H
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 0 0 0 0 0 1 0 0
[2,] 0 0 0 0 0 0 1 0
[3,] 0 0 0 0 0 0 0 1
> linearHypothesis(mod, H)
Linear hypothesis test
Hypothesis:
Model 1: restricted model
Model 2: Viability ~ Treatment * Expression
Res.Df RSS Df Sum of Sq F Pr(>F)
1 27 18966
2 24 16739 3 2226.3 1.064 0.3828
Warning message:
In printHypothesis(L, rhs, names(b)) :
one or more coefficients in the hypothesis include
arithmetic operators in their names;
the printed representation of the hypothesis will be omitted
------- snip --------
There's no good reason that linearHypothesis() should try to express
each hypothesis symbolically for Anova(), since Anova() doesn't use
that information. When I have some time, I'll arrange to avoid the
warning.
Best,
John
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.