R/indirectCalibration.R

Defines functions indirectCalibration

Documented in indirectCalibration

indirectCalibration <-
function(x, x_cal, binom = TRUE){
	
    if(binom == TRUE){
		options(warn = -1)
    	Z_bin <- glm(x_cal ~ x, family = binomial)
   		b_bin <- coef(Z_bin)
    	y_hat_bin <- 1/(1 + (exp(-(b_bin[1] + b_bin[2] * x))))
    	return(structure(y_hat_bin))
		options(warn = 1)
    }
    else{
        N <- length(x_cal)
        x_cal_t <- ((x_cal*(N-1) + 1/2)/N)
        Z_bet <- betareg(x_cal_t ~ x, link = "logit", phi = TRUE)
        y_hat_bet <- b_bet <- coef(Z_bet)
        y_hat_bet <- 1/(1 + (exp(-(b_bet[1] + b_bet[2] * x))))    
        return(structure(y_hat_bet))
    }
}

Try the SetMethods package in your browser

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

SetMethods documentation built on March 31, 2023, 5:41 p.m.