| Type: | Package |
| Title: | Sampling Error Estimation for Complex Surveys |
| Version: | 0.2.0 |
| Description: | Estimates sampling errors and produces indicator tables for complex survey data. Supports weighted totals, proportions, standard errors, confidence intervals, coefficients of variation, design effects, unweighted frequencies, grouped estimates, domain estimates, optional stratification and clustering variables, and customizable exports to '.xlsx' files. Survey estimation is based on design-based inference using Taylor series linearization implemented in the 'survey' package (Lumley, 2004, <doi:10.18637/jss.v009.i08>; Lumley, 2010, ISBN:9780470284308). The package provides a reproducible workflow for official statistics, household surveys, and applied survey research. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-US |
| Depends: | R (≥ 4.2.0) |
| Imports: | survey, openxlsx, stats |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/lburgoss/svySE |
| BugReports: | https://github.com/lburgoss/svySE/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-13 23:22:39 UTC; encal154 |
| Author: | Luis Burgos |
| Maintainer: | Luis Burgos <lburgoss1996@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-14 14:40:02 UTC |
Print svySE configuration
Description
Imprime la configuracion de svySE.
Prints the svySE configuration.
Usage
## S3 method for class 'svySE_cfg'
print(x, ...)
Arguments
x |
Objeto de clase |
... |
Argumentos adicionales. |
Value
Invisiblemente el objeto x.
Print svySE result
Description
Imprime un resumen del resultado de svySE_calc().
Usage
## S3 method for class 'svySE_result'
print(x, ...)
Arguments
x |
Objeto de clase |
... |
Argumentos adicionales. |
Details
Prints a summary of the result from svySE_calc().
Value
Invisiblemente x.
Print an svySE simple result
Description
Imprime un resumen del resultado generado por svySE_simple().
Usage
## S3 method for class 'svySE_simple_result'
print(x, ...)
Arguments
x |
Objeto de clase |
... |
Argumentos adicionales. |
Details
Prints a summary of the result generated by svySE_simple().
Value
Invisiblemente x.
Calculate sampling errors
Description
Calcula estimaciones ponderadas y errores muestrales para uno o mas indicadores usando un data.frame previamente cargado por el usuario.
Usage
svySE_calc(
data,
indicators,
group_vars,
group_labels = group_vars,
strata = NULL,
cluster = NULL,
weight = NULL,
division = NULL,
div_weight = NULL,
cfg = svySE_cfg(),
verbose = TRUE,
strict = FALSE
)
Arguments
data |
Base de datos ya cargada en R / Data frame already loaded in R. |
indicators |
Vector con los nombres de los indicadores. |
group_vars |
Variables de agrupacion. |
group_labels |
Etiquetas de las variables de agrupacion. |
strata |
Variable or variables identifying strata. If |
cluster |
Variable or variables identifying primary sampling units or
clusters. If |
weight |
Variable de peso principal. |
division |
Variable de division opcional. |
div_weight |
Variable de peso opcional para las divisiones. |
cfg |
Configuracion creada con |
verbose |
Si es |
strict |
Si es |
Details
Calculates weighted estimates and sampling errors for one or more indicators using a data.frame previously loaded by the user.
Value
Objeto de clase "svySE_result" que contiene exclusivamente
estimaciones ponderadas y tablas de errores muestrales.
Configure sampling error parameters
Description
Crea una configuracion general para el calculo de errores muestrales. Creates a general configuration object for sampling error estimation.
Usage
svySE_cfg(
estimator = "prop",
variance = "taylor",
lonely_psu = "adjust",
conf_level = 0.95,
target = 1,
valid_values = c(0, 1),
truncate_lower_ci = TRUE,
pct_mult = 100,
deff = TRUE,
cv = TRUE,
na_rm = TRUE
)
Arguments
estimator |
Tipo de estimador. Opciones: |
variance |
Metodo de estimacion de varianza. Actualmente solo |
lonely_psu |
Tratamiento de estratos con una sola UPM. Opciones:
|
conf_level |
Nivel de confianza. Por defecto |
target |
Valor objetivo del indicador. Por defecto |
valid_values |
Valores validos del indicador. Por defecto |
truncate_lower_ci |
Si es |
pct_mult |
Multiplicador para expresar proporciones como porcentajes.
Por defecto |
deff |
Si es |
cv |
Si es |
na_rm |
Si es |
Value
Lista de clase "svySE_cfg".
Examples
cfg <- svySE_cfg(
estimator = "prop",
variance = "taylor",
target = 1
)
Check logical scalar
Description
Valida que un argumento sea logico de longitud uno. Checks whether an argument is a single logical value.
Usage
svySE_chk_bool(x, arg)
Arguments
x |
Objeto a validar / Object to validate. |
arg |
Nombre del argumento / Argument name. |
Value
Invisiblemente TRUE.
Check selected columns
Description
Valida que las columnas seleccionadas existan dentro del conjunto permitido. Checks whether selected columns exist in the allowed column set.
Usage
svySE_chk_cols(cols, all_cols, arg = "cols")
Arguments
cols |
Columnas seleccionadas / Selected columns. |
all_cols |
Columnas disponibles / Available columns. |
arg |
Nombre del argumento / Argument name. |
Value
Invisiblemente TRUE.
Select sampling error columns
Description
Selecciona columnas para exportar la tabla de errores muestrales. Selects columns to export the sampling error table.
Usage
svySE_cols_err(type = "full", cols = NULL)
Arguments
type |
Tipo de salida / Output type. Opciones:
|
cols |
Vector de columnas cuando |
Value
Vector de columnas seleccionadas / Selected column vector.
Examples
svySE_cols_err("full")
svySE_cols_err("pct")
svySE_cols_err("custom", cols = c("est_pct", "cv"))
Available sampling error columns
Description
Devuelve todas las columnas metricas disponibles para la tabla de errores muestrales. Returns all available metric columns for the sampling error table.
Usage
svySE_cols_err_all()
Value
Vector de nombres de columnas / Character vector of column names.
Select simple table columns
Description
Selecciona columnas para exportar la tabla simple. Selects columns to export the simple table.
Usage
svySE_cols_tab(type = "full", cols = NULL)
Arguments
type |
Tipo de salida / Output type. Opciones:
|
cols |
Vector de columnas cuando |
Value
Vector de columnas seleccionadas / Selected column vector.
Examples
svySE_cols_tab("full")
svySE_cols_tab("target")
svySE_cols_tab("custom", cols = c("freq_1", "pct_1"))
Available simple table columns
Description
Devuelve todas las columnas disponibles para la tabla simple. Returns all available columns for the simple table.
Usage
svySE_cols_tab_all()
Value
Vector de nombres de columnas / Character vector of column names.
Check svySE configuration object
Description
Verifica si un objeto pertenece a la clase svySE_cfg.
Checks whether an object belongs to class svySE_cfg.
Usage
svySE_is_cfg(x)
Arguments
x |
Objeto a evaluar / Object to check. |
Value
TRUE o FALSE.
Calculate unweighted simple indicator tables
Description
Calcula frecuencias y porcentajes simples para uno o mas indicadores sin utilizar factores de expansion ni variables del diseno muestral.
Usage
svySE_simple(
data,
indicators,
group_vars,
group_labels = group_vars,
division = NULL,
target = 1,
valid_values = c(0, 1),
pct_mult = 100,
verbose = TRUE,
strict = FALSE
)
Arguments
data |
Base de datos previamente cargada en R. Data frame previously loaded in R. |
indicators |
Vector de texto con los nombres de los indicadores. Character vector containing the indicator names. |
group_vars |
Variables utilizadas para agrupar los resultados. Variables used to group the results. |
group_labels |
Etiquetas de las variables de agrupacion. Labels for the grouping variables. |
division |
Variable opcional para generar resultados separados por
categoria. Si es |
target |
Valor que identifica la categoria de interes. Value identifying the target category. |
valid_values |
Valores permitidos en los indicadores. Values allowed in the indicators. |
pct_mult |
Multiplicador utilizado para expresar los porcentajes. Multiplier used to express percentages. |
verbose |
Si es |
strict |
Si es |
Details
Calculates unweighted frequencies and percentages for one or more indicators without using sampling weights or survey design variables.
Los resultados generados por esta funcion describen solamente los registros observados en la muestra. Como no se utilizan factores de expansion ni componentes del diseno muestral, los porcentajes no deben interpretarse como estimaciones representativas de la poblacion.
The results generated by this function describe only the records observed in the sample. Because sampling weights and survey design components are not used, percentages should not be interpreted as population estimates.
Value
Objeto de clase "svySE_simple_result".
Object of class "svySE_simple_result".
Export svySE results to '.xlsx' files
Description
Exporta uno o varios resultados generados por svySE_calc() y
svySE_simple() a archivos .xlsx.
Usage
svySE_xlsx(
x,
select = NULL,
file_err = NULL,
file_tab = NULL,
cols_err = svySE_cols_err("full"),
cols_tab = svySE_cols_tab("full"),
start_row = 10,
overwrite = TRUE,
keep_na = FALSE
)
Arguments
x |
Objeto generado por |
select |
Vector de texto opcional con los nombres de los elementos de
|
file_err |
Ruta del archivo |
file_tab |
Ruta del archivo |
cols_err |
Columnas de error a exportar. Sampling error columns to export. |
cols_tab |
Columnas de tabla simple a exportar. Simple table columns to export. |
start_row |
Fila inicial de escritura. Starting row for writing. |
overwrite |
Sobrescribir archivos existentes. Whether existing files should be overwritten. |
keep_na |
Mantener |
Details
Exports one or more results generated by svySE_calc() and
svySE_simple() to .xlsx files.
Debe especificarse al menos uno de file_err o file_tab.
Cuando x es una lista, sus elementos deben tener nombres unicos. Los
objetos de clase "svySE_result" se exportan a file_err, mientras que los
objetos de clase "svySE_simple_result" se exportan a file_tab.
At least one of file_err or file_tab must be provided.
When x is a list, its elements must have unique names. Objects of class
"svySE_result" are exported to file_err, while objects of class
"svySE_simple_result" are exported to file_tab.
Value
Invisiblemente una lista con las rutas de los archivos exportados y los resultados seleccionados. Invisibly returns a list containing the exported file paths and selected result names.