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:
Dear Sir, I am not sure about the precision of the cov.wt function. It seems that it provides different results when using frequency weights. This discrepancy only occurs with the covariance matrix, not with the correlation matrix. Do you know to how to solve this issue? Thank you Best regards, Emilio
PLEASE DON'T DO THIS:
rm(list=ls())
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.
Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com