R/mice_impute_catpmm_create_dummies_y.R

Defines functions mice_impute_catpmm_create_dummies_y

## File Name: mice_impute_catpmm_create_dummies_y.R
## File Version: 0.02

mice_impute_catpmm_create_dummies_y <- function(y, dfr, ridge=0)
{
    n <- nrow(dfr)
    y1 <- stats::model.matrix(object=~0+as.factor(y), data=dfr )
    ny <- ncol(y1)
    colnames(y1) <- paste0("y",1:ny)
    y1 <- y1 + matrix( stats::rnorm(n*ny, mean=0, sd=ridge), nrow=n, ncol=ny)
    dfr <- data.frame(dfr, y1)
    #-- outcome
    res <- list(y1=y1, ny=ny, dfr=dfr)
    return(res)
}

Try the miceadds package in your browser

Any scripts or data that you put into this service are public.

miceadds documentation built on May 29, 2024, 11:05 a.m.