get_cc_sparse: Create Sparse Constraints Coefficients Data Frame.

Description Usage Arguments Details Value

View source: R/reweight.r

Description

Construct a data frame that represents a sparse matrix with nonzero constraint coefficients. A constraint coefficient is the amount by which a constraint changes if an element of the vector x changes by one unit. This stores only those coefficients that are nonzero, in triplet form, where i is an index identifying which constraint is represented, j is an index identifying which element of the vector x is represented, and nzcc is the value of the nonzero constraint coefficient.

Usage

1
get_cc_sparse(xmat, target_names, iweights)

Arguments

xmat

Numeric matrix of unweighted data values in dense form where each row is a household, each column corresponds to a constraint, and each cell is a data value.

target_names

Character vector with names for each constraint. One element per column in xmat.

iweights

Numeric vector of initial weights in the microdata file, one per row in xmat.

Details

The data value in xmat multiplied by the initial weight determines how much a constraint will change with a unit change in x, the ratio of the new weight to the initial weight. For example, suppose household number 7 has income of $10,000 then. Suppose that this household is in row 7 of xmat and that column 3 of xmat corresponds to income. If this household has an initial weight of 20, then the constraint coefficient for this cell - how much changing the x value for this household will change the constraint for total income - is 200,000 (20 x 100,000). The constraints coefficient data frame will have a row where i (the index for the constraint, not the household) is 3, j (the index for the household) is 7, and nzcc is 200000.

Value

A data frame representing a sparse matrix of constraint coefficients, with columns:

i

the constraint number

j

an index into x

cname

constraint name, from target_names

nzcc

the nonzero constraint coefficient - the initial weight multiplied by value

iweight

initial weight for this cell

value

data value


donboyd5/microweight documentation built on Aug. 17, 2020, 4:48 p.m.