R/frm_logistic_density.R

Defines functions frm_logistic_density

## File Name: frm_logistic_density.R
## File Version: 0.141

frm_logistic_density <- function(model, y, design_matrix=NULL, case=NULL)
{
    coef0 <- model$coef
    coef1 <- model$coefficients
    if (!is.null(coef1)){
        if ( max( abs(coef1-coef0) )>1e-14){
            model$coef <- model$coefficients
        }
    }
    if ( is.null(design_matrix) ){
        y_pred <- predict(model)
    } else {
        y_pred <- predict(model, newdata=design_matrix)
    }
    d1 <- y_pred
    d1 <- ifelse( y==1, d1, 1-d1 )
    d2 <- frm_normalize_posterior( post=d1, case=case )
    res <- list( like=d1, post=d2 )
    return(res)
}

Try the mdmb package in your browser

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

mdmb documentation built on March 7, 2023, 6:58 p.m.