1 | getPartialRUnconditional(indicator, variable, sampleData, sampleDesign)
|
indicator |
|
variable |
|
sampleData |
|
sampleDesign |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ##---- 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 (indicator, variable, sampleData, sampleDesign)
{
stopifnot(variable %in% names(sampleData))
categories <- sampleData[[variable]]
RBiasFactor <- indicator$RBiasFactor
nPopulation <- sum(indicator$sampleDesign$weights)
propMean <- indicator$propMean
arg <- with(indicator, data.frame(n = sampleDesign$weights,
prop = sampleDesign$weights * prop))
byCategory <- within(aggregate(arg, list(category = categories),
sum), {
prop <- prop/n
propSign <- sign(n * (prop - propMean))
propVar <- n * (prop - propMean)^2/nPopulation
PuUnadj <- propSign * sqrt(propVar)
})
model <- within(indicator$model, formula <- replaceRHSByVariable(formula,
variable))
propVar <- sum(byCategory$propVar)
Pu <- sqrt(propVar * RBiasFactor)
PuUnadj <- sqrt(propVar)
PuSE <- 0.5 * getRSampleBased(model, sampleData, sampleDesign)$RSE
partialIndicator <- list(type = "Unconditional partial R-indicator, sample based",
variable = variable, Pu = Pu, PuUnadj = PuUnadj, PuSE = PuSE,
byCategory = byCategory)
partialIndicator <- getVariancePartialRUnconditional(partialIndicator,
indicator, sampleData, sampleDesign)
partialIndicator$byCategory <- partialIndicator$byCategory[c("category",
"PuUnadj", "PuUnadjSE")]
return(partialIndicator)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.