R/loglik_probit.R

#' Log likelihood function
#'
#' This is the loglikelihood function used in the probit estimation.
#' This function doesn't do anything on its own, its

loglik_probit <- function(param, X, y){
    #param have ncol(X)+1 element (sigma)
    b= param[0:ncol(X)]
    sigma=param[length(param)]
    # adding a col of 1 to matrix of covariates X
    xb=X %*% b
    result=ifelse(y>0, pnorm(xb/sigma,log=T), 1-pnorm(xb/sigma,log=T))
    return(sum(result))
}
2pie/myprobit documentation built on May 5, 2019, 10:42 a.m.