R/LoglikGammaCens.R

Defines functions LoglikGammaCens

Documented in LoglikGammaCens

LoglikGammaCens <- function(x, data, lowerbound, vdelta){
	if(x[1] > 0 & x[2] > 0){
		if(length(lowerbound[is.na(lowerbound) == FALSE]) != 0){
			loglik <- sum(log(dgamma(data[vdelta == 1], shape = x[1], rate = x[2]))) + sum(log(pgamma(data[vdelta == 0 & is.na(lowerbound)==TRUE], shape=x[1], rate=x[2]))) + sum(log(pgamma(data[vdelta == 0 & is.na(lowerbound)==FALSE], shape = x[1], rate = x[2]) - pgamma(lowerbound[vdelta == 0 & is.na(lowerbound) == FALSE], shape = x[1], rate = x[2])))
		}
		if(length(lowerbound[is.na(lowerbound) == FALSE]) == 0){
			loglik <- sum(log(dgamma(data[vdelta == 1], shape = x[1], rate = x[2]))) + sum(log(pgamma(data[vdelta == 0], shape = x[1], rate = x[2])))
		}
	}
	if(x[1] <= 0 | x[2] <= 0){loglik <- -Inf}
     if(loglik == -Inf){loglik <- -100000}
     
return(loglik)
}







#

Try the SurvRegCensCov package in your browser

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

SurvRegCensCov documentation built on Sept. 27, 2023, 5:09 p.m.