Re: [R] lost in vegan package
eva epitta at upatras.gr writes: Thank you very very much. I thought I wouldn't never find the right way of calculating species pairs occurrences in vegan package. My data are already transposed. Do you know a way of saving the output? I can only copy and paste the results in an Excel worksheet. For large numbers of species pairs the console will not show all possible species pairs. Eva, The printed output can be dumped to a file using command sink(). See its help page for info. The oecosimu result is the output of the basic statistic function amended with item oecosimu with structure: str(mod$oecosimu) List of 6 $ z : num -66.5 $ pval : num 0.01 $ simulated : num [1, 1:99] 159621 160463 161865 161720 162472 ... $ method : chr r00 $ statistic : Named num 54904 ..- attr(*, names)= chr statistic $ alternative: chr two.sided You can list and save itmes like mod$oecosimu$statistic, mod$oecosimu$z, mod$oecosimu$pval which all are combined into printed ouput. You can use commands like write.table, write.csv to save these results for external software. Please note the 'alternative' algorithm: it seems to me that your hypotheses may one-sided. Cheers, Jari Oksanen __ R-help@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.
Re: [R] lost in vegan package
Eva, The printed output can be dumped to a file using command sink(). See its help page for info. The oecosimu result is the output of the basic statistic function amended with item oecosimu with structure: str(mod$oecosimu) List of 6 $ z : num -66.5 $ pval : num 0.01 $ simulated : num [1, 1:99] 159621 160463 161865 161720 162472 ... $ method : chr r00 $ statistic : Named num 54904 ..- attr(*, names)= chr statistic $ alternative: chr two.sided You can list and save itmes like mod$oecosimu$statistic, mod$oecosimu$z, mod$oecosimu$pval which all are combined into printed ouput. You can use commands like write.table, write.csv to save these results for external software. Please note the 'alternative' algorithm: it seems to me that your hypotheses may one-sided. Cheers, Jari Oksanen Dr Oksanen I'm checking if the simulated number of checkerboard units of a species pair is larger or smaller than the observed number of checkerboard units in the original dataset. If it is larger I list the species pair as exhibiting cooccurrence and if it is smaller i list it as exhibiting competition. The procedure I'm following (which I'm not sure is correct) is that I use the probabilities i get from the output at the 0.1 level. As I understand, this means that I'm checking at the 0,05 level in each tail of the distribution. Am I wrong? Thank's again Eva -- View this message in context: http://r.789695.n4.nabble.com/lost-in-vegan-package-tp2400145p2403096.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] lost in vegan package
eva epitta at upatras.gr writes: Hi R Helpers, I'm still new to R and i experience many difficulties..I'm using vegan package (R version 2.11) trying to calculate checkerboard units for each species pair of a matrix. I've prepared the function: pair.checker=function (dataset) {designdist (dataset, method=c((A-J)x(B-J), terms =binary, abcd=FALSE)} to use with function oecosimu as follows: oecosimu(dataset, pair.checker, tswap, nsimul=5000, burnin=0, thin=thin, statistic=pair.checker) It seemed to work but the output did not include each species pair name. I don't know what to do. First column was all NAs. I copied and pasted the results of the console and named each species pair in Excel by hand. But then I got this really big matrix with 3828 possible species pairs. The console couldn't show all posssible species pairs even after resetting the max.print option. I've tried saving the output as: Eva, You have several problems with your example: 1) there is a syntax error (or several syntax errors) in the designdist() 'method' you have in you pair.checker(). 2) designdist() finds dissimilarities between rows, and with standard usage yourspecies are columns: you must transpose your data. 3) designdist() returns a dist object which does not have names of pairs of species, but you must make them. 4) you should not give the name of the 'statistic' in the oecosimu unless you return the result in a list with an item named by the value given to the statistic. Below is a version that seems to work. It corrects the syntax of 'method', andchanges the result to a vector named by the species pairs, but it doesn't transpose your data: pair.checker - function (dataset) { d - designdist (dataset, method=(A-J)*(B-J), terms =binary) nm - outer(labels(d), labels(d), paste)[lower.tri(d)] d - as.vector(d) names(d) - nm d } If your species are columns (like usually in vegan data set), you must transposeyour data when calling this using t() function. Here is a working oecosimu call: oecosimu(t(dune), pair.checker, tswap, nsimul = 5000, burnin = 0) I didn't give 'thin' here, since you didn't have a numeric value for 'thin' in your example. Further, you shall not give the name of the 'statistic' since pair.checker() returns an unnamed vector. So you write from Patras... I've carried home a paper by Giokas Sfenthourakis to see at my leisure how to implement their methodology in vegan. I guess it's above... Cheers, Jari Oksanen __ R-help@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.
Re: [R] lost in vegan package
Jari Oksanen wrote: eva epitta at upatras.gr writes: Hi R Helpers, I'm still new to R and i experience many difficulties..I'm using vegan package (R version 2.11) trying to calculate checkerboard units for each species pair of a matrix. I've prepared the function: pair.checker=function (dataset) {designdist (dataset, method=c((A-J)x(B-J), terms =binary, abcd=FALSE)} to use with function oecosimu as follows: oecosimu(dataset, pair.checker, tswap, nsimul=5000, burnin=0, thin=thin, statistic=pair.checker) It seemed to work but the output did not include each species pair name. I don't know what to do. First column was all NAs. I copied and pasted the results of the console and named each species pair in Excel by hand. But then I got this really big matrix with 3828 possible species pairs. The console couldn't show all posssible species pairs even after resetting the max.print option. I've tried saving the output as: Eva, You have several problems with your example: 1) there is a syntax error (or several syntax errors) in the designdist() 'method' you have in you pair.checker(). 2) designdist() finds dissimilarities between rows, and with standard usage yourspecies are columns: you must transpose your data. 3) designdist() returns a dist object which does not have names of pairs of species, but you must make them. 4) you should not give the name of the 'statistic' in the oecosimu unless you return the result in a list with an item named by the value given to the statistic. Below is a version that seems to work. It corrects the syntax of 'method', andchanges the result to a vector named by the species pairs, but it doesn't transpose your data: pair.checker - function (dataset) { d - designdist (dataset, method=(A-J)*(B-J), terms =binary) nm - outer(labels(d), labels(d), paste)[lower.tri(d)] d - as.vector(d) names(d) - nm d } If your species are columns (like usually in vegan data set), you must transposeyour data when calling this using t() function. Here is a working oecosimu call: oecosimu(t(dune), pair.checker, tswap, nsimul = 5000, burnin = 0) I didn't give 'thin' here, since you didn't have a numeric value for 'thin' in your example. Further, you shall not give the name of the 'statistic' since pair.checker() returns an unnamed vector. So you write from Patras... I've carried home a paper by Giokas Sfenthourakis to see at my leisure how to implement their methodology in vegan. I guess it's above... Cheers, Jari Oksanen __ R-help@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. Dr Oksanen, Thank you very very much. I thought I wouldn't never find the right way of calculating species pairs occurrences in vegan package. My data are already transposed. Do you know a way of saving the output? I can only copy and paste the results in an Excel worksheet. For large numbers of species pairs the console will not show all possible species pairs. Thank's Eva PS: I'm a PhD student and my supervisor is Dr Sfenthourakis. We are currelntly evaluating the performance of species pair metrics, such as joint occurrences of species pairs on islands, in artificial and real matrices. -- View this message in context: http://r.789695.n4.nabble.com/lost-in-vegan-package-tp2400145p2401227.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.