Hi Marko, 

good points and thank you for having implemented a new function; 

coli null distribution is based on a uniform distribution, not from the data. 
after my errata: its alternative is : the angle is smaller than by comparing a 
random distribution -> patterns are similar. note that modelling the null 
hypothesis (distribution of different angles) is uneasy, because we can not 
have a clear idea about how much they should differ, the uniform distribution 
of random vector is one choice among many other. 

the procedure described in Tzeng and Yeh is different but might look more 
"trustable" because it is building the distribution of angles based on the 
sample, rather than on an adhoc distribution. the null hypothesis: no 
differences among groups (the two groups can be interchanged). the alternative 
is that groups differ in their patterns. 

so it seems you interpreted well the output of tests. 

well now, interpreting p-values...the risk of rejecting the null hypothesis 
while it is true can be estimated (it is the p-value), but the risk of 
"conserving" it while it is wrong (Tzeng and Yeh. write "accept" it), is not 
known. 

I understand that this can make you confused because the interpretation of 
p-values seems to be in disagreement. 

from coli, we conclude that angles are similar enough when comparing to the 
angle expected between two random vectors (taken from a uniform distribution). 
The problem is that taking random vectors made by random vectors is maybe not 
completely realistic to draw the null distribution... but what kind of other 
distribution can we take ? the second problem is that sampling effort is not 
taken into account in coli.... 

from coli.perm, we conclude that angles between PC1 are greater than from 
randomizing individuals. The problem is that if females and males differ in 
shape, introducing females and males in each group will generate an artificial 
allometric component (in other terms: the first randomized axis will correspond 
to a kind of intergroup difference axis rather than a random intragroup axis (I 
am not sure if I explain that well), and the angle risk always to look rather 
small). A solution would be to first center males and females matrices before 
to do the permutations as one here in the function coli.perm3 

Here are some scripts applied to the problem, feel free to comment, 
I also took the freedom to rewrite coli.perm to optimize it a bit (I dropped 
the graphical part as well as it is easily obtainable). 
group is a binary factor. 

#load the data 
library (ade4) 

data ("tortues") 
turtles <- log (tortues[,1:3]) 
sex <- factor (tortues$sexe) 

#Angle: needed for the two other functions... 
Angle <- function (v1, v2) { 
90 - abs ((180 * (acos (sum (v1 * v2) / (sqrt (sum (v1^2)) * sqrt (sum 
(v2^2))))) / pi) - 90) 
} 

#function performing Tzeng and Yeh approach, with group being a binary factor 
coli.perm2<- function (data, group, nperm = 10000) 
{ 
n1<-table(group)[1] 
n2<-table(group)[2] 
pc11<-prcomp(data[group==levels(group)[1],])$rotation[,1] 
pc12<-prcomp(data[group==levels(group)[2],])$rotation[,1] 
obs<-abs(Angle(pc11, pc12)) 
randang<-NULL 
for (i in 1:nperm) 
{groups<-sample(group) 
randang[i]<-abs(Angle(prcomp(data[groups==levels(groups)[1], ])$rotation[,1], 
prcomp(data[groups==levels(group)[2], ])$rotation[,1])) 
} 
pval <- (sum(obs<randang)+1)/(nperm+1) 

res <- list (obs=obs, pval=pval, null.dist=randang) 
} 

#reworked function of Tzeng and Yeh if groups are different in shape 
coli.perm3<- function (data, group, nperm = 10000) 

{ 
n1<-table(group)[1] 
n2<-table(group)[2] 
pc11<-prcomp(data[group==levels(group)[1],])$rotation[,1] 
pc12<-prcomp(data[group==levels(group)[2],])$rotation[,1] 
obs<-abs(Angle(pc11, pc12)) 
randang<-NULL 
ndata<-rbind(scale(data[group==levels(group)[1],], scale=F), 
scale(data[group==levels(group)[1],], scale=F)) 
for (i in 1:nperm) 
{groups<-sample(group) 
randang[i]<-abs(Angle(prcomp(ndata[groups==levels(groups)[1], ])$rotation[,1], 
prcomp(ndata[groups==levels(group)[2], ])$rotation[,1])) 
} 
pval <- (sum(obs<randang)+1)/(nperm+1) 

res <- list (obs=obs, pval=pval, null.dist=randang) 
} 

coli.perm3(turtles, sex, nperm = 10000)$pval 
#[1] 0.0689931 
###we cannot say that they differ but this is marginal. 

going back to isometric growth or allometric growth, there are plenty of 
strategies available in addition to the one you tried. 

if your idea is to check whether males and females differ in terms of growth 
pattern, the one I would certainly prefer is the use log shape ratio and 
combine it with pca to drop the null dimension. you can compare if both groups 
have similar growth patterns by manova using log size as explanatory variable. 

size<-apply(tortues[,1:3], 1, prod)^(1/3) 
logshaperatio<-log(tortues[,1:3]/size) 
anova(lm(prcomp(logshaperatio)$x[,1:2]~ sex * log(size))) 

#pvalue is 0.09 (pvalue is marginal...), but if you put your cut at 0.05, you 
do not reject the null hypothesis (we can not conclude that turtles differ in 
general growth but this is marginal: you can compare that with the results 
above) 

testing for the presence of allometries within sex you can test whether the 
slope coefficient between log shape ratio and 1. 
or you can also test if allometric coefficient are different one by one. 

summary(lm(log(tortues[sex=="F",1])~log(size)[sex=="F"])) 
#partial output for females: coefficient and std error 
#log(size)[sex == "F"] 1.07573 0.03374 31.881 <2e-16 *** 
summary(lm(log(tortues[sex=="M",1])~log(size)[sex=="M"])) 
#output 
#log(size)[sex == "M"] 1.19133 0.03857 30.885 <2e-16 *** 

###each group contains 24 observations 
# the pvalue is obtained by using the t distribution of the statistics at n-2 
df 
#allometry regarding first measurment for F? 
1-pt((1.07573 - 1) / 0.03374, 22) 
[1] 0.01759256 
#the first turtle dimension for females present a significant allometry 
(positive one) 

#difference in growth for the first dimension between males and females 
# the pvalue is obtained by using the t distribution of the statistics at n-4 
df 
1-pt((1.19133- 1.07573)/sqrt(0.03374^2+0.03857^2), 48-4) 
#they differ ... these discrepancies might come from the fact that we use 
linear models and that normality, homoscedasticity or absence of 
autocorrelation in residuals are not meet in the models... 

###if you do not want to have these problems, you can play with adonis of 
vegan. 
library(vegan) 
adonis(logshaperatio~ sex * log(size), method="euclidean", permutations=10000) 
###p value is marginal here too (even closer from significance...).... 

to conclude, most pvalues are marginal, you cannot "really" conclude that the 
allometry pattern differ.... but the absence of significance maybe come from 
the small sample size. As seen above, depending on strategies, results differ. 
If your idea is to merge males and females in a single group, it would be wiser 
to be conservative and consider that assumptions might not be met to do so. 

best regards, 

Julien 

> De: "Marko Djurakic" <[email protected]>
> À: "Morphmet" <[email protected]>
> Envoyé: Lundi 14 Mars 2022 15:24:11
> Objet: [MORPHMET2] Null hypothesis in tests that compare the angular 
> difference
> between vectors (in traditional, linear morphometrics)

> Dear Morphmetricians,

> I want to compare statistically if two vectors of PC1 loadings differ in terms
> of their direction which can be measured by the angle between them.

> Over the years similar questions appear over morphomet (e.g. [
> https://www.mail-archive.com/[email protected]/msg02270.html | 
> thread1
> ] , [ https://www.mail-archive.com/[email protected]/msg02148.html |
> thread2 ] , ...) but they are mostly related to geometric morphometrics
> approaches (e.g. approach used in MorphoJ, part of PTA in geomorph, or
> customized approaches provided in papers outlined in [
> https://www.mail-archive.com/[email protected]/msg02276.html | this
>          Dean Adams' post ] ). It might be important to mention that MorphoJ 
> and geomorph
>          treat the null hypothesis (H0) differently when comparing angles 
> (e.g. see [
>          
> https://www.researchgate.net/post/Does-anyone-have-experience-with-vector-analysis-and-3D-data-in-MorphoJ
>           | the
>          post of  ] [
>          
> https://www.researchgate.net/post/Does-anyone-have-experience-with-vector-analysis-and-3D-data-in-MorphoJ
>           | Miriam
>          L. Zelditch on RG ] ), so one should be aware of potential 
> differences in
>           results even though the same data have been used.

> In this post, I would like to compare if males and females differ in their
> (multivaraite) size which is defined as a vector of PC1 loadings obtained from
> decomposition of covariance matrix (not correlation) of log transformed linear
> distances ( [ https://morphometrics.uk/PDF_files/WhiteBook.pdf | Klingenberg,
> 1996 ] ). Such PC1 vector of logged variables corresponds to a growth-axis,
> recording both isometric and allometric variations. If groups (e.g. sexes)
> share the same overall size - PC1 loadings of sexes have similar direction
> statistically speaking - it is reasonable to treat PC2-PCn as descriptors of
> overall shape (e.g. they correspond to variation not explained by general
> growth) of animals and "analytical" size-correction (e.g. PCA shearing method)
> is possible, yet this approach has limitations (see [
> https://www.researchgate.net/publication/7176310_Size_correction_Comparing_morphological_traits_among_populations_and_environments
> | McCoy et al., 2006 ] among others).

> If I understood correctly, two questions (or assumptions) are important here:

> 1) Is a vector of PC1 loadings for each sex isometric (in other words 
> colinear?)

> 2) PC1 loadings between sexes are pointing in same direction as otherwise
> "size-correction" will be biased just because groups do not share common size
> axis.

> The first assumption is explained and coded in the book [
> https://www.researchgate.net/publication/258885152_Morphometrics_With_R |
> "Morphometrics
>          with R" ] written by [
>          
> https://www.researchgate.net/publication/350439729_Rfunctions1_R_functions_for_geometric_morphometrics_developed_in_Claude_J_2008_Morphometrics_with_R?_sg%5B0%5D=R6_3W-64FZ3h43VzvFZh02awzYTBePhLB2hxLM3Tpoqeb0H2D5-xl4ZgiW5kn_xyQX7vqs_v4qrB67eqEXAOF9LseEVn3jo8NDHNJ0D0.NRfonsjUFiXnahK4ajI4NPb-t5OufVpHlO8TyNgfZo2v1f5dXnNe-hpILpjNZFCtMIgVaPq0wY7TsjSU9RAdmw
>           | Julien Claude (pages
>          103-104) ] . Function name is "coli" and according to text from the 
> book it
>          evaluates a possible statistic for isometry. More specifically, the 
> function
>          tests if sex-specific PC1 loadings differ from theoretical isometric 
> vector ( i
>          ) which has the same length (number of elements, p ) as the length 
> of PC1
>          loadings but all values in i are identical to 1/sqrt (p) . I will 
> treat this as
>           a "Test 1".

> The second assumption can be tested with permutations explained in the work 
> of [
> https://zoolstud.sinica.edu.tw/Journals/38.1/10.pdf | Tzeng and Yeh (1999) ]
> which used randomization in order to access statistical significance of
> observed angle between two vectors. I will treat this test as as a "Test 2".

> For the demonstration purpose and reproducibility I will use dataset of three
> linear measurements on 48 turtles (24 males and 24 females) ( [
> http://pbil.univ-lyon1.fr/ADE-4/ade4-html/tortues.html | Jolicoeur and
>            Mosimann, 1960 ] ). Codes for functions (coli and coli.perm) as 
> well as
>            downstream analyses with reproducible results are in the 
> "functions and
>             example.txt" file attached in this email.

> -------------------------------------------------------------

> run the code form the "functions and example.txt" file attached

> or see results provided in the file.

> -------------------------------------------------------------

> Questions:

> 1. Is the H0 for Test 1 as follows: "Two vectors are not colinear (not 
> similar)
> no more than expected by chance (randomness)?" Likewise, if we reject H0, we
> can say that two vectors are colinear and PC1 vector follows theoretical
> isometry. Is this correct? What is puzzling me is the part related to
> calculation of p value: it is "H0 < observed" but not "H0 > observed"...

> 2. In accordance to Test 2, H0 is defined as: "The null hypothesis that we 
> want
> to test is that the 2 first eigenvecters are the same (pointing in the same
> direction?)." If so, given that we rejected H0 in "test2", we can conclude 
> that
> males and females do not share the common size axis. Therefore, if one would
> like to use PCA shearing method it would be problematic here and other methods
> might be used instead each having it's own limitation (CPCA,
> Burnaby-Back-Projection and so on...).

> 3. If we compare "test2" and "try" objects (PC1 males vs. PC1 females) we came
> up with similar p values (test2: p = 0.0013 and try: p = 0.009) but their
> conclusions are not the same. For instance, if we apply verbal argumentation
> Test 2 says "PC1 vectors of sexes are not pointing in the same direction" and
> test "try" says "PC1 vectors of sexes are colinear". This sounds
> counter-intuitive... or not. I am kind of lost what are H0 for those tests.
> Does this test "try" have any relations to the "test2" at all in terms of
> conclusions and are they even comparable?

> -------------------------------------------------------------

> I appreciate any input.

> Kind regards,

> Marko

> --
> 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 [ mailto:[email protected] |
> [email protected] ] .
> To view this discussion on the web visit [
> https://groups.google.com/d/msgid/morphmet2/9c418b9f-6a10-4f08-adb9-91453481e724n%40googlegroups.com?utm_medium=email&utm_source=footer
> |
> https://groups.google.com/d/msgid/morphmet2/9c418b9f-6a10-4f08-adb9-91453481e724n%40googlegroups.com
> ] .

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/morphmet2/26336271.4871894.1647443799823.JavaMail.zimbra%40umontpellier.fr.

Reply via email to