Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-28 Thread Julien Clavel
I agree with the others, if your goal is to control for size/mass then I don’t 
see how the “residuals” from an intercept only model will be useful. 

If the relationship between your trait and size is almost isometric, ratios are 
the simplest way to go. 
For ANOVAs, I will simply use size as a covariate to control for it as 
Marguerite proposed. For instance, with a classical ANCOVA design, I would 
enter the size first and then the factor of interest and perform a sequential 
test, or use adjusted tests if there are multiple IVs (with no a priori order) 
including the one you want to ‘control’ for. 
 
Julien 



De : R-sig-phylo  de la part de Marguerite 
Butler 
Envoyé : vendredi 28 mai 2021 09:34
À : Graham Slater 
Cc : r-sig-phylo@r-project.org mailman 
Objet : Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how 
can I rescue residuals corrected by the phylogeny and SE? 
 
Aloha Gabriel,
Joe and Graham have given you very good advice. I just wanted to chime in
to reinforce the point that you should not apply a "phylogenetic
correction" twice on the same set of data!  If youʻve removed the expected
covariance, it is good for an ordinary ANOVA. If you do a phylogenetic
ANOVA that again accounts for phylogenetic covariance, you will INTRODUCE
phylogenetic variance structure into your data.  I really canʻt imagine a
situation that would call for a double accounting of phylogenetic
covariance.

If all youʻre doing is calculating shape variables, why not just take the
ratio with size (SVL)? If it is a mass-dependent trait you can take the
log-ratio with mass (you can divide by 3 if you like but at this point it
is linear). Mass is ~ SVL^3, so you can come up with some rationale. Ratios
are easily interpretable and are not evil, just make sure you donʻt have
severe skew. Usually within a taxonomic group the range of variation is not
that big, so you donʻt have a problem.

Alternatively, you could create shape variables by pgls and then do an
ordinary ANOVA.
Alternatively, you could do OU models such as implemented in OUCH or OUwie
or mvMorph.

Option 1:
pgls - residuals  ->  ordinary ANOVA

Option 2:
regression residuals or ratios -> phylogenetic ANOVA or OU methods

Option 3:
phylogenetic ancova, with size as a covariate.

Marguerite

On Thu, May 27, 2021 at 3:42 PM Graham Slater  wrote:

> I might well be missing something but I think, Gabriel, that you do not
> need to compute any residuals to do what you want to do. In your tail
> length example, you perform a phylogenetic regression to get a
> size-standardized tail length - in this case, the residuals of your pgls
> model. That all makes sense because tail length is expected to vary as a
> function of size but you're interested in the residual variation and
> what explains that. I don't think you care about "correcting for
> phylogeny" at this point in general terms though - you are only
> including phylogeny to get the appropriate evolutionary regression for
> tail~body size from which to  compute tail length residuals. For your
> ratio traits, there is (probably) no meaningful expectation of allometry
> and so there is no need to do this. You can plug these variables
> directly into a phylogenetic ANOVA or macroevolutionary model and
> estimate the appropriate parameters.
>
> Regarding standard errors, most model-fitting functions (fitContinuous,
> mvMorph, OUwie etc) allow you to include a measurement error term, which
> just gets tacked on to the diagonals of the model-transformed
> phylogenetic covariance matrix. It is good to do so, especially when
> fitting OU models.  Phylogenetic ANOVA (a la Garland et al.) uses
> simulation to generate a null distribution of F-statistics to which the
> result of an ordinary ANOVA is compared, so I don't see a
> straightforward way of including standard errors there. A more direct
> approach might be to use a phylogenetic Bayesian multi-level model, as
> implemented in brms or mcmcglmm, where all observations are included and
> species identity is treated as an effect.
>
>
> I've probably missed something, but I hope this helps...
>
>
> Graham
>
> --
>
> Graham Slater [he/him/his]
> Department of the Geophysical Sciences, University of Chicago
> gsla...@uchicago.edu
> (773) 702 0249
> http://www.fourdimensionalbiology.com
>
> On 5/27/21 8:08 PM, Joe Felsenstein wrote:
> > Gabriel Ferreira explained:
> >
> >
> >> I will try to better explain my problem, and I really appreciate your
> time
> >> to help me with this issue.
> >> My study is a conventional ecomorph with linear and univariate
> >> measurements
> >>
> >> So... Some of my traits are linear measures that can and must be
> >> "corrected" by body size, such as tail length. I usually conduct such
> body
> >> size corrections with phylogenetic regressions using *gls *func. from
> >> *nlme*:
> >>
> >  lots of details ...
> >
> >
> >> So I could use the residuals of this regression in the phy ANOVAs ...
> Does
> >> it make sense?

Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-28 Thread Marguerite Butler
Aloha Gabriel,
Joe and Graham have given you very good advice. I just wanted to chime in
to reinforce the point that you should not apply a "phylogenetic
correction" twice on the same set of data!  If youʻve removed the expected
covariance, it is good for an ordinary ANOVA. If you do a phylogenetic
ANOVA that again accounts for phylogenetic covariance, you will INTRODUCE
phylogenetic variance structure into your data.  I really canʻt imagine a
situation that would call for a double accounting of phylogenetic
covariance.

If all youʻre doing is calculating shape variables, why not just take the
ratio with size (SVL)? If it is a mass-dependent trait you can take the
log-ratio with mass (you can divide by 3 if you like but at this point it
is linear). Mass is ~ SVL^3, so you can come up with some rationale. Ratios
are easily interpretable and are not evil, just make sure you donʻt have
severe skew. Usually within a taxonomic group the range of variation is not
that big, so you donʻt have a problem.

Alternatively, you could create shape variables by pgls and then do an
ordinary ANOVA.
Alternatively, you could do OU models such as implemented in OUCH or OUwie
or mvMorph.

Option 1:
pgls - residuals  ->  ordinary ANOVA

Option 2:
regression residuals or ratios -> phylogenetic ANOVA or OU methods

Option 3:
phylogenetic ancova, with size as a covariate.

Marguerite

On Thu, May 27, 2021 at 3:42 PM Graham Slater  wrote:

> I might well be missing something but I think, Gabriel, that you do not
> need to compute any residuals to do what you want to do. In your tail
> length example, you perform a phylogenetic regression to get a
> size-standardized tail length - in this case, the residuals of your pgls
> model. That all makes sense because tail length is expected to vary as a
> function of size but you're interested in the residual variation and
> what explains that. I don't think you care about "correcting for
> phylogeny" at this point in general terms though - you are only
> including phylogeny to get the appropriate evolutionary regression for
> tail~body size from which to  compute tail length residuals. For your
> ratio traits, there is (probably) no meaningful expectation of allometry
> and so there is no need to do this. You can plug these variables
> directly into a phylogenetic ANOVA or macroevolutionary model and
> estimate the appropriate parameters.
>
> Regarding standard errors, most model-fitting functions (fitContinuous,
> mvMorph, OUwie etc) allow you to include a measurement error term, which
> just gets tacked on to the diagonals of the model-transformed
> phylogenetic covariance matrix. It is good to do so, especially when
> fitting OU models.  Phylogenetic ANOVA (a la Garland et al.) uses
> simulation to generate a null distribution of F-statistics to which the
> result of an ordinary ANOVA is compared, so I don't see a
> straightforward way of including standard errors there. A more direct
> approach might be to use a phylogenetic Bayesian multi-level model, as
> implemented in brms or mcmcglmm, where all observations are included and
> species identity is treated as an effect.
>
>
> I've probably missed something, but I hope this helps...
>
>
> Graham
>
> --
>
> Graham Slater [he/him/his]
> Department of the Geophysical Sciences, University of Chicago
> gsla...@uchicago.edu
> (773) 702 0249
> http://www.fourdimensionalbiology.com
>
> On 5/27/21 8:08 PM, Joe Felsenstein wrote:
> > Gabriel Ferreira explained:
> >
> >
> >> I will try to better explain my problem, and I really appreciate your
> time
> >> to help me with this issue.
> >> My study is a conventional ecomorph with linear and univariate
> >> measurements
> >>
> >> So... Some of my traits are linear measures that can and must be
> >> "corrected" by body size, such as tail length. I usually conduct such
> body
> >> size corrections with phylogenetic regressions using *gls *func. from
> >> *nlme*:
> >>
> >  lots of details ...
> >
> >
> >> So I could use the residuals of this regression in the phy ANOVAs ...
> Does
> >> it make sense?
> >>
> >
> > Well, I am afraid I am lost.  Perhaps someone else here could explain the
> > issues to me ...
> >
> >
> > Joe
> > --
> > Joe Felsenstein felse...@gmail.com,  j...@gs.washington.edu
> >   Department of Genome Sciences and Department of Biology,
> >   University of Washington, Box 355065, Seattle, WA 98195-5065 USA
> >
> >   [[alternative HTML version deleted]]
> >
> > ___
> > 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/
>
> ___
> 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/
>


-- 

Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-27 Thread Graham Slater
I might well be missing something but I think, Gabriel, that you do not 
need to compute any residuals to do what you want to do. In your tail 
length example, you perform a phylogenetic regression to get a 
size-standardized tail length - in this case, the residuals of your pgls 
model. That all makes sense because tail length is expected to vary as a 
function of size but you're interested in the residual variation and 
what explains that. I don't think you care about "correcting for 
phylogeny" at this point in general terms though - you are only 
including phylogeny to get the appropriate evolutionary regression for 
tail~body size from which to  compute tail length residuals. For your 
ratio traits, there is (probably) no meaningful expectation of allometry 
and so there is no need to do this. You can plug these variables 
directly into a phylogenetic ANOVA or macroevolutionary model and 
estimate the appropriate parameters.


Regarding standard errors, most model-fitting functions (fitContinuous, 
mvMorph, OUwie etc) allow you to include a measurement error term, which 
just gets tacked on to the diagonals of the model-transformed 
phylogenetic covariance matrix. It is good to do so, especially when 
fitting OU models.  Phylogenetic ANOVA (a la Garland et al.) uses 
simulation to generate a null distribution of F-statistics to which the 
result of an ordinary ANOVA is compared, so I don't see a 
straightforward way of including standard errors there. A more direct 
approach might be to use a phylogenetic Bayesian multi-level model, as 
implemented in brms or mcmcglmm, where all observations are included and 
species identity is treated as an effect.



I've probably missed something, but I hope this helps...


Graham

--

Graham Slater [he/him/his]
Department of the Geophysical Sciences, University of Chicago
gsla...@uchicago.edu
(773) 702 0249
http://www.fourdimensionalbiology.com

On 5/27/21 8:08 PM, Joe Felsenstein wrote:

Gabriel Ferreira explained:



I will try to better explain my problem, and I really appreciate your time
to help me with this issue.
My study is a conventional ecomorph with linear and univariate
measurements

So... Some of my traits are linear measures that can and must be
"corrected" by body size, such as tail length. I usually conduct such body
size corrections with phylogenetic regressions using *gls *func. from
*nlme*:


 lots of details ...



So I could use the residuals of this regression in the phy ANOVAs ... Does
it make sense?



Well, I am afraid I am lost.  Perhaps someone else here could explain the
issues to me ...


Joe
--
Joe Felsenstein felse...@gmail.com,  j...@gs.washington.edu
  Department of Genome Sciences and Department of Biology,
  University of Washington, Box 355065, Seattle, WA 98195-5065 USA

[[alternative HTML version deleted]]

___
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/


___
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/


Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-27 Thread Joe Felsenstein
Gabriel Ferreira explained:


> I will try to better explain my problem, and I really appreciate your time
> to help me with this issue.
> My study is a conventional ecomorph with linear and univariate
> measurements
>

> So... Some of my traits are linear measures that can and must be
> "corrected" by body size, such as tail length. I usually conduct such body
> size corrections with phylogenetic regressions using *gls *func. from
> *nlme*:
>

 lots of details ...


> So I could use the residuals of this regression in the phy ANOVAs ... Does
> it make sense?
>


Well, I am afraid I am lost.  Perhaps someone else here could explain the
issues to me ...


Joe
--
Joe Felsenstein felse...@gmail.com,  j...@gs.washington.edu
 Department of Genome Sciences and Department of Biology,
 University of Washington, Box 355065, Seattle, WA 98195-5065 USA

[[alternative HTML version deleted]]

___
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/


Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-27 Thread Gabriel Ferreira
Hello Sr,

I will try to better explain my problem, and I really appreciate your time
to help me with this issue.
My study is a conventional ecomorph with linear and univariate
measurements

So... Some of my traits are linear measures that can and must be
"corrected" by body size, such as tail length. I usually conduct such body
size corrections with phylogenetic regressions using *gls *func. from *nlme*
:

E.g.gls(trait X ~ body size, correlation=corPagel(1, phy=tree),
data=data, method = "ML")

Then after body size correction, I will use the residuals to conduct
conventional ecomorphological hypotheses tests. At this part I will use
functions that do not allow the inclusion of covariates (as far as I am
aware of, that is why I need residuals), such as phylANOVA (from
*phytools *package)
and evolutionary trait model fitting from Butler and King (from *ouch *
package).
*I believe it worth mentioning that for these linear traits in particular,
I won't include within species variation (SE in this case) because
repeatability tests indicated high R values.*

BUT... I have another set of traits that are ratios (or proportions), so it
is independent of body size. Normally, I would use the log values of this
proportion to directly conduct phylogenetic ANOVAs. But the problem is that
repeatability tests indicated to be low for these proportions, therefore, I
should consider somehow SE in the phy ANOVAs and evolutionary model
fitting.

My rationale was to use the same function of body size correction but
instead of using body size as the predictor, I would fix the intercept at 1
and include SE in the weights argument, e.g.

gls(trait X ~ 1, correlation=corPagel(1, phy=tree), data=data, method =
"ML", weights= SE)

WHERE SE <- varFixed (~1/sqrt(trait X SE))

So I could use the residuals of this regression in the phy ANOVAs ... Does
it make sense?

Thank you again!
Gabriel


Em qui., 27 de mai. de 2021 às 20:39, Joe Felsenstein 
escreveu:

>
> If wants residuals of values of a trait in each species, taking into
> account within-species variation and phylogeny, what does it mean if those
> residuals correlate with those of some other character, or with an
> environmental variable?
>
> Just asking which R machinery to use might wait until it is clear what the
> intended task is and why that makes sense.
>
> Joe
> --
> Joe Felsenstein felse...@gmail.com,  j...@gs.washington.edu
>  Department of Genome Sciences and Department of Biology,
>  University of Washington, Box 355065, Seattle, WA 98195-5065 USA
>
>

-- 
Gabriel Spanghero V. Ferreira
Biólogo | Mestre em Biologia Comparada

[[alternative HTML version deleted]]

___
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/


Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-27 Thread Joe Felsenstein
If wants residuals of values of a trait in each species, taking into
account within-species variation and phylogeny, what does it mean if those
residuals correlate with those of some other character, or with an
environmental variable?

Just asking which R machinery to use might wait until it is clear what the
intended task is and why that makes sense.

Joe
--
Joe Felsenstein felse...@gmail.com,  j...@gs.washington.edu
 Department of Genome Sciences and Department of Biology,
 University of Washington, Box 355065, Seattle, WA 98195-5065 USA

[[alternative HTML version deleted]]

___
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/


Re: [R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-27 Thread Julien Clavel
Hello Gabriel,

If I understand it correctly you're looking for an 'intercept only' model 
(e.g., gls(x~1,...)). The rationale for doing so would be to assess the 
'phylogenetic signal' in your trait 'x'. It will be somehow similar to using 
functions such as, for instance, fitContinuous in geiger.

Regards,

Julien


De : R-sig-phylo  de la part de Gabriel 
Ferreira 
Envoyé : jeudi 27 mai 2021 03:30
À : r-sig-phylo@r-project.org 
Objet : [R-sig-phylo] If my trait X cannot be regressed by body size, how can I 
rescue residuals corrected by the phylogeny and SE? 
 
Hello all,

My questions follows this succinct introduction:

I have a data frame composed of: species, trait X values (means) and SE of
trait X for each species; AND the phylogeny with branch length of the
species.

I would like to know if it is possible to create residuals of the
distribution of trait X that "correct" by the phylogenetic relationship and
SE ??

My rationale followed the fact that its possible to create residuals that
includes SE and the phylogenetic relationship when a trait X is regressed,
for example by body size, therefore using something like:

USING *gls* from *nlme*:

gls(trait X ~ body size, correlation=corPagel(1, phy=tree), data=data,
method = "ML", weights= SE)

WHERE SE <- varFixed (~1/sqrt(traiX_SE))

But, if my trait X cannot be regressed by body size, how can I rescue
residuals corrected by the phylogenetic relationship and SE? Does it make
sense?

Thanks in advance!Hello all,

My questions follows this succinct introduction:

I have a data frame composed of: species, trait X values (means) and SE of
trait X for each species; AND the phylogeny with branch length of the
species.

I would like to know if it is possible to create residuals of the
distribution of trait X that "correct" by the phylogenetic relationship and
SE ??

My rationale followed the fact that its possible to create residuals that
includes SE and the phylogenetic relationship when a trait X is regressed,
for example by body size, therefore using something like:

USING *gls* from *nlme*:

gls(trait X ~ body size, correlation=corPagel(1, phy=tree), data=data,
method = "ML", weights= SE)

WHERE SE <- varFixed (~1/sqrt(traiX_SE))

But, if my trait X cannot be regressed by body size, how can I rescue
residuals corrected by the phylogenetic relationship and SE? Does it make
sense?

Thanks in advance!
Gabriel

    [[alternative HTML version deleted]]

___
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/
___
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/


[R-sig-phylo] If my trait X cannot be regressed by body size, how can I rescue residuals corrected by the phylogeny and SE?

2021-05-27 Thread Gabriel Ferreira
Hello all,

My questions follows this succinct introduction:

I have a data frame composed of: species, trait X values (means) and SE of
trait X for each species; AND the phylogeny with branch length of the
species.

I would like to know if it is possible to create residuals of the
distribution of trait X that "correct" by the phylogenetic relationship and
SE ??

My rationale followed the fact that its possible to create residuals that
includes SE and the phylogenetic relationship when a trait X is regressed,
for example by body size, therefore using something like:

USING *gls* from *nlme*:

gls(trait X ~ body size, correlation=corPagel(1, phy=tree), data=data,
method = "ML", weights= SE)

WHERE SE <- varFixed (~1/sqrt(traiX_SE))

But, if my trait X cannot be regressed by body size, how can I rescue
residuals corrected by the phylogenetic relationship and SE? Does it make
sense?

Thanks in advance!Hello all,

My questions follows this succinct introduction:

I have a data frame composed of: species, trait X values (means) and SE of
trait X for each species; AND the phylogeny with branch length of the
species.

I would like to know if it is possible to create residuals of the
distribution of trait X that "correct" by the phylogenetic relationship and
SE ??

My rationale followed the fact that its possible to create residuals that
includes SE and the phylogenetic relationship when a trait X is regressed,
for example by body size, therefore using something like:

USING *gls* from *nlme*:

gls(trait X ~ body size, correlation=corPagel(1, phy=tree), data=data,
method = "ML", weights= SE)

WHERE SE <- varFixed (~1/sqrt(traiX_SE))

But, if my trait X cannot be regressed by body size, how can I rescue
residuals corrected by the phylogenetic relationship and SE? Does it make
sense?

Thanks in advance!
Gabriel

[[alternative HTML version deleted]]

___
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/