I submitted this question to stat.stackexchange
https://stats.stackexchange.com/questions/147909/puzzling-average-of-correlated-measurements
but it looks like it fits more into that forum, as it may be more a computing issue than a statistic one:
I want to average correlated measurements. Given a set of measurements:
x = ( x1, x2, x3 )
whose internal correlations are given by the covariance matrix C.
A Chi2 minimization leads to the following average:
<x> = C^-1 * x / C^-1
But the following example puzzled me:
Let's consider the following tree:
tree.mod:
(((oryLat2:0.3,(HLnotFur1:0.3001,HLxipMac2:0.3001)HLnotFur1-HLxipMac2:0.0001)oryLat2-HLnotFur1:0.05,(gasAcu1:0.01,tetNig2:0.02)gasAcu1-tetNig2:0.1)oryLat2-gasAcu1:0.4,danRer7:0.5)oryLat2-danRer7;
and do in R:
R
library(ape)
# Read the tree
tree <- read.tree( "tree.mod" )
# Extract a clade of 3 species
clade <- extract.clade( phy=tree, node="oryLat2-HLnotFur1")
# Measurements
x <- c(1,4,4)
# Covariance of the clade
V = vcv(clade)
oryLat2 HLnotFur1 HLxipMac2
oryLat2 0.3 0.0000 0.0000
HLnotFur1 0.0 0.3002 0.0001
HLxipMac2 0.0 0.0001 0.3002
# Replace zero-entries
V[V==0] = 1e-5
oryLat2 HLnotFur1 HLxipMac2
oryLat2 3e-01 0.00001 0.00001
HLnotFur1 1e-05 0.30020 0.00010
HLxipMac2 1e-05 0.00010 0.30020
# Formulas
# Weights
r <- 1/V
oryLat2 HLnotFur1 HLxipMac2
oryLat2 3.3 100000 100000
HLnotFur1 100000 3.3 10000
HLxipMac2 100000 10000 3.3
#Mean
meanX = sum(x %*% r) / sum(r)
2.500008
I am puzzled because meanX = 2.5, which corresponds to the case of high correlation, while in that example the covariance matrix is almost diagonal, so I expect meanX = 3.
I must be missing something, any input would be welcome! Thanks