1 | getVarianceRSampleBased(prop, z, sigma, sampleDesign)
|
prop |
|
z |
|
sigma |
|
sampleDesign |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (prop, z, sigma, sampleDesign)
{
weights <- sampleDesign$weights
nSample <- length(weights)
nPopulation <- sum(weights)
propMean <- weighted.mean(prop, weights)
propVar <- weightedVar(prop, weights, method = "ML")
propZ <- cbind(prop, z)
A <- cov.wt(propZ, wt = weights, method = "ML")$cov[-1, 1]
B <- cov.wt(z, wt = weights, method = "ML")$cov
C <- sampleDesign$getVarTotal(sampleDesign, (prop - propMean)^2)
variance <- numeric()
variance[1] <- 4 * t(A) %*% sigma %*% A
variance[2] <- 2 * getTrace(B %*% sigma %*% B %*% sigma)
variance[3] <- C/nPopulation^2
variance <- sum(variance)/propVar
return(variance)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.