Skip to content
Prev 338360 / 398500 Next

cov.wt gives different results from other (co)variance functions (cov, wtd.var)

On 31 Mar 2014, at 00:30 , Emilio Torres Manzanera <torres at uniovi.es> wrote:

            
PLEASE DON'T DO THIS:
If a friendly an helpful reader pastes that into a running R session, previous work could be lost, causing the reader to become less friendly and helpful in the future.

Anyways, the crux seems to be that cov.wt has

   cov <- switch(match.arg(method), unbiased = crossprod(x)/(1 - 
        sum(wt^2)), ML = crossprod(x))
 
where frequency weighting would have  N/(N - 1) (in this case 150/149). I'm not sure where the term (1-sum(wt^2)) comes from, though; in variance-weighting, I'd expect n/(n-1) (with n=117 here) which is not the same thing, unless the wt are equal.