mbsclf {binarySimCLF}R Documentation

Multiple Correlated Binary Vectors

Description

Unlike mbsclf1, this routine generates multiple vectors where each row of the outcome matrix corresponds to a cluster.

Please be advised that this function DOES NOT check for CLF compatibility. The onus is on the user to do so. His or her program MUST check for CLF compatibility, otherwise the returned value is nonsense. The routine for checking CLF compatibility is blrchk.

Usage

mbsclf(m, u, B, seed)

Arguments

m The number of vectors of correlated binary outcome. All have the same mean and correlation. Thus, the generated vectors of responses are iid. From a clustered data perspective, think of m as the number of clusters.
u Mean vector.
B Intermediate matrix obtained by B = allReg(V).
seed Sets the seed.

Details

As we said in mbsclf1, CLF compatibility requires that λ_i is in [0,1] and also that the largest and smallest possible value of λ_i is in range. As we said in the description section, the latter compatibility condition is not checked by this function. It is checked by the function blrchk. If blrchk returns a FALSE, then this routine should not be used. If the user does not check, then for some i out of the m vectors, λ_i may be in range and for some other i' it may not. This constitutes a failure of this function. The code is allowed to run until a failure is encountered at which point it stops and returns a NULL value for the outcome matrix. Note that if the smallest and largest possible λ_i is out of range, it is possible for the routine to succeed. For large m, this is very unlikely. Even if it did succeed, the output is still nonsense.

The take home message is check for CLF compatibility using blrchk before allowing either mbsclf or mbsclf1 to run. This ensures CLF compatibility.

Value

Returns a list with two components.

succeed Indicates whether the routine succeeds or fails.
y The response. If succeed is FALSE, then y is NA. If succeed is TRUE, then y is a binary outcome matrix. The number of rows of this matrix is m.

References

Qaqish, B. F., A family of multivariate binary distributions for simulating correlated binary variables with specified marginal means and correlations. Biometrika 92:455-463, 2003.

See Also

mbsclf1, binarySimCLF.

Examples

    # Examples
    R = cbind( c(1, 0.1, 0.2), c(0.1, 1, 0.3), c(0.2, 0.3, 1) );
    mu = c(0.4, 0.5, 0.6);
    V = cor2var(R, mu) ; V
    # Check CLF compatibility.
    clf.compat = blrchk(mu,V);
    
    if (clf.compat){
        print("CLF compatible");
        B = allReg(V);
        y = mbsclf(200,mu,B, seed=568381)
    }
    # sample mean
    colMeans(y$y);
    cor(y$y);

[Package binarySimCLF version 1.0 Index]