R/base_logLik.R

Defines functions .logLik

# calculate log likelihood for MOSAiCS

.logLik <- function( mosaicsEst, tagCount, pNfit, k=3, signalModel="2S" )
{              
    switch( signalModel,
        "1S" = {
            # one signal model
            
            pi0 <- mosaicsEst@pi0            
            fitMD <- .margDist_1S( mosaicsEst=mosaicsEst, 
                tagCount=tagCount, pNfit=pNfit, k=k )
            
            loglik <- sum( log( pi0 * fitMD$MDZ0 + ( 1 - pi0 ) * fitMD$MDZ1 ) )
        },
        "2S" = {
            # two signal model
            
            pi0 <- mosaicsEst@pi0
            p1 <- mosaicsEst@p1            
            fitMD <- .margDist_2S( mosaicsEst=mosaicsEst, 
                tagCount=tagCount, pNfit=pNfit, k=k )
                
            loglik <- sum( log( pi0 * fitMD$MDZ0 + 
            	( 1 - pi0 ) * ( fitMD$MDZ1 * p1 + fitMD$MDZ2 * (1-p1) ) ) )
        }
    )
    
    return(loglik)
}

Try the mosaics package in your browser

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

mosaics documentation built on Nov. 8, 2020, 6:59 p.m.