Hi everyone,
Since I've noticed this problem has been seen before, I figured I would
update the list with my potential solution.
The problem was that the pgls breaks multi-state categorical variables into
a number of binary variables (like shown by the summary function).
This increases the number of variables that the anova then tries to iterate
over, but there are fewer variables in the formula, so it hits an error
where it doesn't know what other variables to include. I fixed this by
having it iterate over the number of variables in the formula rather than
the number of binary variables.
I've attached the fixed anova.pgls script here.
It's been working for me and two other users confirm that it is working for
them as well.
If you do use the script and it solves your problems, please let me know.
-Will


On Sat, Mar 7, 2015 at 10:20 PM, William Gearty <wgea...@stanford.edu>
wrote:

> Hi all,
> I've noticed that a number of people have had this problem, but can't seem
> to find any resolutions.
> I am running a PGLS analysis, with body size as the dependent variable,
> and two categorical traits as the explanatory variables:
>
>> data.pgls <- pgls(MeanBodyMass ~ Habitat_aq * TrophicLevel, species.comp,
>> lambda='ML', delta='ML')
>>
> The pgls runs without any problems, and summary(data.pgls) gives proper
> results.
> However, when I run anova(data.pgls), I get the following error:
>
>> Error in terms.formula(formula, data = data) :
>>   invalid model formula in ExtractVars
>
> My trophic level categorical explanatory variable is multistate (not
> binary), so the anova results are much preferred to the summary results
> (which splits multistate variables into a number of binary ones).
> Has anyone run into this problem before and has found a fix or workaround?
> Thanks once again in advance,
> Will
>
> --
> William Gearty
> PhD Student, Paleobiology
> Department of Geological and Environmental Sciences
> Stanford School of Earth, Energy & Environmental Sciences
> people.stanford.edu/wgearty
>



-- 
William Gearty
PhD Student, Paleobiology
Department of Geological and Environmental Sciences
Stanford School of Earth, Energy & Environmental Sciences
people.stanford.edu/wgearty

Attachment: anova.pgls.fixed.r
Description: Binary data

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to