Re: [R] Print hypothesis warning- Car package

2023-09-16 Thread Rolf Turner


On Sat, 16 Sep 2023 15:39:49 -0500
Robert Baer  wrote:

> When doing Anova using the car package,  I get a print warning that
> is unexpected.  It seemingly involves have my flow cytometry factor
> levels named CD271+ and CD171-.  But I am not sure this warning
> should be intended behavior.  Any explanation about whether I'm doing
> something wrong? Why can't I have CD271+ and CD271- as factor levels?
>  Its legal text isn't it?
> 
> library(car) mod = aov(Viability ~ Treatment*Expression, data = dat1) 
> Anova(mod, type =2) Anova Table (Type II tests) Response: Viability
> Sum Sq Df F value Pr(>F) Treatment 19447.3 3 9.2942 0.0002927 ***
> Expression 2669.8 1 3.8279 0.0621394 . Treatment:Expression 2226.3 3
> 1.0640 0.3828336 Residuals 16739.3 24 --- Signif. codes: 0 ‘***’
> 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Warning messages: 1: 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 2: 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 3: 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
> 
> 
> The code to reproduce:
> 
> ```
> 
> 
> dat1 <-structure(list(Treatment = structure(c(1L, 1L, 1L, 1L, 3L, 1L,
>    1L, 1L, 1L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
>    3L, 3L, 4L, 4L, 4L,
> 4L, 4L, 4L, 4L, 4L), levels = c("Control",
> "Dabrafenib", "Trametinib", "Combination"), class = "factor"),
>    Expression = structure(c(2L, 2L, 2L, 2L, 2L,
> 1L, 1L, 1L,
>     1L, 2L, 2L, 2L, 2L,
> 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
>     1L, 2L, 2L, 2L, 2L,
> 1L, 1L, 1L, 1L), levels = c("CD271-",
> "CD271+"), class = "factor"),
>    Viability = c(128.329809725159,
> 24.2360176821065, 76.3597924274457, 11.0128771862387,
> 21.4683836248318, 140.784162982894, 87.4303286565443, 
> 118.181818181818, 53.603690178743,
>      51.2973284643475,
> 5.47760907168941, 27.1574091870075, 50.8360561214684,
>      56.5250816836441,
> 28.6949836632712, 93.2731116663463, 71.900826446281,
>      32.2314049586777,
> 24.2360176821065, 27.4649240822602, 24.0822602344801,
>      26.542379396502,
> 30.693830482414, 27.772438977513, 13.4729963482606,
>      8.24524312896406,
> 18.5469921199308, 13.9342686911397, 13.3192389006342,
>      19.9308091485681,
> 17.6244474341726, 16.2406304055353)),
>   row.names = c(NA,
>     -32L),
>   class = c("tbl_df", "tbl", "data.frame"))
> 
> mod = aov(Viability ~ Treatment*Expression, data = dat1)
> summary(mod)
> library(car)
> Anova(mod, type =2)
> 
> ```

There seems to be something wrong in your presentation of the data.
When I copied and pasted the code I got an error:

> Error: unexpected input in:
> "dat1 <-structure(list(Treatment = structure(c(1L, 1L, 1L, 1L, 3L, 1L,
>   "

I don't really understand the provenance of the error, but after some
fiddling around I managed to create a structure "dat1":


> dput(dat1)
> structure(list(Treatment = structure(c(1L, 1L, 1L, 1L, 3L, 1L, 
> 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 
> 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), levels = c("Control", 
> "Dabrafenib", "Trametinib", "Combination"), class = "factor"), 
> Expression = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 
> 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 
> 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), levels = c("CD271-", 
> "CD271+"), class = "factor"), Viability = c(128.329809725159, 
> 24.2360176821065, 76.3597924274457, 11.0128771862387,
> 21.4683836248318, 140.784162982894, 87.4303286565443,
> 118.181818181818, 53.603690178743, 51.2973284643475,
> 5.47760907168941, 27.1574091870075, 50.8360561214684,
> 56.5250816836441, 28.6949836632712, 93.2731116663463,
> 71.900826446281, 32.2314049586777, 24.2360176821065,> mod = aov(Viability ~ 
> Treatment*Expression, data = dat1)
> summary(mod)
> library(car)
> Anova(mod, type =2)
> 27.4649240822602, 24.0822602344801, 26.542379396502, 30.693830482414,
> 27.772438977513, 13.4729963482606, 8.24524312896406,
> 18.5469921199308, 13.9342686911397, 13.3192389006342,
> 9.9308091485681, 17.6244474341726, 16.2406304055353)), row.names =
> c(NA, -32L), class = c("tbl_df", "tbl", "data.frame"))

Then doing 

> mod 

Re: [R] Print hypothesis warning- Car package

2023-09-16 Thread Bert Gunter
The factor names are legal but the Warnings tell you pretty clearly that
Car doesn't like such things. So why don't you just use something else that
is more conventional.

-- Bert

On Sat, Sep 16, 2023 at 1:40 PM Robert Baer  wrote:

> When doing Anova using the car package,  I get a print warning that is
> unexpected.  It seemingly involves have my flow cytometry factor levels
> named CD271+ and CD171-.  But I am not sure this warning should be
> intended behavior.  Any explanation about whether I'm doing something
> wrong? Why can't I have CD271+ and CD271- as factor levels?  Its legal
> text isn't it?
>
> library(car) mod = aov(Viability ~ Treatment*Expression, data = dat1)
> Anova(mod, type =2) Anova Table (Type II tests) Response: Viability Sum
> Sq Df F value Pr(>F) Treatment 19447.3 3 9.2942 0.0002927 *** Expression
> 2669.8 1 3.8279 0.0621394 . Treatment:Expression 2226.3 3 1.0640
> 0.3828336 Residuals 16739.3 24 --- Signif. codes: 0 ‘***’ 0.001 ‘**’
> 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Warning messages: 1: 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 2: 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 3: 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
>
>
> The code to reproduce:
>
> ```
>
>
> dat1 <-structure(list(Treatment = structure(c(1L, 1L, 1L, 1L, 3L, 1L,
>1L, 1L, 1L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
>3L, 3L, 4L, 4L, 4L, 4L,
> 4L, 4L, 4L, 4L), levels = c("Control",
> "Dabrafenib", "Trametinib", "Combination"), class = "factor"),
>Expression = structure(c(2L, 2L, 2L, 2L, 2L, 1L,
> 1L, 1L,
> 1L, 2L, 2L, 2L, 2L, 1L,
> 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
> 1L, 2L, 2L, 2L, 2L, 1L,
> 1L, 1L, 1L), levels = c("CD271-",
> "CD271+"), class = "factor"),
>Viability = c(128.329809725159, 24.2360176821065,
> 76.3597924274457, 11.0128771862387, 21.4683836248318,
>  140.784162982894, 87.4303286565443,
> 118.181818181818, 53.603690178743,
>  51.2973284643475, 5.47760907168941,
> 27.1574091870075, 50.8360561214684,
>  56.5250816836441, 28.6949836632712,
> 93.2731116663463, 71.900826446281,
>  32.2314049586777, 24.2360176821065,
> 27.4649240822602, 24.0822602344801,
>  26.542379396502, 30.693830482414,
> 27.772438977513, 13.4729963482606,
>  8.24524312896406, 18.5469921199308,
> 13.9342686911397, 13.3192389006342,
>  19.9308091485681, 17.6244474341726,
> 16.2406304055353)),
>   row.names = c(NA,
> -32L),
>   class = c("tbl_df", "tbl", "data.frame"))
>
> mod = aov(Viability ~ Treatment*Expression, data = dat1)
> summary(mod)
> library(car)
> Anova(mod, type =2)
>
> ```
>
>
> > sessionInfo() R version 4.3.1 (2023-06-16 ucrt) Platform:
> x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build
> 25951) Matrix products: default locale: [1] LC_COLLATE=English_United
> States.utf8 LC_CTYPE=English_United States.utf8
> LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C
> LC_TIME=English_United States.utf8 time zone: America/Chicago tzcode
> source: internal attached base packages: [1] stats graphics grDevices
> utils datasets methods base other attached packages: [1] car_3.1-2
> carData_3.0-5 tidyr_1.3.0 readr_2.1.4 readxl_1.4.3 ggplot2_3.4.3
> dplyr_1.1.3 loaded via a namespace (and not attached): [1] crayon_1.5.2
> vctrs_0.6.3 cli_3.6.1 rlang_1.1.1 purrr_1.0.2 generics_0.1.3
> labeling_0.4.3 [8] bit_4.0.5 glue_1.6.2 colorspace_2.1-0 hms_1.1.3
> scales_1.2.1 fansi_1.0.4 grid_4.3.1 [15] cellranger_1.1.0 abind_1.4-5
> munsell_0.5.0 tibble_3.2.1 tzdb_0.4.0 lifecycle_1.0.3 compiler_4.3.1
> [22] pkgconfig_2.0.3 rstudioapi_0.15.0 farver_2.1.1 R6_2.5.1
> tidyselect_1.2.0 utf8_1.2.3 parallel_4.3.1 [29] vroom_1.6.3 pillar_1.9.0
> magrittr_2.0.3 bit64_4.0.5 tools_4.3.1 withr_2.5.0 gtable_0.3.4
>
>
> [[alternative HTML version deleted]]
>
> __
> 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, 

[R] Print hypothesis warning- Car package

2023-09-16 Thread Robert Baer
When doing Anova using the car package,  I get a print warning that is 
unexpected.  It seemingly involves have my flow cytometry factor levels 
named CD271+ and CD171-.  But I am not sure this warning should be 
intended behavior.  Any explanation about whether I'm doing something 
wrong? Why can't I have CD271+ and CD271- as factor levels?  Its legal 
text isn't it?

library(car) mod = aov(Viability ~ Treatment*Expression, data = dat1) 
Anova(mod, type =2) Anova Table (Type II tests) Response: Viability Sum 
Sq Df F value Pr(>F) Treatment 19447.3 3 9.2942 0.0002927 *** Expression 
2669.8 1 3.8279 0.0621394 . Treatment:Expression 2226.3 3 1.0640 
0.3828336 Residuals 16739.3 24 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 
0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Warning messages: 1: 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 2: 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 3: 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


The code to reproduce:

```


dat1 <-structure(list(Treatment = structure(c(1L, 1L, 1L, 1L, 3L, 1L,
   1L, 1L, 1L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
   3L, 3L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L), levels = c("Control",
"Dabrafenib", "Trametinib", "Combination"), class = "factor"),
   Expression = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L,
    1L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
    1L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 1L), levels = c("CD271-",
"CD271+"), class = "factor"),
   Viability = c(128.329809725159, 24.2360176821065, 
76.3597924274457, 11.0128771862387, 21.4683836248318,
     140.784162982894, 87.4303286565443, 
118.181818181818, 53.603690178743,
     51.2973284643475, 5.47760907168941, 
27.1574091870075, 50.8360561214684,
     56.5250816836441, 28.6949836632712, 
93.2731116663463, 71.900826446281,
     32.2314049586777, 24.2360176821065, 
27.4649240822602, 24.0822602344801,
     26.542379396502, 30.693830482414, 
27.772438977513, 13.4729963482606,
     8.24524312896406, 18.5469921199308, 
13.9342686911397, 13.3192389006342,
     19.9308091485681, 17.6244474341726, 
16.2406304055353)),
  row.names = c(NA,
    -32L),
  class = c("tbl_df", "tbl", "data.frame"))

mod = aov(Viability ~ Treatment*Expression, data = dat1)
summary(mod)
library(car)
Anova(mod, type =2)

```


> sessionInfo() R version 4.3.1 (2023-06-16 ucrt) Platform: 
x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 
25951) Matrix products: default locale: [1] LC_COLLATE=English_United 
States.utf8 LC_CTYPE=English_United States.utf8 
LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C 
LC_TIME=English_United States.utf8 time zone: America/Chicago tzcode 
source: internal attached base packages: [1] stats graphics grDevices 
utils datasets methods base other attached packages: [1] car_3.1-2 
carData_3.0-5 tidyr_1.3.0 readr_2.1.4 readxl_1.4.3 ggplot2_3.4.3 
dplyr_1.1.3 loaded via a namespace (and not attached): [1] crayon_1.5.2 
vctrs_0.6.3 cli_3.6.1 rlang_1.1.1 purrr_1.0.2 generics_0.1.3 
labeling_0.4.3 [8] bit_4.0.5 glue_1.6.2 colorspace_2.1-0 hms_1.1.3 
scales_1.2.1 fansi_1.0.4 grid_4.3.1 [15] cellranger_1.1.0 abind_1.4-5 
munsell_0.5.0 tibble_3.2.1 tzdb_0.4.0 lifecycle_1.0.3 compiler_4.3.1 
[22] pkgconfig_2.0.3 rstudioapi_0.15.0 farver_2.1.1 R6_2.5.1 
tidyselect_1.2.0 utf8_1.2.3 parallel_4.3.1 [29] vroom_1.6.3 pillar_1.9.0 
magrittr_2.0.3 bit64_4.0.5 tools_4.3.1 withr_2.5.0 gtable_0.3.4


[[alternative HTML version deleted]]

__
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.