Hello Kathleen, disclaimer: here I doubt Your approach, so if You are really sure what You want, do not take this mail into account. Otherwise: I know nothing about your mental abilities, but so many pairwise correlations are about order of magnitude more than I am able to handle with mine. For me, this is a good reason to use some multivariate method (e.g. ordination) and make things much more simple. Then test just what seems to be meaningful (and correct for non-independence) if You really need it. This way Your tests could be viewed as post-hoc ("325 tests"-way is rigorous, but I am not sure whether it is useful). Or forget testing, and just look at the matrix of correlation coefficients themselves - these numbers tell the story, p-values just say how likely are they lying in doing so. Best, Martin Weiser Wayne Richter píše v Pá 16. 11. 2012 v 12:59 -0500: > Take a look at rcorr() in the Hmisc package. You can divide the P value > matrix by the value needed for the Bonferroni correction. > > But, with 26 parameters, you will have 325 pairwise correlations. By > dividing, for example, an alpha of 0.05 by 325, your minimum P value for > significance would be 0.00015. It's going to take a mighty high correlation > coefficient to be significant with 60 observations. Take a look at p.adjust. > > >>> > From: Kathleen Regan <kath.re...@gmail.com> > To: <r-sig-ecology@r-project.org> > Date: 11/15/2012 8:16 AM > Subject: [R-sig-eco] Use cor.test for multiple parameters? > > Please forgive me if this question has been answered somewhere else, but > for the life of me I couldn't find an answer (although i have found that > others have asked similar questions.) > > If anyone replies, PLEASE keep in mind that I am a soil ecologist with > absolutely no background or experience in object-oriented programming, > which is perhaps why I have not been able to take advantage of existing > help on this subject. If there are answers, I simply do not understand them! > > *What I need to do:* > I am trying to generate a table of correlations (26 parameters in columns, > 60 data rows.) I need Spearman's rho, the significance level p, and I need > to apply the Bonferroni correction. I also need to export it into Excel in > a nice matrix-y table format. > > *What I am able to do:* > I am able to do parts of what I want: with cor() I can generate a Spearman > correlation (but it's very ugly and hard to read or export nicely). > With cor.test I can generate a result when I use only 2 parameters (eg. > soilMois and BD), but I need to produce a table with all parameters > compared to each other. > > Ex: result<-cor.test(AprCorKR$SoilMois, AprCorKR$BD,method="spearman", > adjust.method="Bonferroni") > > Warning message: > > In cor.test.default(AprCorKR$SoilMois, AprCorKR$BD, : > > Cannot compute exact p-values with ties > > > Spearman's rank correlation rho > > data: AprCorKR$SoilMois and AprCorKR$BD > S = 49274.48, p-value = 0.003705 > alternative hypothesis: true rho is not equal to 0 > sample estimates: > rho > -0.3691158 > > (By the way, I understand the warning message.) > > *What I am unable to do:* > Use the function cor.test to generate the output of all my parameters with > respect to one another. > > Examples below are of various ways of writing what I want to R: > > result<-cor.test(AprCorKR$[2:26], AprCorKR$[2:26],method="spearman", > adjust.method="Bonferroni") > Error: unexpected '[' in "result<-cor.test(AprCorKR$[" > > > > result<-cor.test(AprCorKR$[2,26], AprCorKR$[2,26],method="spearman", > adjust.method="Bonferroni") > Error: unexpected '[' in "result<-cor.test(AprCorKR$[" > > result<-cor.test(c([2:26]), c([2:26]),data=AprCorKR,method="spearman", > adjust.method="Bonferroni") > Error: unexpected '[' in "result<-cor.test(c([" > > result<-cor.test(vars=2:26, vars=2:26,data=AprCorKR,method="spearman", > adjust.method="Bonferroni") > Error in cor.test.default(vars = 2:26, vars = 2:26, data = AprCorKR, method > = "spearman", : > argument "x" is missing, with no default > > result<-cor.test(vars=2:26,data=AprCorKR,method="spearman", > adjust.method="Bonferroni") > Error in cor.test.default(vars = 2:26, data = AprCorKR, method = > "spearman", : > argument "x" is missing, with no default > > result<-cor.test(data=AprCorKR,vars=2:26,method="spearman", > adjust.method="Bonferroni") > Error in cor.test.default(data = AprCorKR, vars = 2:26, method = > "spearman", : > argument "x" is missing, with no default > > *What I know:* > I have no missing values, no values of zero, and no typos that I am aware > of. I can display all my data correctly in R (and R seems to read it > correctly, based on what I am already able to do.) > > A former colleague wrote a small line of code that does what I am trying to > do but I can't get it to work on my newer version of R. I have R 2.14.2 and > I don't know what version he was using. > His code for this: *result<-cor_test(data="**mydata* > ",vars=2:26,adjust.method="Bonferroni") > > (I include below his entire German instructions. But the code he wrote to > do this job is very short, and I would like to duplicate it if I can. It > provides the results I need in a form I can use.) > > * *An additional note: > I have multtest loaded, and in my version cor.test is not written as > cor_test with an underscore but rather with a period. In the version of R > that I am using, there is no such thing as "correlation.r". > > * > * > > > ("Alb_Gesamtdat_10-03-10_bd_NA.txt") und das R-Skript ("correlation.r") > liegen und das Paket 'multtest' ist installiert > (www.r-project.org<file:///C:/Users/Regan/Documents/SCALEMIC/NewRStats/www.r-project.org>-> > CRAN > > -> Mirror -> Packages) > > > > > source("correlation.r") > > > > > result <- cor_test( data="Alb_Gesamtdat_10-03-10_bd_NA.txt", > > > vars=5:23, > > adjust.method="Bonferroni" ) > > > > Es werden bei diesem Funktionsaufruf automatisch 3 Dateien angelegt: > > - spearman_correlation_coefficients_complete_data.txt > > - spearman_correlation_raw_pvalues_complete_data.txt > > - spearman_correlation_Bonferroni_corrected_pvalues_complete_data.txt > > > > > > Thanks to anyone who can help me with this! > > > Kind regards, > > Kathy Regan
_______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology