Re: [R] pairwise.var.test

2022-11-02 Thread Deepayan Sarkar
On Mon, Oct 31, 2022 at 5:30 AM Thomas Subia via R-help
 wrote:
>
> Colleagues,
>
> Thank you all for the timely suggestions. That is appreciated.
>
> What I am really looking for a way to identify difference in group level 
> variance by using multiple comparison intervals. Minitab displays those 
> results in a graph.
>
> This method is described in:
> https://support.minitab.com/en-us/minitab/20/media/pdfs/translate/Multiple_Comparisons_Method_Test_for_Equal_Variances.pdf
>
> I was hoping that R had something similar.

Perhaps you are looking for something like the plot produced by

example(TukeyHSD)

For this you would need confidence intervals for each pairwise
comparison, not just the p-values. Once you have those, recreating the
plot should not be difficult, but I don't know if there is any package
that already does this for you. E.g., car::leveneTest() etc. are
designed for multiple groups and won't give you confidence intervals.

Best,
-Deepayan

>
> I tried a Google search on this but to no avail.
>
> Thomas Subia
>
>
>
>
>
>
> On Sunday, October 30, 2022 at 03:44:54 PM PDT, Rui Barradas 
>  wrote:
>
>
>
>
>
> Às 21:47 de 30/10/2022, Jim Lemon escreveu:
> > Hi Thomas,
> > I have assumed the format of your p-value matrix. This may require
> > some adjustment.
> >
> >A  B  CD  E  F
> > A 1  0.74640.01870.0865  0.0122  0.4693
> > B 0.74641  0.03580.1502  0.0173  0.3240
> > C 0.01870.035810.5131  0.7185  0.0050
> > D 0.08650.15020.51311  0.3240  0.0173
> > E 0.01220.01730.71850.3240  1  0.0029
> > F 0.46930.32400.00500.0173  0.0029  1
> >
> > pvar.mat<-as.matrix(read.table(text=
> >  "1  0.74640.01870.0865  0.0122  0.4693
> >  0.74641  0.03580.1502  0.0173  0.3240
> >  0.01870.035810.5131  0.7185  0.0050
> >  0.08650.15020.51311  0.3240  0.0173
> >  0.01220.01730.71850.3240  1  0.0029
> >  0.46930.32400.00500.0173  0.0029  1",
> >  stringsAsFactors=FALSE))
> > rownames(pvar.mat)<-colnames(pvar.mat)<-LETTERS[1:6]
> > pvar.col<-matrix(NA,nrow=6,ncol=6)
> > pvar.col[pvar.mat < 1]<-"red"
> > pvar.col[pvar.mat < 0.05]<-"orange"
> > pvar.col[pvar.mat < 0.01]<-"green"
> > library(plotrix)
> > par(mar=c(6,4,4,2))
> > color2D.matplot(pvar.mat,cellcolors=pvar.col,
> >  main="P-values for matrix",axes=FALSE)
> > axis(1,at=seq(0.5,5.5,by=1),labels=LETTERS[1:6])
> > axis(2,at=seq(0.5,5.5,by=1),labels=rev(LETTERS[1:6]))
> > color.legend(0,-1.3,2.5,-0.7,c("NA","NS","<0.05","<0.01"),
> >  rect.col=c(NA,"red","orange","green"))
> >
> > Jim
> >
> > On Mon, Oct 31, 2022 at 6:34 AM Thomas Subia via R-help
> >  wrote:
> >>
> >> Colleagues,
> >>
> >> The RVAideMemoire package has a pairwise variance test which one can use 
> >> to identify variance differences between group levels.
> >>
> >> Using the example from this package, 
> >> pairwise.var.test(InsectSprays$count,InsectSprays$spray), we get this 
> >> output:
> >>
> >>  Pairwise comparisons using F tests to compare two variances
> >>
> >> data:  InsectSprays$count and InsectSprays$spray
> >>
> >>A  BCDE
> >> B 0.7464-  -  -  -
> >> C 0.01870.0358-  -  -
> >> D 0.08650.15020.5131--
> >> E 0.01220.01730.71850.3240-
> >> F 0.46930.32400.00500.01730.0029
> >>
> >> P value adjustment method: fdr
> >>
> >> Is there a way to graph the pairwise variance differences so that users 
> >> can easily identify the statistically significant variance differences 
> >> between group levels?
> >>
> >> I can do this using Minitab but I'd prefer using R for this.
> >>
> >> Thomas Subia
> >>
> >> __
> >> 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.
>
>
> Hello,
>
> With Jim's data creation code, here is a ggplot graph.
>
> First coerce to data.frame, then reshape to long format.
> Now bin the p-values with the cutpoints 0.01, 0.05 and 1. This is dne
> with ?findInterval.
>
> The colors are assigned in the plot code, based on the binned p.values
> above.
>
>
> library(ggplot2)
>
> pvar.mat |> as.data.frame() -> 

Re: [R] pairwise.var.test

2022-10-30 Thread Thomas Subia via R-help
Colleagues,

Thank you all for the timely suggestions. That is appreciated.

What I am really looking for a way to identify difference in group level 
variance by using multiple comparison intervals. Minitab displays those results 
in a graph.

This method is described in:
https://support.minitab.com/en-us/minitab/20/media/pdfs/translate/Multiple_Comparisons_Method_Test_for_Equal_Variances.pdf

I was hoping that R had something similar.

I tried a Google search on this but to no avail.

Thomas Subia






On Sunday, October 30, 2022 at 03:44:54 PM PDT, Rui Barradas 
 wrote: 





Às 21:47 de 30/10/2022, Jim Lemon escreveu:
> Hi Thomas,
> I have assumed the format of your p-value matrix. This may require
> some adjustment.
> 
>    A          B          C        D          E          F
> A 1          0.7464    0.0187    0.0865      0.0122      0.4693
> B 0.7464    1          0.0358    0.1502      0.0173      0.3240
> C 0.0187    0.0358    1        0.5131      0.7185      0.0050
> D 0.0865    0.1502    0.5131    1          0.3240      0.0173
> E 0.0122    0.0173    0.7185    0.3240      1          0.0029
> F 0.4693    0.3240    0.0050    0.0173      0.0029      1
> 
> pvar.mat<-as.matrix(read.table(text=
>  "1          0.7464    0.0187    0.0865      0.0122      0.4693
>  0.7464    1          0.0358    0.1502      0.0173      0.3240
>  0.0187    0.0358    1        0.5131      0.7185      0.0050
>  0.0865    0.1502    0.5131    1          0.3240      0.0173
>  0.0122    0.0173    0.7185    0.3240      1          0.0029
>  0.4693    0.3240    0.0050    0.0173      0.0029      1",
>  stringsAsFactors=FALSE))
> rownames(pvar.mat)<-colnames(pvar.mat)<-LETTERS[1:6]
> pvar.col<-matrix(NA,nrow=6,ncol=6)
> pvar.col[pvar.mat < 1]<-"red"
> pvar.col[pvar.mat < 0.05]<-"orange"
> pvar.col[pvar.mat < 0.01]<-"green"
> library(plotrix)
> par(mar=c(6,4,4,2))
> color2D.matplot(pvar.mat,cellcolors=pvar.col,
>  main="P-values for matrix",axes=FALSE)
> axis(1,at=seq(0.5,5.5,by=1),labels=LETTERS[1:6])
> axis(2,at=seq(0.5,5.5,by=1),labels=rev(LETTERS[1:6]))
> color.legend(0,-1.3,2.5,-0.7,c("NA","NS","<0.05","<0.01"),
>  rect.col=c(NA,"red","orange","green"))
> 
> Jim
> 
> On Mon, Oct 31, 2022 at 6:34 AM Thomas Subia via R-help
>  wrote:
>>
>> Colleagues,
>>
>> The RVAideMemoire package has a pairwise variance test which one can use to 
>> identify variance differences between group levels.
>>
>> Using the example from this package, 
>> pairwise.var.test(InsectSprays$count,InsectSprays$spray), we get this output:
>>
>>      Pairwise comparisons using F tests to compare two variances
>>
>> data:  InsectSprays$count and InsectSprays$spray
>>
>>    A              B            C            D            E
>> B 0.7464    -              -              -              -
>> C 0.0187    0.0358    -      -      -
>> D 0.0865    0.1502    0.5131    -            -
>> E 0.0122    0.0173    0.7185    0.3240    -
>> F 0.4693    0.3240    0.0050    0.0173    0.0029
>>
>> P value adjustment method: fdr
>>
>> Is there a way to graph the pairwise variance differences so that users can 
>> easily identify the statistically significant variance differences between 
>> group levels?
>>
>> I can do this using Minitab but I'd prefer using R for this.
>>
>> Thomas Subia
>>
>> __
>> 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.


Hello,

With Jim's data creation code, here is a ggplot graph.

First coerce to data.frame, then reshape to long format.
Now bin the p-values with the cutpoints 0.01, 0.05 and 1. This is dne 
with ?findInterval.

The colors are assigned in the plot code, based on the binned p.values 
above.


library(ggplot2)

pvar.mat |> as.data.frame() -> pvar.df
pvar.df$id <- row.names(pvar.df)

pvar.df |> tidyr::pivot_longer(-id, values_to = "p.value") -> pvar.long
i <- findInterval(pvar.long$p.value, c(0, 0.01, 0.05, 1))
pvar.long$p.value <- c("<0.01", "<0.05", "NS", "NA")[i]
clrs <- setNames(c("green", "blue", "lightgrey", "white"),
                  c("<0.01", "<0.05", "NS", "NA"))

ggplot(pvar.long, aes(id, name, fill = p.value)) +
  geom_tile() +
  scale_y_discrete(limits = rev) +
  scale_fill_manual(values = clrs) +
  theme_bw()


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 

Re: [R] pairwise.var.test

2022-10-30 Thread Rui Barradas

Às 21:47 de 30/10/2022, Jim Lemon escreveu:

Hi Thomas,
I have assumed the format of your p-value matrix. This may require
some adjustment.

   A  B  C D   E   F
A 1  0.7464 0.01870.0865  0.0122  0.4693
B 0.7464 1  0.03580.1502  0.0173  0.3240
C 0.0187 0.0358 1 0.5131  0.7185  0.0050
D 0.0865 0.1502 0.51311   0.3240  0.0173
E 0.0122 0.0173 0.71850.3240  1   0.0029
F 0.4693 0.3240 0.00500.0173  0.0029  1

pvar.mat<-as.matrix(read.table(text=
  "1  0.7464 0.01870.0865  0.0122  0.4693
  0.7464 1  0.03580.1502  0.0173  0.3240
  0.0187 0.0358 1 0.5131  0.7185  0.0050
  0.0865 0.1502 0.51311   0.3240  0.0173
  0.0122 0.0173 0.71850.3240  1   0.0029
  0.4693 0.3240 0.00500.0173  0.0029  1",
  stringsAsFactors=FALSE))
rownames(pvar.mat)<-colnames(pvar.mat)<-LETTERS[1:6]
pvar.col<-matrix(NA,nrow=6,ncol=6)
pvar.col[pvar.mat < 1]<-"red"
pvar.col[pvar.mat < 0.05]<-"orange"
pvar.col[pvar.mat < 0.01]<-"green"
library(plotrix)
par(mar=c(6,4,4,2))
color2D.matplot(pvar.mat,cellcolors=pvar.col,
  main="P-values for matrix",axes=FALSE)
axis(1,at=seq(0.5,5.5,by=1),labels=LETTERS[1:6])
axis(2,at=seq(0.5,5.5,by=1),labels=rev(LETTERS[1:6]))
color.legend(0,-1.3,2.5,-0.7,c("NA","NS","<0.05","<0.01"),
  rect.col=c(NA,"red","orange","green"))

Jim

On Mon, Oct 31, 2022 at 6:34 AM Thomas Subia via R-help
 wrote:


Colleagues,

The RVAideMemoire package has a pairwise variance test which one can use to 
identify variance differences between group levels.

Using the example from this package, 
pairwise.var.test(InsectSprays$count,InsectSprays$spray), we get this output:

 Pairwise comparisons using F tests to compare two variances

data:  InsectSprays$count and InsectSprays$spray

A  B C DE
B 0.7464 -   -  -  -
C 0.0187 0.0358 -  -   -
D 0.0865 0.1502 0.5131 - -
E 0.0122 0.0173 0.7185 0.3240-
F 0.4693 0.3240 0.0050 0.0173 0.0029

P value adjustment method: fdr

Is there a way to graph the pairwise variance differences so that users can 
easily identify the statistically significant variance differences between 
group levels?

I can do this using Minitab but I'd prefer using R for this.

Thomas Subia

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


Hello,

With Jim's data creation code, here is a ggplot graph.

First coerce to data.frame, then reshape to long format.
Now bin the p-values with the cutpoints 0.01, 0.05 and 1. This is dne 
with ?findInterval.


The colors are assigned in the plot code, based on the binned p.values 
above.



library(ggplot2)

pvar.mat |> as.data.frame() -> pvar.df
pvar.df$id <- row.names(pvar.df)

pvar.df |> tidyr::pivot_longer(-id, values_to = "p.value") -> pvar.long
i <- findInterval(pvar.long$p.value, c(0, 0.01, 0.05, 1))
pvar.long$p.value <- c("<0.01", "<0.05", "NS", "NA")[i]
clrs <- setNames(c("green", "blue", "lightgrey", "white"),
 c("<0.01", "<0.05", "NS", "NA"))

ggplot(pvar.long, aes(id, name, fill = p.value)) +
  geom_tile() +
  scale_y_discrete(limits = rev) +
  scale_fill_manual(values = clrs) +
  theme_bw()


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.


Re: [R] pairwise.var.test

2022-10-30 Thread Bert Gunter
Hard to know what you want. You may wish to take a look here for ideas:

https://r-graph-gallery.com/

Cheers,
Bert

On Sun, Oct 30, 2022 at 12:34 PM Thomas Subia via R-help <
r-help@r-project.org> wrote:

> Colleagues,
>
> The RVAideMemoire package has a pairwise variance test which one can use
> to identify variance differences between group levels.
>
> Using the example from this package,
> pairwise.var.test(InsectSprays$count,InsectSprays$spray), we get this
> output:
>
> Pairwise comparisons using F tests to compare two variances
>
> data:  InsectSprays$count and InsectSprays$spray
>
>A  B C DE
> B 0.7464 -   -  -  -
> C 0.0187 0.0358 -  -   -
> D 0.0865 0.1502 0.5131 - -
> E 0.0122 0.0173 0.7185 0.3240-
> F 0.4693 0.3240 0.0050 0.0173 0.0029
>
> P value adjustment method: fdr
>
> Is there a way to graph the pairwise variance differences so that users
> can easily identify the statistically significant variance differences
> between group levels?
>
> I can do this using Minitab but I'd prefer using R for this.
>
> Thomas Subia
>
> __
> 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.
>

[[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] pairwise.var.test

2022-10-30 Thread Jim Lemon
Hi Thomas,
I have assumed the format of your p-value matrix. This may require
some adjustment.

  A  B  C D   E   F
A 1  0.7464 0.01870.0865  0.0122  0.4693
B 0.7464 1  0.03580.1502  0.0173  0.3240
C 0.0187 0.0358 1 0.5131  0.7185  0.0050
D 0.0865 0.1502 0.51311   0.3240  0.0173
E 0.0122 0.0173 0.71850.3240  1   0.0029
F 0.4693 0.3240 0.00500.0173  0.0029  1

pvar.mat<-as.matrix(read.table(text=
 "1  0.7464 0.01870.0865  0.0122  0.4693
 0.7464 1  0.03580.1502  0.0173  0.3240
 0.0187 0.0358 1 0.5131  0.7185  0.0050
 0.0865 0.1502 0.51311   0.3240  0.0173
 0.0122 0.0173 0.71850.3240  1   0.0029
 0.4693 0.3240 0.00500.0173  0.0029  1",
 stringsAsFactors=FALSE))
rownames(pvar.mat)<-colnames(pvar.mat)<-LETTERS[1:6]
pvar.col<-matrix(NA,nrow=6,ncol=6)
pvar.col[pvar.mat < 1]<-"red"
pvar.col[pvar.mat < 0.05]<-"orange"
pvar.col[pvar.mat < 0.01]<-"green"
library(plotrix)
par(mar=c(6,4,4,2))
color2D.matplot(pvar.mat,cellcolors=pvar.col,
 main="P-values for matrix",axes=FALSE)
axis(1,at=seq(0.5,5.5,by=1),labels=LETTERS[1:6])
axis(2,at=seq(0.5,5.5,by=1),labels=rev(LETTERS[1:6]))
color.legend(0,-1.3,2.5,-0.7,c("NA","NS","<0.05","<0.01"),
 rect.col=c(NA,"red","orange","green"))

Jim

On Mon, Oct 31, 2022 at 6:34 AM Thomas Subia via R-help
 wrote:
>
> Colleagues,
>
> The RVAideMemoire package has a pairwise variance test which one can use to 
> identify variance differences between group levels.
>
> Using the example from this package, 
> pairwise.var.test(InsectSprays$count,InsectSprays$spray), we get this output:
>
> Pairwise comparisons using F tests to compare two variances
>
> data:  InsectSprays$count and InsectSprays$spray
>
>A  B C DE
> B 0.7464 -   -  -  -
> C 0.0187 0.0358 -  -   -
> D 0.0865 0.1502 0.5131 - -
> E 0.0122 0.0173 0.7185 0.3240-
> F 0.4693 0.3240 0.0050 0.0173 0.0029
>
> P value adjustment method: fdr
>
> Is there a way to graph the pairwise variance differences so that users can 
> easily identify the statistically significant variance differences between 
> group levels?
>
> I can do this using Minitab but I'd prefer using R for this.
>
> Thomas Subia
>
> __
> 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.