R/rmulti.R

Defines functions rmulti

Documented in rmulti

rmulti <-
function(p) {
    if (is.vector(p)) p <- t(p)
    n <- nrow(p)
    p <- matrix(p[,-ncol(p)],nrow=n)
    thresh <- matrix(apply(p,1,cumsum),nrow=n,ncol=ncol(p),byrow=TRUE)
    vals <- matrix(runif(n),ncol=ncol(thresh),nrow=n)
    return(rowSums(vals>thresh)+1)
}

Try the poLCA package in your browser

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

poLCA documentation built on April 25, 2022, 5:06 p.m.