Hello,
You write a function of two arguments, 'par' and 'data' and do not use
them in the body of the function. Furthermore, what are b0, b1x and y?
Also, take a look at ?.Machine. In particular, couldn't you use
precision0 <- .Machine$double.eps
precision1 <- 1 - .Machine$double.eps
instead of 0.000001 and 0.999999?
Hope this helps,
Rui Barradas
Em 27-05-2013 16:21, knouri escreveu:
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.
______________________________________________
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.