R/base_calcModelBIC.R

Defines functions .calcModelBIC

Documented in .calcModelBIC

.calcModelBIC <- function( loglik, n, nChr, 
	method="mosaics", analysisType="IO", signalModel="2S", type="BIC" )
{     
    # calculate number of parameters for each case
    
    npar <- switch( analysisType,
		
    	OS = 9,
    	TS = 11,
    	IO = 6
    )
    
    if ( method == "mosaicsHMM" ) {
    	npar <- npar - 1 + ( 1 + 2 ) * nChr
			# minus: proportion of binding (1)
			# plus: for each chromosome, 
			#		initial probability (1) + transition probability (2)
			# [Note] sum to one constraint
    }
    
    if ( signalModel == "2S" ) { 
    	npar <- npar + 3
    		# 1S: b, c
    		# 2S: p1, b1, c2, b2, c2
    }
    
    # calculate BIC
    
    penalty <- switch( type,
        AIC = 2,
        BIC = log(n)
    )
    
    val <- -2 * loglik + penalty * npar
    
    return(val)
}

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.