GREGWT: GREGWT

Description Usage Arguments Value Author(s) Examples

Description

Implementation of the GREGWT algorithm in the R language

Usage

1
GREGWT(x, ...)

Arguments

data_in

(default=FALSE) input data

area_code

(default = 1) area code to use for the reweighting, defines the area code name. If area_code is a list, the GREGWT function will loop through that list and reweight every area on the list. If area_code is of class logical the GREGWT function will loop through all simulation area on the data set. If area_code is set to 'internal' the GREGWT function will loop through all areas on the data set but will used the area codes define by function 'prepareData'.

use_ginv

(default = FALSE) use the ginv function of the MASS library to compute the inverse matrix.

Tx

(default = FALSE) manually specify benchmark vector

X_input

(default = FALSE) manually specify survey matrix as dummy variables without reference categories.

X_complete_input

(default = FALSE) manually specify complete survey matrix as dummy variables with all categories.

dx_input

(default = FALSE) manually specify initial weights.

area_pop

(default = FALSE) manually specify the total population. The area_pop is a vector of size == dim(Tx)[2]. If Tx is a vector area_pop needs to be define as a single value representing the total population of a single area.

group

(default = FALSE) position of the grouping variable, implies an integrated reweighting.

bounds

(default = c(0,Inf)) defines the bounds of the estimated new weights.

epsilon

(default = 0.001) defines the desire precision of the model to achieve convergence.

max_iter

(default = 10) maximum number of iterations to run

cat_weights

(default = FALSE, under development) weights for individual benchmarks. If not FALSE the function will compute individual weights for each benchmark (or benchmark group) and compute a weighted mean with the weights define in variable 'cat_weights'.

align_pop

(default = TRUE) align weights to total population.

error

(default = TRUE) compute the error in the simulation.

output_log

(default = FALSE) create en output log of the simulation. This will create a file called GREGWT.out on the current working directory. This option will suppress the output to the command line. You can process the output by calling the function logtocsv() provided by this package.

verbose

(optional, default = FALSE) be verbose

Value

GREGWT

Author(s)

M. Esteban Munoz H.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library('GREGWT')
data("GREGWT.census")
data("GREGWT.survey")

simulation_data <- prepareData(
  GREGWT.census, GREGWT.survey,
  survey_id=FALSE,
  pop_benchmark=c(2,12),
  census_categories=seq(2,24),
  survey_categories=seq(1,3)
)

# reweight for 4 areas
areas <- c("02", "11", "04011", "04012")
weights_GREGWT = GREGWT(data_in=simulation_data, area_code=areas)
plot(weights_GREGWT)

# reweight and plot the results for a single area
acode = "02"
weights_GREGWT_02 <- GREGWT(data_in= simulation_data, area_code=acode)

plot(weights_GREGWT_02)
print(weights_GREGWT_02)
summary(weights_GREGWT_02)

emunozh/GREGWT documentation built on May 16, 2019, 5:11 a.m.