modifyProps: Change the default simulated values to proportions requested...

View source: R/modifyProps.r

modifyPropsR Documentation

Change the default simulated values to proportions requested by the user. The values of a vector are changed so that the proportions of each discrete value are that requested by the user. The values that are changed are the ones with the highest propensity to do so The propensity score(s) of an observation to be a higher (or lower) value can be given as input to the function. If the propensity score(s) are not provided by the user then random propensity scores are generated.

Description

Change the default simulated values to proportions requested by the user. The values of a vector are changed so that the proportions of each discrete value are that requested by the user. The values that are changed are the ones with the highest propensity to do so The propensity score(s) of an observation to be a higher (or lower) value can be given as input to the function. If the propensity score(s) are not provided by the user then random propensity scores are generated.

Usage

modifyProps(default.vec, desired_props, propens = 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.

accuracy

gives how close the end proportions are allowed to be away from the desired proportions before an error message is given - the default is 0.01. If the '.accuracy' global variable exists, its value will be used instead of that in function call.

Value

a modified vector with the proportions requested.

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 change.cat


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