Re: [R] Hadamard transformation

2023-09-18 Thread mohan radhakrishnan
Hello,
  It really helped.

Thanks.

On Mon, Sep 18, 2023 at 11:46 PM Rui Barradas  wrote:

> Às 18:45 de 18/09/2023, mohan radhakrishnan escreveu:
> > Hello,
> >
> > I am attempting to port the R code which is an answer to
> >
> https://codegolf.stackexchange.com/questions/194229/implement-the-2d-hadamard-transform
> >
> >
> > function(M){for(i in 1:log2(nrow(M)))T=T%x%matrix(1-2*!3:0,2)/2;
> print(T);
> > T%*%M%*%T}
> >
> > The code, 3 inputs and the corresponding outputs are shown in
> >
> https://tio.run/##PYyxCsIwFEX3fkUcAu@VV7WvcSl2dOwi8QNqNSXQJhAqrYjfHoOIwz3D4XBDNOJYiGgerp@td9Diy/gAVlgnynr0A4MLfkkeUTdarnLq5mBXKAvON1W9J8YdZ1rmsk3T72jgV/TAVBHTAROYrs/00@jz5YSY/aOSFKmvGP1yD9sk4Wa7ARSSRowf
> >
> > These are the inputs.
> >
> > f(matrix(c(2,3,2,5),2,2,byrow=TRUE))
> > f(matrix(1,4,4))
> > f(lower.tri(diag(4),T))
> >
> > My attempt to port this R code to another framework(Tensorflow) was only
> > partially successful
> > because I didn't fully understand the cryptic R code. The second input
> > shown above works after
> > hacking Tensorflow for a long time.
> >
> > My question is this. Can anyone code this in a clear way so that I can
> > understand ? I understand
> > Kronecker Product and matrix multiplication and can port that code but I
> am
> > missing something as the same ported code does not work for all inputs.
> >
> > Thanks,
> > Mohan
> >
> >   [[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.
> Hello,
>
> Is this what you want?
> (I have changed the notation a bit.)
>
>
> H <- function(M){
>H0 <- 1
>Transf <- matrix(c(1, 1, 1, -1), 2L)
>for(i in 1:log2(nrow(M))) {
>  H0 <- H0 %x% Transf/2
>}
>H0 %*% M %*% H0
> }
>
> x <- matrix(c(2, 3, 2, 5), 2, 2, byrow = TRUE)
> y <- matrix(1, 4, 4)
> z <- lower.tri(diag(4), TRUE)
> z[] <- apply(z, 2, as.integer)
> H(x)
> H(y)
> H(z)
>
>
>
> Hope this helps,
>
> Rui Barradas
>
>

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


[R] overlay shaded area in base r plot

2023-09-18 Thread ani jaya
Dear R-Help,

I try to overlay two standard deviations from two means. How to change
the overlaid area between two shaded areas into a specific color or
maybe a soft color in a plot?

> dput(mean1[1:20])
c(122.194495954369, 118.955256282505, 115.540991140893, 113.116216840647,
111.24053267553, 109.827890459103, 108.523652505026, 107.033183023752,
105.259229707182, 103.124055471975, 100.877524901322, 98.6376579858244,
96.5156796979913, 94.6968535964952, 93.0502858942909, 91.5977750931902,
90.2651576455091, 89.0734094965085, 87.9562971122031, 86.9443758094494
)

> dput(mean2[1:20])
c(85.9733226064336, 85.1790888261485, 84.4436873347186, 83.8339820163413,
83.2527178882373, 82.7270110163027, 82.2807280513966, 81.9025314782845,
81.4641947900397, 81.0208948190769, 80.5647455355762, 80.0587583244909,
78.9354501839752, 78.4263183538841, 78.3688690670842, 77.9632850076303,
77.6888937972956, 77.5689173832678, 77.5860621564674, 77.6375257226031

> dput(sd1[1:20])
c(17.0473968859792, 19.7055838512895, 20.0280169279762, 19.5651973323109,
19.4292448372276, 19.0540881390057, 18.9295826565011, 18.7039744205801,
18.688319090752, 18.6946307822843, 18.7427879417687, 18.8069804986113,
18.8794754969972, 18.9830959093513, 19.0754455885966, 19.1360320444124,
19.0546404913351, 19.1280788210156, 19.2014747953522, 19.2456454651155
)

> dput(sd2[1:20])
c(19.2537538439847, 19.2462114145511, 19.2253213677253, 19.2476344684752,
19.2494964552016, 19.2871242318276, 19.2695982918065, 19.261879086708,
19.3410606442566, 19.3257171172684, 19.5029937941038, 19.5286520380856,
19.472587329424, 19.4815048434245, 19.3056947381611, 19.2193415347369,
19.1367354761276, 19.062832883228, 19.0123017669597, 18.9504334825052
)

what i've done:

plot(mean1[1:20],type="l", ylim=c(170,60),las=1,
 xlab="Data",ylab=expression(bold("Val")),cex.axis=1.2,font=2,
cex.lab=1.2,lwd=4)
polygon(c(1:20,20:1),c(mean1[1:20]+sd1[1:20],mean1[20:1]),col="lightblue")
polygon(c(1:20,20:1),c(mean1[1:20]-sd1[1:20],mean1[20:1]),col="lightblue")
polygon(c(1:20,20:1),c(mean2[1:20]+sd2[1:20],mean2[20:1]),col="lightyellow")
polygon(c(1:20,20:1),c(mean2[1:20]-sd2[1:20],mean2[20:1]),col="lightyellow")
lines(mean1,lty=1,lwd=2,col="blue")
lines(mean2,lty=1,lwd=2,col="yellow")

what i want is like in this source, but using base r plot if possible:

https://datascience.stackexchange.com/questions/30913/plots-with-shaded-standard-deviation

Any help and suggestion is very welcome!

Best,
Ani

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


Re: [R] Hadamard transformation

2023-09-18 Thread Rui Barradas

Às 18:45 de 18/09/2023, mohan radhakrishnan escreveu:

Hello,

I am attempting to port the R code which is an answer to
https://codegolf.stackexchange.com/questions/194229/implement-the-2d-hadamard-transform


function(M){for(i in 1:log2(nrow(M)))T=T%x%matrix(1-2*!3:0,2)/2; print(T);
T%*%M%*%T}

The code, 3 inputs and the corresponding outputs are shown in
https://tio.run/##PYyxCsIwFEX3fkUcAu@VV7WvcSl2dOwi8QNqNSXQJhAqrYjfHoOIwz3D4XBDNOJYiGgerp@td9Diy/gAVlgnynr0A4MLfkkeUTdarnLq5mBXKAvON1W9J8YdZ1rmsk3T72jgV/TAVBHTAROYrs/00@jz5YSY/aOSFKmvGP1yD9sk4Wa7ARSSRowf

These are the inputs.

f(matrix(c(2,3,2,5),2,2,byrow=TRUE))
f(matrix(1,4,4))
f(lower.tri(diag(4),T))

My attempt to port this R code to another framework(Tensorflow) was only
partially successful
because I didn't fully understand the cryptic R code. The second input
shown above works after
hacking Tensorflow for a long time.

My question is this. Can anyone code this in a clear way so that I can
understand ? I understand
Kronecker Product and matrix multiplication and can port that code but I am
missing something as the same ported code does not work for all inputs.

Thanks,
Mohan

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

Hello,

Is this what you want?
(I have changed the notation a bit.)


H <- function(M){
  H0 <- 1
  Transf <- matrix(c(1, 1, 1, -1), 2L)
  for(i in 1:log2(nrow(M))) {
H0 <- H0 %x% Transf/2
  }
  H0 %*% M %*% H0
}

x <- matrix(c(2, 3, 2, 5), 2, 2, byrow = TRUE)
y <- matrix(1, 4, 4)
z <- lower.tri(diag(4), TRUE)
z[] <- apply(z, 2, as.integer)
H(x)
H(y)
H(z)



Hope this helps,

Rui Barradas

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


[R] Post Details for Two ASA Awards

2023-09-18 Thread P. D. Waggoner
Please post to R-help:


Hi all -

I wanted to share a message putting TWO upcoming awards on your radar. These 
are jointly sponsored by the Graphics and Computing sections of the American 
Statistical Association (ASA): 

The student Paper Award. Full details here: 
https://community.amstat.org/jointscsg-section/awards/student-paper-competition 
All application materials MUST BE RECEIVED by 5:00 PM EST, Thursday, December 
15, 2023. The submission window will be open on December 1, 2023. They will be 
reviewed by the Student Paper Competition Award committee of the Statistical 
Computing and Graphics Sections. The selection criteria used by the committee 
will include innovation and significance of the contribution as well as the 
professional quality of the manuscript. Award announcements will be made by 
January 15, 2024. 

John M. Chambers Statistical Software Award. Full details here: 
https://community.amstat.org/jointscsg-section/awards/john-m-chambers
All application materials MUST BE RECEIVED by 5:00 PM EST, Thursday, December 
15, 2023. The submission window will be open at http://asa.stat.uconn.edu 
 on December 1, 2023. The entries will be judged on 
a variety of dimensions, including the importance and relevance for statistical 
practice of the tasks performed by the software, ease of use, clarity of 
description, elegance and availability for use by the statistical community. 
Preference will be given to those entries that are grounded in software design 
rather than calculation. Award announcements will be made by January 15, 2024.

I am chairing the awards process (and one of the committees) this term and 
would be happy to answer any questions. Thanks!

Philip Waggoner

https://pdwaggoner.github.io/
[[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.


[R] Hadamard transformation

2023-09-18 Thread mohan radhakrishnan
Hello,

I am attempting to port the R code which is an answer to
https://codegolf.stackexchange.com/questions/194229/implement-the-2d-hadamard-transform


function(M){for(i in 1:log2(nrow(M)))T=T%x%matrix(1-2*!3:0,2)/2; print(T);
T%*%M%*%T}

The code, 3 inputs and the corresponding outputs are shown in
https://tio.run/##PYyxCsIwFEX3fkUcAu@VV7WvcSl2dOwi8QNqNSXQJhAqrYjfHoOIwz3D4XBDNOJYiGgerp@td9Diy/gAVlgnynr0A4MLfkkeUTdarnLq5mBXKAvON1W9J8YdZ1rmsk3T72jgV/TAVBHTAROYrs/00@jz5YSY/aOSFKmvGP1yD9sk4Wa7ARSSRowf

These are the inputs.

f(matrix(c(2,3,2,5),2,2,byrow=TRUE))
f(matrix(1,4,4))
f(lower.tri(diag(4),T))

My attempt to port this R code to another framework(Tensorflow) was only
partially successful
because I didn't fully understand the cryptic R code. The second input
shown above works after
hacking Tensorflow for a long time.

My question is this. Can anyone code this in a clear way so that I can
understand ? I understand
Kronecker Product and matrix multiplication and can port that code but I am
missing something as the same ported code does not work for all inputs.

Thanks,
Mohan

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


Re: [R] halting with errors

2023-09-18 Thread Duncan Murdoch
You can use try() or tryCatch().  The former is simpler, the latter is 
more flexible.


For example:

  result <- 
try(read_html(“https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15016/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code”))

  if (inherits(result, "try-error"))
message("year 2015 doesn't have data")
  else {
 ... do the usual stuff ...
  }



On 18/09/2023 12:54 p.m., Nick Wray wrote:

Hello  I am downloading flow data from the UK national river flow archive
(NRFA).  I have code which works (thanks to previous help on r-help) but
the problem is that before I make a call for the data for that particular
year I don’t know whether the data exists for that particular year and
catchment

This is a typical url  and it works if you paste it into the top line on a
web page.  15007 is the code for the Pitnacree catchment in Scotland

https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15007/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code

It works in R as well with

page<-read_html("
https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15007/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code
")

 yiq<-page |>

   html_element("table") |>

   html_table(header = TRUE) |>

   (\(x) {

 hdr <- unlist(x[3, ])

 y <- x[-(1:3), ]

 names(y) <- hdr

 y

   })()

 print(nrow(yiq))

 yiq



But if I try to move onto another catchment Kenmore 15006

eg



https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15016/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code

So in R

read_html(“
https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15016/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code
”)

This doesn’t work because there’s no data for this catchment for this year

I am pasting in different years (from say 1961 to 2017) in a loop (and this
works if the data sets exist) but the problem is that if the data is not
there (and there doesn’t seem to be a way of determining this elsewhere)
and so there’s nothing to read, an error message comes up and halts the
program loop, so that manually I have to reset the url to try to find out
whether there is data for the next year.

What I’d like to know is whether there’s any way in R of seeing whether the
data set exists, and if doesn’t, moving on the next possibility without
halting…

Any thoughts appreciated

Thanks Nick Wray

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


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


[R] halting with errors

2023-09-18 Thread Nick Wray
Hello  I am downloading flow data from the UK national river flow archive
(NRFA).  I have code which works (thanks to previous help on r-help) but
the problem is that before I make a call for the data for that particular
year I don’t know whether the data exists for that particular year and
catchment

This is a typical url  and it works if you paste it into the top line on a
web page.  15007 is the code for the Pitnacree catchment in Scotland

https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15007/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code

It works in R as well with

page<-read_html("
https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15007/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code
")

yiq<-page |>

  html_element("table") |>

  html_table(header = TRUE) |>

  (\(x) {

hdr <- unlist(x[3, ])

y <- x[-(1:3), ]

names(y) <- hdr

y

  })()

print(nrow(yiq))

yiq



But if I try to move onto another catchment Kenmore 15006

eg



https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15016/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code

So in R

read_html(“
https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters&type=queryServices&datasource=0&request=getTimeseriesValues&ts_path=1/15016/Q/15m.Cmd&from=2015-01-01&to=2015-01-31&returnfields=Timestamp,Value,Quality%20Code
”)

This doesn’t work because there’s no data for this catchment for this year

I am pasting in different years (from say 1961 to 2017) in a loop (and this
works if the data sets exist) but the problem is that if the data is not
there (and there doesn’t seem to be a way of determining this elsewhere)
and so there’s nothing to read, an error message comes up and halts the
program loop, so that manually I have to reset the url to try to find out
whether there is data for the next year.

What I’d like to know is whether there’s any way in R of seeing whether the
data set exists, and if doesn’t, moving on the next possibility without
halting…

Any thoughts appreciated

Thanks Nick Wray

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


Re: [R] Print hypothesis warning- Car package

2023-09-18 Thread John Fox

Hi Peter,

On 2023-09-18 10:08 a.m., peter dalgaard wrote:

Caution: External email.


Also, I would guess that the code precedes the use of backticks in non-syntactic names. 


Indeed, by more than a decade (though modified in the interim).


Could they be deployed here?


I don't think so, at least not without changing how the function works.

The problem doesn't occur when the hypothesis is specified symbolically 
as a character vector, including in equation form, only when the 
hypothesis matrix is given directly, in which case linearHypothesis() 
tries to construct the equation-form representation, again as character 
vectors. Its inability to do so when the coefficient names include 
arithmetic operators doesn't, I think, require a warning or even a 
message: the symbolic representation of the hypothesis can simply be 
omitted. The numeric results reported are entirely unaffected.


I've made this change and will commit it to the next version of the car 
package.


Thank you for the suggestion,
 John




- Peter


On 17 Sep 2023, at 16:43 , 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  32226.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,]00000100
[2,]00000010
[3,]00000001


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

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://www.john-fox.ca/
On 2023-09-16 4:39 p.m., Robert Baer wrote:

Caution: External email.
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 o

Re: [R] Print hypothesis warning- Car package

2023-09-18 Thread peter dalgaard
Also, I would guess that the code precedes the use of backticks in 
non-syntactic names. Could they be deployed here?

- Peter

> On 17 Sep 2023, at 16:43 , 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  32226.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,]00000100
> [2,]00000010
> [3,]00000001
> 
> > 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  32226.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
> 
> -- 
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> web: https://www.john-fox.ca/
> On 2023-09-16 4:39 p.m., Robert Baer wrote:
>> Caution: External email.
>> 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,
>>