modifypropsVarSingle_on_subset: Calls modifyProps on a subset, returning the whole vector,...

View source: R/modifyProps.r

modifypropsVarSingle_on_subsetR Documentation

Calls modifyProps on a subset, returning the whole vector, but with the subset modified

Description

Calls modifyProps on a subset, returning the whole vector, but with the subset modified

Usage

modifypropsVarSingle_on_subset(
  default.vec,
  desired_props,
  propens = NULL,
  logiset = NULL,
  accuracy = 0.01
)

Arguments

default.vec

a vector after a run of the simulation. The values of this variable will be changed in accordance with what the user requests

desired_props

a vector that is the proportions requested by the user. The vector is the length of the number of distinct values of the variable being modified.

propens

matrix or vector of the propensity scores for each child For binary variables there is one column of propensity scores: the propensities to change from a 0 to a 1. For categorical variables with more than two categories there are multiple columns of propensity scores: E.g. for a three category variables the propensities to change from category 1 to category 2 are in the first column and the propensities to change from category 2 to category 3 are in the second column.

logiset

logical vector indicating which observations to include, or NULL to include all.

accuracy

gives how close the end proportions are allowed to be away from the desired proportions - the default is 0.01. It is passed to function modifyProps().

Value

a vector with the subset modified

Note

Assumptions made by the function: It is assumed that the proportions given in props are given in consectuive increasing order (e.g. 0,1, 1, 2, 3 or 2, 5, 9, 23). If the user wants to make it so no observations are in a particular category the value 0 must be put in the corresponding place in the vector props If the propensity scores (propens) are provided by the user then it is assumed that default.vec and propens are given in the same order and exactly the same children are in each vector (i.e. there are no children in one vector that are not in the other). In other words, the propensity score for a specific child is in the same row in propens as that same child's value of the variable in default.vec.

See Also

This function calls modifyProps


kcha193/simarioV2 documentation built on April 8, 2024, 4:51 p.m.