Extracting part of anova.cca()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Extracting part of anova.cca()

Nevil Amos
I have an anova.cca() output.

If it is possible I would like to extract the table it contains as a data frame
ie

> > myAnova
> Permutation test for rda under reduced model
> Terms added sequentially (first to last)
>
> Model: rda(formula = mygenind@tab ~ mds3dCS_NULL + mds3dTRE_25_2_CS25 + mydata$LAT.x + mydata$LONG.x + mydata$Hab_Config + mds3dTRE_25_100_CS25 + mydata$TreeCov + mydata$Site_No + mds3dSFW_EO_100_CS25 + mds3dSFW_EO_5000_CS25 + mydata$Landscape + mds3dSFW_TH_10_CS25, scale = T, na.action = "na.omit")
>                        Df     Var      F N.Perm Pr(>F)  
> mds3dCS_NULL            3   6.527 2.6380     99   0.01 **
> mds3dTRE_25_2_CS25      3   5.596 2.2616     99   0.01 **
> mydata$LAT.x            1   1.892 2.2939     99   0.01 **
> mydata$LONG.x           1   1.891 2.2929     99   0.01 **
> mydata$Hab_Config       2   2.772 1.6807     99   0.01 **
> mds3dTRE_25_100_CS25    3   3.952 1.5970     99   0.01 **
> mydata$TreeCov          1   1.272 1.5418     99   0.01 **
> mydata$Site_No          1   1.345 1.6306     99   0.01 **
> mds3dSFW_EO_100_CS25    3   3.741 1.5120     99   0.01 **
> mds3dSFW_EO_5000_CS25   3   3.410 1.3783     99   0.01 **
> mydata$Landscape        8   9.300 1.4094     99   0.01 **
> mds3dSFW_TH_10_CS25     3   3.658 1.4785     99   0.01 **
> Residual              139 114.644                        
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> >




I would like to extract as a table:
                     

>                        Df     Var      F N.Perm Pr(>F)  
> mds3dCS_NULL            3   6.527 2.6380     99   0.01 **
> mds3dTRE_25_2_CS25      3   5.596 2.2616     99   0.01 **
> mydata$LAT.x            1   1.892 2.2939     99   0.01 **
> mydata$LONG.x           1   1.891 2.2929     99   0.01 **
> mydata$Hab_Config       2   2.772 1.6807     99   0.01 **
> mds3dTRE_25_100_CS25    3   3.952 1.5970     99   0.01 **
> mydata$TreeCov          1   1.272 1.5418     99   0.01 **
> mydata$Site_No          1   1.345 1.6306     99   0.01 **
> mds3dSFW_EO_100_CS25    3   3.741 1.5120     99   0.01 **
> mds3dSFW_EO_5000_CS25   3   3.410 1.3783     99   0.01 **
> mydata$Landscape        8   9.300 1.4094     99   0.01 **
> mds3dSFW_TH_10_CS25     3   3.658 1.4785     99   0.01 **
> Residual              139 114.644                        
             

Is this possible? what is the syntax?

I have looked at str(myAnova) but cannot see how to get the table with variable names included

Many thanks
Nevil Amos
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Extracting part of anova.cca()

Jari Oksanen

On 23/01/2012, at 13:31 PM, Nevil Amos wrote:

> I have an anova.cca() output.
>
> If it is possible I would like to extract the table it contains as a data frame
> ie
>>> myAnova
>> Permutation test for rda under reduced model
>> Terms added sequentially (first to last)
>>
>> Model: rda(formula = mygenind@tab ~ mds3dCS_NULL + mds3dTRE_25_2_CS25 + mydata$LAT.x + mydata$LONG.x + mydata$Hab_Config + mds3dTRE_25_100_CS25 + mydata$TreeCov + mydata$Site_No + mds3dSFW_EO_100_CS25 + mds3dSFW_EO_5000_CS25 + mydata$Landscape + mds3dSFW_TH_10_CS25, scale = T, na.action = "na.omit")
>>                       Df     Var      F N.Perm Pr(>F)  
>> mds3dCS_NULL            3   6.527 2.6380     99   0.01 **
>> mds3dTRE_25_2_CS25      3   5.596 2.2616     99   0.01 **
>> mydata$LAT.x            1   1.892 2.2939     99   0.01 **
>> mydata$LONG.x           1   1.891 2.2929     99   0.01 **
>> mydata$Hab_Config       2   2.772 1.6807     99   0.01 **
>> mds3dTRE_25_100_CS25    3   3.952 1.5970     99   0.01 **
>> mydata$TreeCov          1   1.272 1.5418     99   0.01 **
>> mydata$Site_No          1   1.345 1.6306     99   0.01 **
>> mds3dSFW_EO_100_CS25    3   3.741 1.5120     99   0.01 **
>> mds3dSFW_EO_5000_CS25   3   3.410 1.3783     99   0.01 **
>> mydata$Landscape        8   9.300 1.4094     99   0.01 **
>> mds3dSFW_TH_10_CS25     3   3.658 1.4785     99   0.01 **
>> Residual              139 114.644                        
>> ---
>> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>>>
>
>
>
>
> I would like to extract as a table:
>
>>                       Df     Var      F N.Perm Pr(>F)  
>> mds3dCS_NULL            3   6.527 2.6380     99   0.01 **
>> mds3dTRE_25_2_CS25      3   5.596 2.2616     99   0.01 **
>> mydata$LAT.x            1   1.892 2.2939     99   0.01 **
>> mydata$LONG.x           1   1.891 2.2929     99   0.01 **
>> mydata$Hab_Config       2   2.772 1.6807     99   0.01 **
>> mds3dTRE_25_100_CS25    3   3.952 1.5970     99   0.01 **
>> mydata$TreeCov          1   1.272 1.5418     99   0.01 **
>> mydata$Site_No          1   1.345 1.6306     99   0.01 **
>> mds3dSFW_EO_100_CS25    3   3.741 1.5120     99   0.01 **
>> mds3dSFW_EO_5000_CS25   3   3.410 1.3783     99   0.01 **
>> mydata$Landscape        8   9.300 1.4094     99   0.01 **
>> mds3dSFW_TH_10_CS25     3   3.658 1.4785     99   0.01 **
>> Residual              139 114.644                        
>
>
> Is this possible? what is the syntax?
>
> I have looked at str(myAnova) but cannot see how to get the table with variable names included


Nevil,

The output *is* a data frame so that there is not much to extract. There are a two extra arguments added to the data frame:  heading and Random.seed. One way of getting rid off those is to use command as.data.frame():

as.data.frame(myAnova)

However,  you will not get significance stars with this: the stars are not a part of the result, but they are only displayed when you print the result and if getOption("show.signif.stars") is TRUE. Moreover, the last line ("Residuals") has some cells which are printed as empty, but they are not empty: they contain NA and they only look empty because print.anova sets option na.print = "" in printCoefmat() it uses internally.

Putting these together: if you only want to have the data frame, you have it or may strip extra arguments using as.data.frame(myAnova). If you want to get printed output like in your example above,  you can use

printCoefmat(as.data.frame(myAnova), na.print="", signif.legend=FALSE)

Cheers, Jari Oksanen
--
Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
[hidden email], Ph. +358 400 408593, http://cc.oulu.fi/~jarioksa

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Terms with zero variance included in ordistep best model?

Nevil Amos
Below I have pasted the outputs of an ordistep() on an rda()

I noticed in the final fitting of the ordistep() that two terms "mydata$TreeCov" and "mydata$HabConfig" were still included but had variance of 0 and therefore P was not calculated.

Why are they still included in the final model?  

thanks

Nevil Amos


> myOrdistepBoth
Call: rda(formula = mygenind@tab ~ mds3dCS_NULL + mds3dTRE_25_2_CS25 + mydata$LAT.x + mydata$Hab_Config + mds3dTRE_25_100_CS25 + mydata$TreeCov +
mydata$Site_No + mds3dSFW_EO_100_CS25 + mds3dSFW_EO_5000_CS25 + mydata$Landscape + mds3dSFW_TH_10_CS25 + mydata$LONG.x, scale = T, na.action = "na.omit")

               Inertia Proportion Rank
Total         160.0000     1.0000    
Constrained    45.3560     0.2835   32
Unconstrained 114.6440     0.7165  139
Inertia is correlations
Some constraints were aliased because they were collinear (redundant)

Eigenvalues for constrained axes:
  RDA1   RDA2   RDA3   RDA4   RDA5   RDA6   RDA7   RDA8   RDA9  RDA10  RDA11  RDA12  RDA13  RDA14  RDA15  RDA16  RDA17  RDA18  RDA19  RDA20  RDA21  RDA22  RDA23  RDA24  RDA25
3.3489 3.2291 2.8211 2.5129 2.2606 2.1062 2.0834 1.8720 1.7727 1.6680 1.6072 1.5512 1.5100 1.4314 1.3802 1.2427 1.1497 1.1153 1.0547 1.0287 0.9814 0.9361 0.9168 0.8851 0.7577
 RDA26  RDA27  RDA28  RDA29  RDA30  RDA31  RDA32
0.7150 0.7056 0.6436 0.6098 0.5643 0.4806 0.4140

Eigenvalues for unconstrained axes:
  PC1   PC2   PC3   PC4   PC5   PC6   PC7   PC8
3.433 3.098 3.057 2.912 2.866 2.743 2.669 2.586
(Showed only 8 of all 139 unconstrained eigenvalues)



> anova(myOrdistepBoth,by="term")
Permutation test for rda under reduced model
Terms added sequentially (first to last)

Model: rda(formula = mygenind@tab ~ mds3dCS_NULL + mds3dTRE_25_2_CS25 + mydata$LAT.x + mydata$Hab_Config + mds3dTRE_25_100_CS25 + mydata$TreeCov + mydata$Site_No + mds3dSFW_EO_100_CS25 + mds3dSFW_EO_5000_CS25 + mydata$Landscape + mds3dSFW_TH_10_CS25 + mydata$LONG.x, scale = T, na.action = "na.omit")
                       Df     Var      F N.Perm Pr(>F)  
mds3dCS_NULL            3   6.527 2.6380     99   0.01 **
mds3dTRE_25_2_CS25      3   5.596 2.2616     99   0.01 **
mydata$LAT.x            1   1.892 2.2939     99   0.01 **
mydata$Hab_Config       2   2.858 1.7325     99   0.01 **
mds3dTRE_25_100_CS25    3   4.314 1.7435     99   0.01 **
mydata$TreeCov          1   1.238 1.5008     99   0.01 **
mydata$Site_No          1   1.304 1.5806     99   0.01 **
mds3dSFW_EO_100_CS25    3   3.834 1.5497     99   0.01 **
mds3dSFW_EO_5000_CS25   3   3.344 1.3515     99   0.01 **
mydata$Landscape        8   9.711 1.4717     99   0.01 **
mds3dSFW_TH_10_CS25     3   3.702 1.4961     99   0.01 **
mydata$LONG.x           1   1.037 1.2569     99   0.06 .
Residual              139 114.644                        
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



> anova(myOrdistepBoth,by="margin")
Permutation test for rda under reduced model
Marginal effects of terms

Model: rda(formula = mygenind@tab ~ mds3dCS_NULL + mds3dTRE_25_2_CS25 + mydata$LAT.x + mydata$Hab_Config + mds3dTRE_25_100_CS25 + mydata$TreeCov + mydata$Site_No + mds3dSFW_EO_100_CS25 + mds3dSFW_EO_5000_CS25 + mydata$Landscape + mds3dSFW_TH_10_CS25 + mydata$LONG.x, scale = T, na.action = "na.omit")
                       Df     Var      F N.Perm  Pr(>F)  
mds3dCS_NULL            3   3.519 1.4222    199 0.00500 **
mds3dTRE_25_2_CS25      3   3.663 1.4805    199 0.00500 **
mydata$LAT.x            1   1.185 1.4364    199 0.00500 **
mydata$Hab_Config       0   0.000 0.0000      0          
mds3dTRE_25_100_CS25    3   3.569 1.4423    199 0.00500 **
mydata$TreeCov          0   0.000 0.0000      0          
mydata$Site_No          1   1.251 1.5170    199 0.00500 **
mds3dSFW_EO_100_CS25    3   3.303 1.3348    199 0.00500 **
mds3dSFW_EO_5000_CS25   3   3.395 1.3721    199 0.01000 **
mydata$Landscape        8   9.573 1.4508    199 0.00500 **
mds3dSFW_TH_10_CS25     3   3.658 1.4785    199 0.00500 **
mydata$LONG.x           1   1.037 1.2569   1399 0.03571 *
Residual              139 114.644                        
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.