Dear all: 

I am writing the following small function for a probit likelihood.
As indicated, in order to avoid p=1 or p=0, I defined some precisions.
I feel however, that there might be a better way to do this.
Any help is greatly appreciated.

##########################################################

##set limits to avoid px=0 or px=1
precision1   <- 0.999999
precision0   <- 0.000001

logpost <- function(par, data){
px    <- pnorm(b0 + b1x)
# to avoid px=1 or px=0
px[px >  precision1] <- precision1
px[px <  precision0] <- precision0
loga  <- sum( y*log(px)+(1-y)*log(1-px) )
loga
}

#########################################################



Best,
 

________________________________
Keramat Nourijelyani, PhD
Associate Professorof Biostatistics
Tehran University of Medical Sciences
http://tums.ac.ir/faculties/nourij

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to