# NOT RUN {
# See similar and related examples in PLSrounding documentation
RoundViaDummy(SmallCountData("e6"), "freq")
RoundViaDummy(SmallCountData("e6"), "freq", formula = ~eu * year + geo)
RoundViaDummy(SmallCountData("e6"), "freq", hierarchies =
list(geo = c("EU", "@Portugal", "@Spain", "Iceland"), year = c("2018", "2019")))
RoundViaDummy(SmallCountData('z2'),
'ant', ~region + hovedint + fylke*hovedint + kostragr*hovedint, 10)
mf <- ~region*mnd + hovedint*mnd + fylke*hovedint*mnd + kostragr*hovedint*mnd
a <- RoundViaDummy(SmallCountData('z3'), 'ant', mf, 5)
b <- RoundViaDummy(SmallCountData('sosialFiktiv'), 'ant', mf, 4)
print(cor(b[[2]]),digits=12) # Correlation between original and rounded
# Demonstrate parameter leverageCheck
# The 42nd inner cell must be rounded since it can be revealed from the published cells.
mf2 <- ~region + hovedint + fylke * hovedint + kostragr * hovedint
RoundViaDummy(SmallCountData("z2"), "ant", mf2, leverageCheck = FALSE)$yInner[42, ]
RoundViaDummy(SmallCountData("z2"), "ant", mf2, leverageCheck = TRUE)$yInner[42, ]
# }
# NOT RUN {
# Demonstrate parameters maxRound, zeroCandidates and forceInner
# by tabulating the inner cells that have been changed.
z4 <- SmallCountData("sosialFiktiv")
for (forceInner in c("FALSE", "z4$ant < 10"))
for (zeroCandidates in c(FALSE, TRUE))
for (maxRound in c(2, 5)) {
set.seed(123)
a <- RoundViaDummy(z4, "ant", formula = mf, maxRound = maxRound,
zeroCandidates = zeroCandidates,
forceInner = eval(parse(text = forceInner)))
change <- a$yInner[, "original"] != a$yInner[, "rounded"]
cat("\n\n---------------------------------------------------\n")
cat(" maxRound:", maxRound, "\n")
cat("zeroCandidates:", zeroCandidates, "\n")
cat(" forceInner:", forceInner, "\n\n")
print(table(original = a$yInner[change, "original"], rounded = a$yInner[change, "rounded"]))
cat("---------------------------------------------------\n")
}
# }
Run the code above in your browser using DataLab