[R-sig-eco] Extract residuals from adonis function in vegan package
Hi, I am using the adonis function in the vegan package to determine effects of different environmental factors in forest plant community composition in different regions. I would like to first use adonis to remove the region effect, this is, to fit a model like adonis_region- adonis(community ~ region,permutations=999,method=bray) Where community is a presence/absence data matrix of species in forest patches belonging to different regions. Then I would like to use the residuals of this model as the response variable for some other analyses. I know I could use strata to model region as a block variable, but this does not interest me, as afterwards I want to perform another kind of analysis where I would like the region effect to be removed. My problem is that I cannot figure out how to get residual values from the adonis model. Any hint of some other kind of multivariate analysis that could solve this problem is very welcome. Thanks in advance, -- Alicia Valdés Université de Picardie Jules Verne Unité EDYSAN (Ecologie et Dynamique des Systèmes Anthropisés) 1, rue des Louvels F-80037 Amiens Cedex France tel:+33 322825775 alicia.val...@u-picardie.fr http://www.u-picardie.fr/edysan/ [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Dear Alicia Valdés, On 18/03/2014, at 13:53 PM, Alicia Valdés wrote: My problem is that I cannot figure out how to get residual values from the adonis model. You cannot get residuals from the output of adonis(). We could change the function so that this is possible, but the current function does not return information for getting residuals. Neither would they be residuals in the traditional meaning of the word as we are dealing with dissimilarities or distances, and these cannot be negative. We got to discuss this with vegan developers. Cheers, Jari Oksanen ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Dear Alicia and Jari, just a thought: Couldn't be capscale or betadisper be used for this? - To obtain the distances to the group centroid? But than: How to convert this from distances to abundances? Eduard Szöcs On 03/18/2014 01:21 PM, Jari Oksanen wrote: Dear Alicia Valdés, On 18/03/2014, at 13:53 PM, Alicia Valdés wrote: My problem is that I cannot figure out how to get residual values from the adonis model. You cannot get residuals from the output of adonis(). We could change the function so that this is possible, but the current function does not return information for getting residuals. Neither would they be residuals in the traditional meaning of the word as we are dealing with dissimilarities or distances, and these cannot be negative. We got to discuss this with vegan developers. Cheers, Jari Oksanen ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- Eduard Szöcs Quantitative Landscape Ecology Institute for Environmental Sciences University Koblenz-Landau Fortstrasse 7 76829 Landau Germany http://www.uni-koblenz-landau.de/campus-landau/faculty7/environmental-sciences/landscape-ecology/Staff/eduardszoecs ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
On 18/03/2014, at 15:23 PM, Eduard Szöcs wrote: Dear Alicia and Jari, just a thought: Couldn't be capscale or betadisper be used for this? - To obtain the distances to the group centroid? But than: How to convert this from distances to abundances? You can *almost* do this with capscale(), but not quite: for semimetric dissimilarities the results are not identical with capscale (they are identical with metric distances). The capscale() function also has fitted() and residuals() methods that both return dissimilarities. Now it also depends on what you mean with residuals. The capscale() interpretation and the one I had on my mind is that 1) adonis(fitted(adonis(y ~ model)) ~ model) should give distances where the fitted part of adonis(y ~model) and the residual variation part should be null, and 2) adonis(residuals(adonis(y ~model) ~ model) should give distances where fit would be null and residual similar as in the original adonis(y ~ model). It would be possible to develop such functions, but not with the current adonis() output. You can approximate both of these with capscale() and its fitted() and residuals() methods, but not exactly. The ecodist package of Sarah Goslee takes a different approach, and could return something usable (but I do not know that package very well). What really is needed depends on what you mean with residuals. Should they be dissimilarities (which cannot be negative) or straightforward residuals (which have an average of zero and some of which are negative). Cheers, jari Oksanen ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Hi and many thanks for your replies, I have had a look at capscale() and betadisper(), but as you said, this could only provide residuals in fhe form of dissimilarities, and what I actually would like to have are true residuals, negative and positive. I have also looked into ecodist, but I did not find anything that could help. Cheers, Alicia Valdés 2014-03-18 15:06 GMT+01:00 Jari Oksanen jari.oksa...@oulu.fi: On 18/03/2014, at 15:23 PM, Eduard Szöcs wrote: Dear Alicia and Jari, just a thought: Couldn't be capscale or betadisper be used for this? - To obtain the distances to the group centroid? But than: How to convert this from distances to abundances? You can *almost* do this with capscale(), but not quite: for semimetric dissimilarities the results are not identical with capscale (they are identical with metric distances). The capscale() function also has fitted() and residuals() methods that both return dissimilarities. Now it also depends on what you mean with residuals. The capscale() interpretation and the one I had on my mind is that 1) adonis(fitted(adonis(y ~ model)) ~ model) should give distances where the fitted part of adonis(y ~model) and the residual variation part should be null, and 2) adonis(residuals(adonis(y ~model) ~ model) should give distances where fit would be null and residual similar as in the original adonis(y ~ model). It would be possible to develop such functions, but not with the current adonis() output. You can approximate both of these with capscale() and its fitted() and residuals() methods, but not exactly. The ecodist package of Sarah Goslee takes a different approach, and could return something usable (but I do not know that package very well). What really is needed depends on what you mean with residuals. Should they be dissimilarities (which cannot be negative) or straightforward residuals (which have an average of zero and some of which are negative). Cheers, jari Oksanen [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
You ought to be very careful about using residuals from one analysis as the response variable in another analysis as the inferences about the second analysis will almost certainly be flawed. Best to try and do this another way if at all possible. Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: ca...@usgs.gov brian_c...@usgs.gov tel: 970 226-9326 On Tue, Mar 18, 2014 at 5:53 AM, Alicia Valdés aliciavaldes1...@gmail.comwrote: Hi, I am using the adonis function in the vegan package to determine effects of different environmental factors in forest plant community composition in different regions. I would like to first use adonis to remove the region effect, this is, to fit a model like adonis_region- adonis(community ~ region,permutations=999,method=bray) Where community is a presence/absence data matrix of species in forest patches belonging to different regions. Then I would like to use the residuals of this model as the response variable for some other analyses. I know I could use strata to model region as a block variable, but this does not interest me, as afterwards I want to perform another kind of analysis where I would like the region effect to be removed. My problem is that I cannot figure out how to get residual values from the adonis model. Any hint of some other kind of multivariate analysis that could solve this problem is very welcome. Thanks in advance, -- Alicia Valdés Université de Picardie Jules Verne Unité EDYSAN (Ecologie et Dynamique des Systèmes Anthropisés) 1, rue des Louvels F-80037 Amiens Cedex France tel:+33 322825775 alicia.val...@u-picardie.fr http://www.u-picardie.fr/edysan/ [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Hi, Yes, I know there are issues about using residuals as response variable, and contrasting opinions about that. However, what I attempt to do is to perform an indicator species analysis (ISA) with these residuals. I want to see if I can find species which are indicators for different environmental conditions, but first I would like to remove the differences in species composition due to the study region (which accounts in fact for a big part of the differences in species composition). I am using the packages indicspecies and labdsv for ISA but in none of the cases did I found a way of including this as, for example, a block variable, that's what I attempt to get the residuals. Cheers, Alicia -- Alicia Valdés Université de Picardie Jules Verne Unité EDYSAN (Ecologie et Dynamique des Systèmes Anthropisés) 1, rue des Louvels F-80037 Amiens Cedex France tel:+33 322825775 alicia.val...@u-picardie.fr http://www.u-picardie.fr/edysan/ 2014-03-18 15:43 GMT+01:00 Cade, Brian ca...@usgs.gov: You ought to be very careful about using residuals from one analysis as the response variable in another analysis as the inferences about the second analysis will almost certainly be flawed. Best to try and do this another way if at all possible. Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: ca...@usgs.gov brian_c...@usgs.gov tel: 970 226-9326 On Tue, Mar 18, 2014 at 5:53 AM, Alicia Valdés aliciavaldes1...@gmail.com wrote: Hi, I am using the adonis function in the vegan package to determine effects of different environmental factors in forest plant community composition in different regions. I would like to first use adonis to remove the region effect, this is, to fit a model like adonis_region- adonis(community ~ region,permutations=999,method=bray) Where community is a presence/absence data matrix of species in forest patches belonging to different regions. Then I would like to use the residuals of this model as the response variable for some other analyses. I know I could use strata to model region as a block variable, but this does not interest me, as afterwards I want to perform another kind of analysis where I would like the region effect to be removed. My problem is that I cannot figure out how to get residual values from the adonis model. Any hint of some other kind of multivariate analysis that could solve this problem is very welcome. Thanks in advance, -- Alicia Valdés Université de Picardie Jules Verne Unité EDYSAN (Ecologie et Dynamique des Systèmes Anthropisés) 1, rue des Louvels F-80037 Amiens Cedex France tel:+33 322825775 alicia.val...@u-picardie.fr http://www.u-picardie.fr/edysan/ [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Dear Alicia, the mvabund package enables to fit Multivariate Generalized Linear Model for presence/abscence data. I guess you could extract residuals. HTH, Pierre *Pierre THIRIET* Doctorant en écologie marine - Marine Ecology PhD student EA 4228 - ECOMERS - /Ecosystèmes Côtiers Marins et Réponses aux Stress/ Université de Nice - Sophia Antipolis, Faculté des Sciences, Parc Valrose, 06108 Nice Cedex 2, France More about my work and my lab. http://www.unice.fr/ecomers/index.php?option=com_comprofilertask=userProfileuser=101Itemid=111lang=fr Cell: +336 79 44 91 90 Office: +334 92 07 68 33 Skype: pierre.d.thiriet Mail: pierre.thir...@unice.fr Mail(bis): pierre.d.thir...@gmail.com Le 18/03/2014 15:43, Cade, Brian a écrit : You ought to be very careful about using residuals from one analysis as the response variable in another analysis as the inferences about the second analysis will almost certainly be flawed. Best to try and do this another way if at all possible. Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email:ca...@usgs.gov brian_c...@usgs.gov tel: 970 226-9326 On Tue, Mar 18, 2014 at 5:53 AM, Alicia Valdés aliciavaldes1...@gmail.comwrote: Hi, I am using the adonis function in the vegan package to determine effects of different environmental factors in forest plant community composition in different regions. I would like to first use adonis to remove the region effect, this is, to fit a model like adonis_region- adonis(community ~ region,permutations=999,method=bray) Where community is a presence/absence data matrix of species in forest patches belonging to different regions. Then I would like to use the residuals of this model as the response variable for some other analyses. I know I could use strata to model region as a block variable, but this does not interest me, as afterwards I want to perform another kind of analysis where I would like the region effect to be removed. My problem is that I cannot figure out how to get residual values from the adonis model. Any hint of some other kind of multivariate analysis that could solve this problem is very welcome. Thanks in advance, -- Alicia Valdés Université de Picardie Jules Verne Unité EDYSAN (Ecologie et Dynamique des Systèmes Anthropisés) 1, rue des Louvels F-80037 Amiens Cedex France tel:+33 322825775 alicia.val...@u-picardie.fr http://www.u-picardie.fr/edysan/ [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
On Tue, Mar 18, 2014 at 5:02 PM, Alicia Valdés aliciavaldes1...@gmail.com wrote: ... However, what I attempt to do is to perform an indicator species analysis (ISA) with these residuals. I want to see if I can find species which are indicators for different environmental conditions, but first I would like to remove the differences in species composition due to the study region (which accounts in fact for a big part of the differences in species composition). I am using the packages indicspecies and labdsv for ISA but in none of the cases did I found a way of including this as, for example, a block variable, that's what I attempt to get the residuals. Alicia, following up on my previous comment, I think you might use the regions as a typology on which to base your ISA. So you'll get the characteristic species for each region and there is no need to account for differences in species composition among regions (moreover, I fail to understand why one might need to do so). If you take a look at the help page for multipatt() in indicspecies, you'll see that you need a community data table (your presence/absence matrix) and a site classification (your regions if these are not further classified into meaningful clusters; although you didn't provide more details on how the forest patches relate to the regions you wrote about) to run the analysis. HTH, Ivailo -- The cure for boredom is curiosity. There is no cure for curiosity. -- Dorothy Parker ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Thanks for so many thoughts! Arne: I could use Condition() for that but something like capscale(communitydistances ~ environmentalvar+Condition(region)) would not attempt what I need, because I need to fit a model only with region, extract residuals, and then do another analysis (ISA) with these residuals. However, if this kind of formulation is correct, it could also be useful to see the effects of environmental factors while controlling for the effect of region Indicator species analysis could be done for each region separately. - yes, but I would like to try both approaches, ISA for all regions (but removing the region effect) and ISA for each region separately, and compare the results Jari: OK I guess that even if they could be calculated, residuals from the adonis() point of view are not suitable for me, as they are dissimilarities. Sorry if I was confusing, what I need are residuals of raw data, as you say. So I guess the residuals() method of rda() should work. Yes, I know that ISA needs non-negative values, I was attending to transform these residuals to make them all positive. Pierre: I checked manyglm() function in the mvabund package and I think it could be useful too, you can indeed get residuals from a mutivariate GLM with family=binomial. Ivailo: I think you maybe misunderstood my approach, I want to perform an ISA based on differences in species composition, but I want to focus on the part of these differences which is not caused by the region studied. I want to identify indicator species for different environmental conditions and caracteristics of forest patches (like landscape management type, forest age and others), but I am not interested in finding the characteristic species for the different regions. To make it clearer, I have data from different regions, into each of the regions there are a series of forest patches which vary in management type, age and other factors. So the cluster I am using in multipatt() is a classification into management types, age groups, etc. As I said before, I am not interested in use regions for site classification. I hope this makes the analysis easier to understand now! So my main doubts now are: for this kind of purpose, 1) what is your opinion on using a community data table in the ISA which contains not the actual presence/absence, but residuals form a previous model with region effect?; and 2) Which kind of residuals do you find more appropiate to use here (rda residuals of multivariate GLM residuals)? Cheers, Alicia 2014-03-18 16:23 GMT+01:00 Ivailo ubuntero.9...@gmail.com: On Tue, Mar 18, 2014 at 5:02 PM, Alicia Valdés aliciavaldes1...@gmail.com wrote: ... However, what I attempt to do is to perform an indicator species analysis (ISA) with these residuals. I want to see if I can find species which are indicators for different environmental conditions, but first I would like to remove the differences in species composition due to the study region ... Isn't an indicator species analysis *based* on differences in species composition? How could one remove the difference in species composition due to region and then still hope to identify indicator species for the regions that are equalized? Cheers, Ivailo -- The cure for boredom is curiosity. There is no cure for curiosity. -- Dorothy Parker [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Extract residuals from adonis function in vegan package
Alicia One more thought. I wonder if part of the problem is that you're attempting to use ISA to do something it was not designed to deal with. Sometimes that can work and result in a clever new approach, but in this case, I don't see how it can work. As a recall, ISA is done by taking the product of relative abundance and relative frequency. Therefore, as mentioned by Jari, it can only be used with positive values of abundance and frequency. Yes, it is true that you can transform the residual abundances to make them all positive. That seems perfectly reasonable if you then intend to use the residual abundances (and the residual abundances only) to examine associations with environmental groups. What is puzzling me is how one calculates a relative frequency using residual abundances or how one calculates a residual frequency. Is it your intention to calculate residual frequencies? It's not clear to me how that could be done. I suppose you could leave out the relative frequency when doing the ISA, but that leads me to the following question: Can you tell us why indicator species analysis is a better approach for determining indication of particular environmental conditions than are species scores generated from a capscale ordination? Given the flexibility of capscale to deal with categorical predictors, it has never been clear to me what advantages ISA has over species scores in interpreting environmental associations (other than generating a Monte Carlo-derived significance value). If there is not much difference, then I would do a capscale analysis using region as a Condition factor (as suggested by Arne) and then examine the species scores. Steve J. Stephen Brewer Professor Department of Biology PO Box 1848 University of Mississippi University, Mississippi 38677-1848 Brewer web page - http://home.olemiss.edu/~jbrewer/ FAX - 662-915-5144 Phone - 662-915-1077 On 3/18/14 11:48 AM, Alicia Valdés aliciavaldes1...@gmail.com wrote: Thanks for so many thoughts! Arne: I could use Condition() for that but something like capscale(communitydistances ~ environmentalvar+Condition(region)) would not attempt what I need, because I need to fit a model only with region, extract residuals, and then do another analysis (ISA) with these residuals. However, if this kind of formulation is correct, it could also be useful to see the effects of environmental factors while controlling for the effect of region Indicator species analysis could be done for each region separately. - yes, but I would like to try both approaches, ISA for all regions (but removing the region effect) and ISA for each region separately, and compare the results Jari: OK I guess that even if they could be calculated, residuals from the adonis() point of view are not suitable for me, as they are dissimilarities. Sorry if I was confusing, what I need are residuals of raw data, as you say. So I guess the residuals() method of rda() should work. Yes, I know that ISA needs non-negative values, I was attending to transform these residuals to make them all positive. Pierre: I checked manyglm() function in the mvabund package and I think it could be useful too, you can indeed get residuals from a mutivariate GLM with family=binomial. Ivailo: I think you maybe misunderstood my approach, I want to perform an ISA based on differences in species composition, but I want to focus on the part of these differences which is not caused by the region studied. I want to identify indicator species for different environmental conditions and caracteristics of forest patches (like landscape management type, forest age and others), but I am not interested in finding the characteristic species for the different regions. To make it clearer, I have data from different regions, into each of the regions there are a series of forest patches which vary in management type, age and other factors. So the cluster I am using in multipatt() is a classification into management types, age groups, etc. As I said before, I am not interested in use regions for site classification. I hope this makes the analysis easier to understand now! So my main doubts now are: for this kind of purpose, 1) what is your opinion on using a community data table in the ISA which contains not the actual presence/absence, but residuals form a previous model with region effect?; and 2) Which kind of residuals do you find more appropiate to use here (rda residuals of multivariate GLM residuals)? Cheers, Alicia 2014-03-18 16:23 GMT+01:00 Ivailo ubuntero.9...@gmail.com: On Tue, Mar 18, 2014 at 5:02 PM, Alicia Valdés aliciavaldes1...@gmail.com wrote: ... However, what I attempt to do is to perform an indicator species analysis (ISA) with these residuals. I want to see if I can find species which are indicators for different environmental conditions, but first I would like to remove the differences in species composition due to the study region ... Isn't an indicator species