[R] Print hypothesis warning- Car package

Rolf Turner ro||turner @end|ng |rom po@teo@net
Sun Sep 17 02:27:57 CEST 2023


On Sat, 16 Sep 2023 15:39:49 -0500
Robert Baer <rbaer using atsu.edu> 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 = aov(Viability ~ Treatment*Expression, data = dat1)
> summary(mod)
> library(car)
> Anova(mod, type =2)

produced

>                      Df Sum Sq Mean Sq F value   Pr(>F)    
> Treatment             3  20004    6668   9.553 0.000246 ***
> Expression            1   2490    2490   3.568 0.071050 .  
> Treatment:Expression  3   2386     795   1.140 0.353142    
> Residuals            24  16751     698                     
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> Anova Table (Type II tests)
> 
> Response: Viability
>                       Sum Sq Df F value    Pr(>F)    
> Treatment            20003.9  3  9.5534 0.0002462 ***
> Expression            2490.3  1  3.5679 0.0710500 .  
> Treatment:Expression  2386.1  3  1.1395 0.3531420    
> Residuals            16751.3 24                      
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

No apparent problems that I can discern.  No warnings.

cheers,

Rolf Turner

P.S.

> sessionInfo()
> R version 4.3.1 (2023-06-16)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 22.04.3 LTS
> 
> Matrix products: default
> BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3 
> LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK
> version 3.10.0
> 
> locale:
>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
>  [3] LC_TIME=en_NZ.UTF-8        LC_COLLATE=en_GB.UTF-8    
>  [5] LC_MONETARY=en_NZ.UTF-8    LC_MESSAGES=en_GB.UTF-8   
>  [7] LC_PAPER=en_NZ.UTF-8       LC_NAME=C                 
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
> [11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C       
> 
> time zone: Pacific/Auckland
> tzcode source: system (glibc)
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>    
> 
> other attached packages:
> [1] car_3.0-7     carData_3.0-3 brev_0.0-8   
> 
> loaded via a namespace (and not attached):
>  [1] compiler_4.3.1    crayon_1.5.2      brio_1.1.3        zip_2.1.1
> [5] Rcpp_1.0.8.3      callr_3.7.3       readxl_1.3.1
> fastmap_1.1.1 [9] R6_2.5.1          openxlsx_4.1.4    curl_5.0.0
>   forcats_0.5.0 [13] tibble_3.2.1      desc_1.4.2
> rprojroot_2.0.3   nnet_7.3-19 [17] pillar_1.9.0      rlang_1.1.1
>  utf8_1.2.3        testthat_3.1.3 [21] stringi_1.7.8     cachem_1.0.8
>      fs_1.6.2          pkgload_1.2.4 [25] eglhmm_0.0-15
> memoise_2.0.1     cli_3.6.1         withr_2.5.0 [29] magrittr_2.0.3
>  ps_1.7.5          rio_0.5.29        processx_3.8.1 [33] haven_2.2.0
>      hms_1.1.3         remotes_2.4.2     devtools_2.4.2 [37]
> lifecycle_1.0.3   vctrs_0.6.2       prettyunits_1.1.1 glue_1.6.2 [41]
> data.table_1.12.8 cellranger_1.1.0  sessioninfo_1.2.2 abind_1.4-5
> [45] pkgbuild_1.4.0    fansi_1.0.4       colorspace_1.4-1
> foreign_0.8-79 [49] purrr_0.3.4       pkgconfig_2.0.3   tools_4.3.1
>     usethis_2.0.1 [53] ellipsis_0.3.2

R.T.

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
         +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619



More information about the R-help mailing list