Skip to content

Commit

Permalink
extend documentiont hhTables and persTables for calibPop and fix some…
Browse files Browse the repository at this point in the history
… roxygen warnings
  • Loading branch information
Johannes Gussenbauer - QM committed Feb 19, 2024
1 parent bb76866 commit 1b40ecf
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ Collate:
'whipple.R'
'dataSets.R'
'zzz.R'
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Encoding: UTF-8
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(as.array,spTable)
S3method(as.table,spTable)
S3method(calibVars,data.frame)
S3method(calibVars,default)
S3method(calibVars,matrix)
Expand All @@ -14,12 +16,17 @@ S3method(covWt,data.frame)
S3method(covWt,dataObj)
S3method(covWt,default)
S3method(covWt,matrix)
S3method(getExclude,data.frame)
S3method(getExclude,data.table)
S3method(getExclude,default)
S3method(meanWt,dataObj)
S3method(meanWt,default)
S3method(plot,spTable)
S3method(prepBwplotStats,data.frame)
S3method(prepBwplotStats,default)
S3method(prepCdf,data.frame)
S3method(prepCdf,default)
S3method(print,spTable)
S3method(quantileWt,dataObj)
S3method(quantileWt,default)
S3method(varWt,dataObj)
Expand Down Expand Up @@ -50,6 +57,7 @@ export(getCat)
export(getCdf)
export(getCitizenship)
export(getEcoStat)
export(getExclude)
export(getGender)
export(getHsize)
export(ipu)
Expand Down
6 changes: 4 additions & 2 deletions R/calibPop.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ multiply_data <- function(data0,params,redist.var,split){
#' @param observe.break When objective value has been saved \code{observe.times}-times the coefficient of variation is calculated over saved values; if the coefficient of variation falls below \code{observe.break}
#' simmulated annealing terminates. This repeats for each new set of \code{observe.times} new values of the objecive function. Can help save run time if objective value does not improve much. Disable this termination by either setting \code{observe.times=0} or \code{observe.break=0}.
#' @param n.forceCooldown integer, if the solution does not move for \code{n.forceCooldown} iterations then a cooldown is automatically done.
#' @param hhTables information on population margins for households
#' @param persTables information on population margins for persons
#' @param hhTables Information on population margins for households. Can bei either a single \code{data.table} or \code{data.frame} or a list with multiple \code{data.tables}s or \code{data.frame}s.
#' Each table must have one column named \code{Freq} and all other columns holding variable(s) of the synthetic population. Each row in this table corresponds to a the frequency count a one of the variable combination in that table, see examples.
#' @param persTables Information on population margins for persons. Can bei either a single \code{data.table} or \code{data.frame} or a list with multiple \code{data.tables}s or \code{data.frame}s.
#' Each table must have one column named \code{Freq} and all other columns holding variable(s) of the synthetic population. Each row in this table corresponds to a the frequency count a one of the variable combination in that table, see examples.
#' @param redist.var single column in the population which can be redistributed in each `split`. Still experimental!
#' @param redist.var.factor numeric in the interval (0,1]. Used in combinationo with `redist.var`, still experimental!
#' @return Returns an object of class \code{\linkS4class{simPopObj}} with an
Expand Down
3 changes: 2 additions & 1 deletion R/simPop-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#'
#' @name simPop-package
#' @aliases simPop-package simPop
#' @docType package
#' @author Bernhard Meindl, Matthias Templ, Andreas Alfons, Alexander Kowarik,
#'
#' Maintainer: Matthias Templ <matthias.templ@@gmail.com>
Expand All @@ -68,6 +67,7 @@
#' \emph{Privacy in Statistical Databases}, \strong{6344} of Lecture Notes in Computer Science, 174--186. Springer Verlag, Heidelberg. \doi{10.1007/978-3-642-15838-4_16}
#'
#' @keywords package
#'
#' @examples
#'
#' ## we use synthetic eusilcS survey sample data
Expand Down Expand Up @@ -99,4 +99,5 @@
#' ## using different methods, calibrating surveys or populations, etc.
#' ## -- see Templ et al. (2017) for more details.
#'
"_PACKAGE"
NULL
4 changes: 4 additions & 0 deletions R/spTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ spTable <- function(inp, select) {
}

# methods for class "spTable"
#' @export
as.array.spTable <- function(x, ...) {
values <- c(as.integer(x$expected), as.integer(x$realized))
d <- c(dim(x$expected), 2)
Expand All @@ -77,14 +78,17 @@ as.array.spTable <- function(x, ...) {
array(values, dim=d, dimnames=dn)
}

#' @export
as.table.spTable <- function(x, ...) {
tab <- as.array(x)
class(tab) <- "table"
tab
}

#' @export
plot.spTable <- function(x, ...) spMosaic(x, ...)

#' @export
print.spTable <- function(x, ...) {
# expected (from sample)
cat("Expected:\n")
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@ dropLevels <- function(x, select = names(x)) {


## get which observations contain NAs (and need to be excluded)
#' @export
getExclude <- function(x, ...) UseMethod("getExclude")
#' @export
getExclude.default <- function(x, ...) which(is.na(x))
#' @export
getExclude.data.frame <- function(x, ...) {
unique(which(is.na(x), arr.ind=TRUE)[, 1])
}
#' @export
getExclude.data.table <- function(x, ...) {
unique(which(is.na(x), arr.ind=TRUE)[, 1])
}
Expand Down
6 changes: 4 additions & 2 deletions man/calibPop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b40ecf

Please sign in to comment.