[R] MLE for probit regression. How to avoid p=1 or p=0

2013-05-27 Thread knouri


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.99
precision0   - 0.01

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.


Re: [R] MLE for probit regression. How to avoid p=1 or p=0

2013-05-27 Thread Rui Barradas

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.01 and 0.99?

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.99
precision0   - 0.01

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.