override_tbin_probs {SimTimeVar}R Documentation

Override probabilities for time-varying binary variables

Description

An internal function not intended for the user. For clusters assigned to have a given time-varying binary variable always equal to 0, overrides to 0 the corresponding proportion of observations with the binary variable equal to 1.

Usage

override_tbin_probs(mus0, n.TBins, n.OtherBins, zero = 1e-04)

Arguments

mus0

The matrix of cluster means.

n.TBins

Number of time-varying binary variables.

n.OtherBins

The number of static binary variables.

zero

A number very close to 0, but slightly larger.

Examples

# make example subject means matrix for 1 static binary, 
#  1 time-varying binary, and 1 normal
#  50 subjects and 5 observations (latter plays into variance)
set.seed(451)
mus0 = mod.jointly.generate.binary.normal( no.rows = 50, no.bin = 2, no.nor = 2,
                                           prop.vec.bin = c( .5, .35 ),
                                           mean.vec.nor = c( .4, 100 ),
                                           var.nor = c( (0.4 * 0.6) / 5, 10 ),
                                           corr.vec = c(0.05, .08, 0, 0, -0.03, 0) )

# note that we have ever-users with non-zero propensities to be on drug: not okay
any( mus0[,1] == 0 & mus0[,3] != 0 )

# fix them
mus1 = override_tbin_probs( mus0, 1, 1 )

# all better!
any( mus1[,1] == 0 & mus1[,3] > 0.0001 )

[Package SimTimeVar version 1.0.0 Index]