Removing the effects of size

1,166 views
Skip to first unread message

bj...@mail.holar.is

unread,
Mar 26, 2018, 5:20:37 AM3/26/18
to geomorph R package
Hi all

There is one thing I´m wondering about, and perhaps you could come up with some ideas regarding this.  I  am studying morphological variation among different populations of small benthic charr in Iceland.  I have run a morphometric analysis and found out that size is a significant factor in explaining the morphology of these fish. 

Datafr.gdf<-geomorph.data.frame(cave.gpa, caves=caves)
procD.lm(coords~log(Csize),iter=999, data=Datafr.gdf)

I tested if the slopes were homogneous, They were not, but there was no systematic variation when comparing across populations. 

Morph.disgroups<-morphol.disparity(coords~log(Csize)*caves, groups=~caves, data=Datafr.gdf, iter=999)


I took size in to account when comparing morphology of these fish. 

procD.lm(coords~log(Csize)+caves,iter=999, data=Datafr.gdf)

I think all of this is correct way of doing things.   Now I am interested in two things one to describe the differences among the caves using discriminant function analysis's. There I am mostly interested in how well fish can be classified to their own population, and where the mis-classified fish end up. Second I´m interested in the morphological variation among the caves using PCA - 

PCA<-plotTangentSpace(cave.gpa$coords, verbose =T). 

In both cases I can visualize morphology at the extreem of either PCA or DFA axises, using. 
e.g.

DF1pred<-shape.predictor(cave.gpa$coords,Pred.Discr$x[,1], Intercept=FALSE, pred1=-3, pred2=3 )
Mean_morph<-mshape(cave.gpa$coords)
plotRefToTarget(Mean_morph, DF1pred$pred1) #min
plotRefToTarget(Mean_morph, DF1pred$pred2) #max

But how do I remove the effect of size from these visualization?  Can I calculate the residuals of each landmark from a regression of landmark scores and log Centroid size and then use those for such visualization? Similarily, can I use such residual landmarks for the DFA analysis and the PCA calculations?  I´m not planing to do any statistical analysis with the PCA scores, only for visualization of  how mean scores of populations are distributed, and how that is related to morphology. 

Thanks in advance

Bjarni 

Antigoni Kaliontzopoulou

unread,
Mar 26, 2018, 7:32:58 AM3/26/18
to geomorph-...@googlegroups.com
Dear Bjarni,

yes, one could take the residuals of a linear model for further analyses, and those residuals would be "corrected" for the terms included in the model. You would just need to add back the consensus for visualization, because the residuals are from a model that includes an intercept and will not resemble the structure you are studying unless you do that.

Of course, some thinking is required to decide which is the model you want to use, especially if you have different slopes for your groups. BTW, morphol.disparity does not test for homogeneity of slopes, please consult the help file of that function carefully. Also notice that the statistics of a discriminant analysis are MANOVA statistics, and will thus give you the same answer as a linear model (although I would argue that using procD.lm for that also gives you the advantage of hypothesis testing based on permutation of residuals).

Hope this helps
Antigoni
--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/7cbf0db0-7fe5-4593-9ecc-89edfaa71cdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
-------------------
Antigoni Kaliontzopoulou

Assistant researcher

CIBIO, Centro de Investigacao em Biodiversidade e Recursos Geneticos

Campus Agrario de Vairao, 4485-661 Vairao

PORTUGAL

http://cibio.up.pt/people/details/akaliont
http://antigonik.wix.com/akaliontzopoulou

Mike Collyer

unread,
Mar 26, 2018, 8:11:03 AM3/26/18
to geomorph-...@googlegroups.com
Bjarni,

As Antigoni mentioned, one can use residuals (plus average shape) as allometry-corrected shapes, but this should only true if one establishes that a common-allometry model is appropriate; i.e., shape ~ size + group.  If you find you have heterogenous allometries ( shape ~ size + group + size x group is a better model), then you cannot correct for allometry.  

It seems you desire to perform DFA is for classification of individuals to groups?  If you have heterogenous allometries, you must realize that it is insufficient to ask, “To which group should this individual be classified based on its shape?”  Rather, you must then ask, “To which group should this individual be classified based on its shape, given its size?”  The latter recognizes that the classification posterior probabilities are much more complex, as prior probabilities are based on group shape distinction as it varies with size.  For example, maybe at small sizes, one cannot predict group but at larger sizes it becomes easier.

If you have heterogenous allometries, please try to abandon a lumping or splitting focus and focus more so on whether groups converge in shape or diverge in shape as they grow larger.  This is what a model with significant variation in allometries among groups would encourage you to do.

Cheers!
Mike

Sergio Ferreira Cardoso

unread,
Mar 27, 2018, 7:54:40 AM3/27/18
to geomorph R package
Dear Michael,

So, you suggested shape ~ size + group + size x group is the best model to do the homogeneity of slopes test. If we want to test if slopes are parallel, then something like this would be the most appropriate: advanced.procD.lm(shape ~ log(cs)+gp, ~log(cs)*gp, groups = ~gp, slope = ~log(cs), angle.type = "deg", iter = 4999, data = gdf, print.progress = FALSE). On a previous intervention here in the group (https://groups.google.com/forum/#!msg/geomorph-r-package/1jXm_6dNE3A/DwZYD7t0AwAJ;context-place=forum/geomorph-r-package) I suggested something like this: advanced.procD.lm(shape ~ log(cs), ~log(cs)*gp, groups = ~gp, slope = ~log(cs), angle.type = "deg", iter = 4999, data = gdf, print.progress = FALSE). 

For instance, with my data they retreave different results. I don't completely understand what is the difference between f1=shape ~ log(cs)+gp, f2=~log(cs)*gp and f1=shape ~ log(cs), f2=~log(cs)*gp.

Thank you.
Mike

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.


-- 
-------------------
Antigoni Kaliontzopoulou

Assistant researcher

CIBIO, Centro de Investigacao em Biodiversidade e Recursos Geneticos

Campus Agrario de Vairao, 4485-661 Vairao

PORTUGAL

http://cibio.up.pt/people/details/akaliont
http://antigonik.wix.com/akaliontzopoulou


--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.

Mike Collyer

unread,
Mar 27, 2018, 8:01:34 AM3/27/18
to geomorph-...@googlegroups.com
Sergio,
>
>
> For instance, with my data they retreave different results. I don't completely understand what is the difference between f1=shape ~ log(cs)+gp, f2=~log(cs)*gp and f1=shape ~ log(cs), f2=~log(cs)*gp.

The former has a null model with different intercepts for groups and tests only the interaction, which is homogeneity of slopes test. The latter forces all groups to have the same intercept in the null model (no groups at all) and tests the variation associated with different group slopes AND intercepts. This is not a homogeneity of slopes test. It is a test to compare a global allometry to individual group allometries. A homogeneity of slopes test normally allows for different intercepts. A subtle but distinctly different set of tests.

Arguments could be made for doing either, but the point is that if the variation is significant, one should not look for ways to remove allometric variation but instead focus on WHY the variation is significant, which you did with your pairwise arguments (groups and slope).

Cheers!
Mike

Sergio Ferreira Cardoso

unread,
Mar 28, 2018, 10:08:14 AM3/28/18
to geomorph R package
Michael,

I appreciate your help.

Cheers,
Sérgio.

Sergio Ferreira Cardoso

unread,
May 11, 2018, 4:40:06 AM5/11/18
to geomorph R package
Dear all,

I come back here with a quick question. I'm looking at my data and, graphically, there is some thing that does not make sense to me. So here I have the p-values for the tests of (angular) difference of slopes between groups:

       1      2      3      4      5      6      7
1 1.0000 0.4357 0.4626 0.5756 0.5064 0.4181 0.3006
2 0.4357 1.0000 0.0346 0.0759 0.9415 0.2310 0.1528
3 0.4626 0.0346 1.0000 0.0133 0.7792 0.8602 0.0476
4 0.5756 0.0759 0.0133 1.0000 0.0791 0.3209 0.0299
5 0.5064 0.9415 0.7792 0.0791 1.0000 0.4361 0.3912
6 0.4181 0.2310 0.8602 0.3209 0.4361 1.0000 0.3800
7 0.3006 0.1528 0.0476 0.0299 0.3912 0.3800 1.0000



As I look at the graph I would expect to have species 1 and 6 to present a large amount of significant differences given that they look like they have a completely difference slope compared to the remaining ones. However, none of these species presents any significant difference of slope angle. In fact, as you can see, low p-values are present for species with very slight differences.

Am I doing the correct interpretation? Should I not expect to have significant differences for species 1 and 6 instead of the others?

Thank you once again.

 

On Tuesday, 27 March 2018 14:01:34 UTC+2, Michael Collyer wrote:

Mike Collyer

unread,
May 11, 2018, 7:15:18 AM5/11/18
to geomorph-...@googlegroups.com
Sergio,

Two (maybe three) observations.

First, only group 3 looks to be qualitatively much different than the others.  I see no slope for this group compared to the arbitrarily positive slopes of the others.  (Keep in mind there is no positive or negative, other than the arbitrary assignment of such for PC 1).  As this group has such a small sample size, I would not give this difference much credit.

Second, these are fitted values and do not show the dispersion of individual values around the lines.  One of the other plotting options might give you a sense of the goodness of fit for each line.  Groups 6 and 7 might be quite variable, so although the lines look to have different slopes, the fits might not be that good, and there is a high probability fo finding greater differences by chance sampling.  Also, the ANOVA table gives you a Z-score (I am assuming small) and Rsq value (also assuming small) which might indicate that although you have “significant” group slope differences, the effect size is not that large.  Remember that P-values are not the whole story.

Cheers!
Mike

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.

To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

Sergio Ferreira Cardoso

unread,
May 11, 2018, 8:17:52 AM5/11/18
to geomorph R package
Hello Mike,

Thank you once again for your answer. Ok, I understood your points. 
But taking into account this slightly enlarged data set. In fact the R2 is quite low (0.1673) but the Z is quite high (12.8038). In terms of Effects sizes my maximum value is 2.55, which is actually quite high. Given the graphs and the R2, I'm tempted to say that all 7 species present paralell slopes (again, as in the previous example, the sample is quite low for species 1, so the same would apply). However, I'm not sure that these arguments are enough to stand against a significant p value in this situation.

> HOS$anova.table
                                              Df        SSE            SS           R2          F          Z         Pr(>F)    
Y ~ log(cs) + gp                    170  0.52055                                           
Y ~ log(cs) + gp + log(cs):gp 164  0.49690   0.023655  0.016735  1.3012  12.804   1e-04 ***


Effects sizes (Z)
             1                   2                 3                   4                5                6              7
1  0.000000000  0.08483629  0.000168779 -0.2667358 -0.06844792  0.1559264 0.4429047
2  0.084836291  0.00000000  2.015417211  1.5124228 -1.41845166  0.6985162 1.0105763
3  0.000168779  2.01541721  0.000000000  2.5533102 -0.80842337 -1.0441285 1.8734163
4 -0.266735789  1.51242278  2.553310211  0.0000000  1.51482488  0.3956992 2.1390078
5 -0.068447920 -1.41845166 -0.808423371  1.5148249  0.00000000  0.1113059 0.1922597
6  0.155926447  0.69851620 -1.044128492  0.3956992  0.11130590  0.0000000 0.2121663
7  0.442904651  1.01057634  1.873416260  2.1390078  0.19225974  0.2121663 0.0000000

P-values
          1         2         3        4          5        6         7
1 1.0000 0.4357 0.4626 0.5756 0.5064 0.4181 0.3006
2 0.4357 1.0000 0.0346 0.0759 0.9415 0.2310 0.1528
3 0.4626 0.0346 1.0000 0.0133 0.7792 0.8602 0.0476
4 0.5756 0.0759 0.0133 1.0000 0.0791 0.3209 0.0299
5 0.5064 0.9415 0.7792 0.0791 1.0000 0.4361 0.3912
6 0.4181 0.2310 0.8602 0.3209 0.4361 1.0000 0.3800
7 0.3006 0.1528 0.0476 0.0299 0.3912 0.3800 1.0000


















Mike

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.

Ian Dworkin

unread,
May 11, 2018, 1:04:04 PM5/11/18
to geomorph R package
Sergio,

 I know that Mike and Dean have recently updated how they estimate the effect size (Z score) in geomorph, so I am not in a position to speak to that (Mike what should I read to understand how it has been updated?). However, I would say that given that coefficient of determination for the interaction term is on the order of 1.5%, I would suggest re-examining the angles (and associated p-values) between the allometry vectors. If the angles (vector correlations) are close to zero  (one), and p-values also not close to your alpha, you probably can make an argument for a shared allometry with several important caveats:

1) That your sample sizes within each group (your gp variable) are reasonable for estimating the allometric relationship between shape and size. 
2) That you have captured a substantial amount of the variation within each group for size.

If both of these are "true" then you probably have a reasonable amount of uncertainty associated with your estimates of the allometric vector and can proceed. However, if either the within group sample size is small and/or the amount of size variation is small, then the magnitude of the allometry vector may be small (a short vector), which usually results in a poorly estimated direction of allometric effects. I am curious, what is the coefficient of determination (R^2) for the model with just shape ~ csize + gp ?

Cheers
Ian 

Mike

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph-r-package@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ian Dworkin
Department of Biology
McMaster University

Adams, Dean [EEOBS]

unread,
May 11, 2018, 1:30:08 PM5/11/18
to geomorph-...@googlegroups.com

Sergio,

 

Ian emphasizes an important point that echoes Mike’s response. The pairwise comparisons are of more importance here, not the overall test of the interaction term.  If you examine the matrix of pairwise effect sizes, most of these are quite small, and their corresponding significance levels are not significant. That tells you that the evidence for differences in slopes is generally quite weak (in this case, it may be driven by one or 2 pairwise comparisons: see your pairwise matrices). From my perspective that provides stronger information regarding the type of biological signal in your data and where it resides.

 

Ian, regarding effect size calculations, a major difference occurred starting in geomorph 3.0.5. Now we obtain effect sizes as:  observed – mean(permutation)  / std error.   This adjustment was made because we found that some statistics could vary size sample size and variable number, and so basing the effect size on the expected value from the permutation distribution was the more robust approach (see Adams and Collyer 2016: Evol.). This differs from the previous implementation which was based on Collyer et al. 2015 (Heredity) where the expected value was treated as a constant that did not vary with these components in the data (see passage in help file for procD.lm as well as above papers).

 

Dean

 

Dr. Dean C. Adams

Director of Graduate Education, EEB Program

Professor

Department of Ecology, Evolution, and Organismal Biology

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

Mike



--

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.

 

--

You received this message because you are subscribed to the Google Groups "geomorph R package" group.

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.


To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.



 

--

Ian Dworkin
Department of Biology
McMaster University

--

You received this message because you are subscribed to the Google Groups "geomorph R package" group.

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.


To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

Ian Dworkin

unread,
May 11, 2018, 1:51:40 PM5/11/18
to geomorph R package
Dean,

Thanks so much, that explains it, and may I say, a very neat idea. I definitely have to think about it further (I will re-read the 2016 paper in Evolution). Thanks so much.

Ian

Mike



--

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.

 

--

You received this message because you are subscribed to the Google Groups "geomorph R package" group.

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph-r-package@googlegroups.com.



 

--

Ian Dworkin
Department of Biology
McMaster University

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph-r-package@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph-r-package@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sergio Ferreira Cardoso

unread,
May 15, 2018, 3:59:01 AM5/15/18
to geomorph R package
Thank you so much Ian, Michail and Dean. I was a bit lost because graphically I could not detect slope heterogeneity. 
I'm more sure now of how I should interpret my results.

Cheers

--

To post to this group, send email to geomorph...@googlegroups.com.



 

--

Ian Dworkin
Department of Biology
McMaster University

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

guiye...@gmail.com

unread,
Oct 14, 2020, 7:50:14 AM10/14/20
to geomorph R package
Hi Antigoni, 

I was reading this thread and I wanted to ask you something you mentioned here: how do you calculate those pgls-terms-corrected shapes, a.k.a residual shapes? Is it by summing each coordinate's residual to the mean coordinates?

Antigoni Kaliontzopoulou

unread,
Oct 14, 2020, 8:22:35 AM10/14/20
to geomorph-...@googlegroups.com
Precisely!

Note that the addition of the mean does not make a difference for downstream analyses, but you do need it for visualization, i.e. for producing deformation grids etc.

Antigoni
----- Original Message -----
From: guiye...@gmail.com <guiye...@gmail.com>
To: geomorph R package <geomorph-...@googlegroups.com>
Sent: Wed, 14 Oct 2020 12:50:14 +0100 (WEST)
Subject: Re: [geomorph-r-package] Removing the effects of size

> <https://groups.google.com/d/msgid/geomorph-r-package/7cbf0db0-7fe5-4593-9ecc-89edfaa71cdd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> -------------------
> Antigoni Kaliontzopoulou
>
> Assistant researcher
>
> CIBIO, Centro de Investigacao em Biodiversidade e Recursos Geneticos
>
> Campus Agrario de Vairao, 4485-661 Vairao
>
> PORTUGAL
> http://cibio.up.pt/people/details/akalionthttp://antigonik.wix.com/akaliontzopoulou
>
>

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/1b2876be-e09a-4b32-a8a9-0b6e6a650b88n%40googlegroups.com.

--
​--


Antigoni Kaliontzopoulou

Assistant Researcher
CIBIO/InBIO, Centro de Investigação em Biodiversidade e Recursos Genéticos
University of Porto
Campus Agrário de Vairão, 4485-661 Vairão
PORTUGAL

https://cibio.up.pt/research-groups-1/details/phenevol
http://antigonik.wix.com/akaliontzopoulou
http://cibio.up.pt/people/details/akaliont

Guillermo Navalón

unread,
Oct 14, 2020, 8:27:51 AM10/14/20
to geomorph-...@googlegroups.com
Great!

Thanks for the (much needed) confirmation!

Have a nice day ;)

Reply all
Reply to author
Forward
0 new messages