Josef.Kardos at phila.gov
2010-Aug-07 20:08 UTC
[R] basic question about t-test with adjusted p value
I have read the R manual and help archives, sorry but I'm still stuck. How would I do a t-test with an adjusted p-value? Suppose that I use t.test ( ) , with the function argument alternative = "two.sided", and data such that degrees of freedom = 20. The function calculates a t-statistic of 2.086, and p-value =0.05 How do I then adjust the p-value? My thought is to do p.adjust (pt(2.086, df=20),"BH") but that doesn't change anything (returns 0.975) what is the procedure? I'm sorry if there is a basic concept that I am missing here... [[alternative HTML version deleted]]
On Sat, Aug 7, 2010 at 1:08 PM, <Josef.Kardos at phila.gov> wrote:> I have read the R manual and help archives, sorry but I'm still stuck. > > How would I do a t-test with an adjusted p-value? > > Suppose that I use t.test ( ) , with the function argument alternative > "two.sided", ?and data such that degrees of freedom = 20. ?The function > calculates a t-statistic of 2.086, and p-value =0.05 > > How do I then adjust the p-value? ?My thought is to do > p.adjust (pt(2.086, df=20),"BH") > but that doesn't change anything (returns 0.975) > > what is the procedure? ?I'm sorry if there is a basic concept that I am > missing here...These adjustments are generally designed to control a family wise or experiment wise error rate. If you only have one p-value, then the adjustment is equivalent to the unadjusted. The argument n defaults to length(p) (which is the length of the first argument). Here are some examples:> p.adjust(p = 0.975, method = "BH")[1] 0.975> p.adjust(p = 0.975, method = "BH", n = 1)[1] 0.975> p.adjust(p = 0.975, method = "BH", n = 5)[1] 1 HTH, Josh> > > > > > > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
On Sat, Aug 07, 2010 at 04:08:40PM -0400, Josef.Kardos at phila.gov wrote:> I have read the R manual and help archives, sorry but I'm still stuck. > > How would I do a t-test with an adjusted p-value? > > Suppose that I use t.test ( ) , with the function argument alternative = > "two.sided", and data such that degrees of freedom = 20. The function > calculates a t-statistic of 2.086, and p-value =0.05 > > How do I then adjust the p-value? My thought is to do > p.adjust (pt(2.086, df=20),"BH") > but that doesn't change anything (returns 0.975) > > what is the procedure? I'm sorry if there is a basic concept that I am > missing here...I'm confused - what result where you expecting? p.adjust will need to know the number of test you are trying to adjust for - either by giving explicitly giving the number or by handing a vector of p-values to the function. cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/
On 08/07/2010 03:08 PM, Josef.Kardos at phila.gov wrote:> I have read the R manual and help archives, sorry but I'm still stuck. > > How would I do a t-test with an adjusted p-value?Please be more specific about what you mean by 'adjusted p-value'. See below...> > Suppose that I use t.test ( ) , with the function argument alternative > "two.sided", and data such that degrees of freedom = 20. The function > calculates a t-statistic of 2.086, and p-value =0.05 > > How do I then adjust the p-value? My thought is to do > p.adjust (pt(2.086, df=20),"BH") > but that doesn't change anything (returns 0.975)A couple things here. 1) You can get the p-value returned from t.test by inspecting the object with ?str, and noting that it's stored in an element called p-value. So, p.val <- t.test(extra ~ group, data = sleep)$p.value assigns the p-value to an object called p.val. 2) You're calling p.adjust with a single p-value, so what kind of adjustment did you have in mind? You would normally be adjusting p-values because of a multiple comparison issue (i.e., multiple tests performed). You'd pass p.adjust the *vector* of p-values, and a method to adjust them by. Your vector is of length 1, so in p.adjust's opinion, there is nothing to adjust for. So, what do *you* mean by 'adjusted p-value'? `Why are you looking to adjust?` is another way of stating that.
ANOVA will give you an adjusted t-test. For example: fit<-lm(height~sex+age) summary(fit) Will give an age-adjusted t-test of the heights of men and women. John John Sorkin Chief Biostatistics and Informatics Univ. of Maryland School of Medicine Division of Gerontology and Geriatric Medicine JSorkin at grecc.umaryland.edu -----Original Message----- From: Erik Iverson <eriki at ccbr.umn.edu> To: <Josef.Kardos at phila.gov> Cc: <r-help at r-project.org> Sent: 8/7/2010 4:24:35 PM Subject: Re: [R] basic question about t-test with adjusted p value On 08/07/2010 03:08 PM, Josef.Kardos at phila.gov wrote:> I have read the R manual and help archives, sorry but I'm still stuck. > > How would I do a t-test with an adjusted p-value?Please be more specific about what you mean by 'adjusted p-value'. See below...> > Suppose that I use t.test ( ) , with the function argument alternative > "two.sided", and data such that degrees of freedom = 20. The function > calculates a t-statistic of 2.086, and p-value =0.05 > > How do I then adjust the p-value? My thought is to do > p.adjust (pt(2.086, df=20),"BH") > but that doesn't change anything (returns 0.975)A couple things here. 1) You can get the p-value returned from t.test by inspecting the object with ?str, and noting that it's stored in an element called p-value. So, p.val <- t.test(extra ~ group, data = sleep)$p.value assigns the p-value to an object called p.val. 2) You're calling p.adjust with a single p-value, so what kind of adjustment did you have in mind? You would normally be adjusting p-values because of a multiple comparison issue (i.e., multiple tests performed). You'd pass p.adjust the *vector* of p-values, and a method to adjust them by. Your vector is of length 1, so in p.adjust's opinion, there is nothing to adjust for. So, what do *you* mean by 'adjusted p-value'? `Why are you looking to adjust?` is another way of stating that. ______________________________________________ R-help at r-project.org mailing list 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. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
Reasonably Related Threads
- how to represent error bar in a plot legend?
- how to make a barplot similar to Excel’s “clustered column chart”.
- Problem loading rJava
- any feedback on XL Solutions Courses for R?
- plotting time series with data gap using type line- but do not want to connect gap with line