Jin Yung,
Before sorting out an R-code equivalent for what MorphoJ does, I recommend that
you revisit and re-read the last few posts on Morphmet concerning statistical
and biological significance of comparisons of slopes. The important thing to
determine first and foremost is whether or not the significant interaction term
in your model is biologically meaningful (ie, does it represent the underlying
patterns in the data or is it spurious for some reason). If it does represent
the underlying patterns in your data, than any pooled-group or common
regression-based allometric residuals makes no sense.
Think of it this way: both a common slope model and a pooled within-group model
assume that patterns of within-group covariation are equivalent (‘the same’ in
vernacular speech). If that assumption can be made, then one can fit a common
slope or pooled-within group model and obtain so-called allometry-free
residuals. However, if the groups really do have different slopes, that means
the within-group allometric trajectories are different. In this case it makes
no sense to obtain allometric residuals from a common slope model, or a
pooled-within group model, as these models do not account for the different
shape~size relationships in each group. Thus, the common-slope analysis is not
accounting for the actual allometric patterns in any of the groups. What that
means is that the residuals for group A are not residuals from the shape~size
allometric relationship in group A, but rather are the allometric residuals of
this group +/- the difference in that groups’ slope versus the common-slope
model. And likewise for group B, group C, etc. Importantly, note that the
difference in actual within-group residuals from common-slope residuals is not
a constant across groups: meaning that there is no way to make these residuals
comparable units for downstream analyses.
Additionally, obtaining residuals from a separate slopes model (i.e., a model
containing the interaction term, as you have in your post) also makes little
sense because here the residuals are obtained from different allometric
trajectories for each group. Thus, those residuals are not comparable, because
they have accounted for a different shape~size relationship for each group. In
other words, they are residuals of different models for each group, and are not
comparable units for subsequent analyses either.
Thus it is ONLY the case that allometric residuals can be used in downstream
analyses when those groups are deemed to have a common allometric slope. When
they do not, allometric residuals from a common model or separate models,
should not be placed together and used in subsequent analyses.
What I’m getting at here is that when the allometric slopes between groups
truly are different, then biology has changed your question. The question now
is in understanding how those allometric trajectories differ, not whether the
groups differ in the allometric residuals themselves. That is not always what
the biologist sets out to ask, but sometimes the data tell us what we should be
asking. Data has a funny way of refocusing our gaze to the questions we should
have asked!
‘The data are’ as the great Dr. Sokal told many of us over the years.
Hope this helps.
Best,
Dean
Dr. Dean C. Adams
Professor
Department of Ecology, Evolution, and Organismal Biology
Department of Statistics
Iowa State University
www.public.iastate.edu/~dcadams/<http://www.public.iastate.edu/~dcadams/>
phone: 515-294-3834
From: wongjinyung [mailto:[email protected]]
Sent: Tuesday, December 13, 2016 7:53 AM
To: MORPHMET <[email protected]>
Subject: [MORPHMET] allometry adjustment in R
Dear all,
My goal is to carry out allometry adjustment to produce 'allometry-free' shapes
and visualize the result. This has been brought up a lot recently, but I still
wish to check whether what I did was correct, both in terms of concepts and
implementation.
Currently I'm doing allometry adjustment in R in this way (without taking group
into consideration):
mod1 <- lm(shape ~ size)
mean.shape <- apply(shape, 2, mean)
allometry.free.shape <- t(apply(mod1$residuals, 1, `+`, mean.shape))
But I also have a factor (let's call it 'group'). When I run Procrustes ANOVA
using procD.lm in geomorph, both group and size:group terms are significant,
and HOS test in procD.allometry is significant too. If I want to take this into
consideration to get the allometry free shape, what can I do?
I came across MorphoJ's procedure of pooled within group regression and I think
maybe this is what I am looking for (side note: I'm very confused on the
difference between what I read from the discussion on this forum some time
ago<https://groups.google.com/a/morphometrics.org/forum/#!topic/morphmet/K7vtiKl2xhI>
and MorphoJ's explanation on pooled within group regression, I am not good in
stats). Following is the explanation from MorphoJ's user
manual<http://www.flywings.org.uk/MorphoJ_guide/frameset.htm?covariation/regression.htm>:
The bottom element is for selecting a pooled within-group regression. This type
of regression is suitable, for instance, for removing the effect of
within-group variation of a variable such as size, age or environmental factors
before comparisons between groups. The analysis is performing a regression
using the deviations of the dependent and independent variables from the
respective group means (the group means are added back to the residuals and
predicted values in the output dataset).
How can I do this in R? This is what I have came out with:
mod2 <- lm(shape ~ group)
mod3 <- lm(shape ~ size * group)
allometry.free.shape <- mod3$residuals + predict(mod2)
The output visualization made sense but I am not confident. Did it do what
MorphoJ does? If it was wrong, how can I do it? And is it conceptually correct
to get allometry free shapes this way for data with significant size:group
interaction?
Many thanks
Cheers,
Jin Yung
--
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
---
You received this message because you are subscribed to the Google Groups
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
--
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
---
You received this message because you are subscribed to the Google Groups
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].