[R] how to perform multiple comparison?

2016-05-19 Thread laomeng_3
Hi all:
As to the anova, we can perform multiple comparison via TukeyHSD.
But as to chi-square test for frequency table,how to perform multiple 
comparison?

For example, if I want to compare 3 samples' ratio(the data has 3 rows,each row 
corresponds to 1 sample,and has 2 columns,each column corresponds to positive 
and negative respectively).


dat<-matrix(c(6,30,8,23,14,3),nrow=3)
dat
  [,1] [,2]
[1,]6   23
[2,]   30   14
[3,]83



chisq.test(dat)

   Pearson's Chi-squared test

data:  dat
X-squared = 17.9066, df = 2, p-value = 0.0001293


The result shows that the difference between the 3 samples is significant.But 
if I want to perform multiple comparison to find out which pair of samples is  
significantly different,which function should be used?


Many thanks for your help.

My best



 ��ʦ
[[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] how to perform multiple comparison?

2016-05-20 Thread laomeng_3
thanks for your help.


发自 网易邮箱大师
On 2016-05-20 09:48 , David Winsemius Wrote:


> On May 19, 2016, at 5:19 PM, Jim Lemon  wrote:
>
> Hi laomeng_3,
> Have a look at the padjust function (stats).
>
> Jim
>
>
> On Fri, May 20, 2016 at 1:56 AM, laomeng_3  wrote:
>> Hi all:
>> As to the anova, we can perform multiple comparison via TukeyHSD.
>> But as to chi-square test for frequency table,how to perform multiple 
>> comparison?
>>
>> For example, if I want to compare 3 samples' ratio(the data has 3 rows,each 
>> row corresponds to 1 sample,and has 2 columns,each column corresponds to 
>> positive and negative respectively).
>>
>>
>> dat<-matrix(c(6,30,8,23,14,3),nrow=3)
>> dat
>>  [,1] [,2]
>> [1,]6   23
>> [2,]   30   14
>> [3,]83
>>
>>
>>
>> chisq.test(dat)
>>
>>   Pearson's Chi-squared test
>>
>> data:  dat
>> X-squared = 17.9066, df = 2, p-value = 0.0001293
>>
>>
>> The result shows that the difference between the 3 samples is 
>> significant.But if I want to perform multiple comparison to find out which 
>> pair of samples is  significantly different,which function should be used?
>>

It appears your question is which row(s) are contributing most greatly to the 
overall test of independence. The result of a `chisq.test(.)` (which is not 
what you see from its print method) has a component named residuals. (Read the 
help page : ?chisq.test)

x2 <- chisq.test(dat)
x2$residuals
  [,1]   [,2]
[1,] -2.3580463  2.4731398
[2,]  1.4481733 -1.5188569
[3,]  0.9323855 -0.9778942



Those row sums should be distributed as chi-squared statistics with one degree 
of freedom each, but since you have admittedly inflated the possibility of the 
type I error, it would be sensible to adjust the "p-statistics" using the 
function that Jim Lemon misspelled:

> rowSums(x2$residuals^2)
[1] 11.676803  4.404132  1.825620

> p.adjust( 1- pchisq( rowSums(x2$residuals^2), 1) )

[1] 0.001898526 0.071703921 0.176645786

So row 1 represents the only group that is "significantly different at the 
conventional level" from the expectations based on the overall sample 
collection. I also seem to remember that there is a function named CrossTable 
(in a package whose name I'm forgetting) that will deliver a SAS-style 
tabulation of row and column chi-squared statistics.

--
David.

>>
>> Many thanks for your help.
>>
>> My best
>>
>>
>>
>> 发自 网易邮箱大师
>>[[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.

David Winsemius
Alameda, CA, USA


[[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] how to perform multiple comparison?

2016-05-20 Thread laomeng_3
ok,many thanks.


发自 网易邮箱大师
On 2016-05-20 08:19 , Jim Lemon Wrote:

Hi laomeng_3,
Have a look at the padjust function (stats).

Jim


On Fri, May 20, 2016 at 1:56 AM, laomeng_3  wrote:
> Hi all:
> As to the anova, we can perform multiple comparison via TukeyHSD.
> But as to chi-square test for frequency table,how to perform multiple 
> comparison?
>
> For example, if I want to compare 3 samples' ratio(the data has 3 rows,each 
> row corresponds to 1 sample,and has 2 columns,each column corresponds to 
> positive and negative respectively).
>
>
> dat<-matrix(c(6,30,8,23,14,3),nrow=3)
> dat
>   [,1] [,2]
> [1,]6   23
> [2,]   30   14
> [3,]83
>
>
>
> chisq.test(dat)
>
>Pearson's Chi-squared test
>
> data:  dat
> X-squared = 17.9066, df = 2, p-value = 0.0001293
>
>
> The result shows that the difference between the 3 samples is significant.But 
> if I want to perform multiple comparison to find out which pair of samples is 
>  significantly different,which function should be used?
>
>
> Many thanks for your help.
>
> My best
>
>
>
> 发自 网易邮箱大师
> [[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.

[[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] how to draw the confidence interval

2017-03-05 Thread laomeng_3
hi all
I have a question about drawing the confidence interval .

For instance,if I want to sample 100 times,and each time,the sample size is 
10,and  the mean and sd is 15 and 1 respectively .I want to draw the 100 
confidence intervals(as the attachment) .Which function should be used to draw 
the confidence interval ?

Many thanks!



发自网易邮箱大师
__
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] [FORGED] how to draw the confidence interval

2017-03-05 Thread laomeng_3
this is not homework,just a case which I made by myself.


��ʦ



On 2017-03-06 06:47 , Rolf Turner Wrote:

On 04/03/17 19:39, laomeng_3 wrote:
> hi all I have a question about drawing the confidence interval .
>
> For instance,if I want to sample 100 times,and each time,the sample
> size is 10,and the mean and sd is 15 and 1 respectively .I want to draw
> the 100 confidence intervals(as the attachment) .Which function should
> be used to draw the confidence interval ?

This list does not answer questions about homework.

(BTW, no attachment came through; only a *very* limited range of file
types is permitted for attachments).

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

[[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] how to draw the confidence interval

2017-03-08 Thread laomeng_3
thanks a lot.


发自网易邮箱大师



On 2017-03-06 18:19 , Jim Lemon Wrote:

Hi laomeng,
If you know how to plot the means and calculate the standard
deviations, perhaps look at the "dispersion" function in the plotrix
package.

Jim


On Sat, Mar 4, 2017 at 5:39 PM, laomeng_3  wrote:
> hi all
> I have a question about drawing the confidence interval .
>
> For instance,if I want to sample 100 times,and each time,the sample size is 
> 10,and  the mean and sd is 15 and 1 respectively .I want to draw the 100 
> confidence intervals(as the attachment) .Which function should be used to 
> draw the confidence interval ?
>
> Many thanks!
>
>
>
> 发自网易邮箱大师
> __
> 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.