I am trying to run a program which generates data from various covariate distributions, and finds the maximum likelihood estimator by explicitly maximising the log likelihood function. I am specifically working with a logistic regression model. The problem is that I keep getting nan for my log likelihood values, because some probabilities are inevitably going to be sufficiently close to 0 or 1 that it gives problems in the log. This means that the optimisation method won't work!
This problem was also asked here in this post and the answer said to use the
scipy.stats.norm.logcdf method or
scipy.stats.norm.logsf but I cannot find any thorough documentation about these or how to use them. How and if it works to solve the problem. I would appreciate if someone could point me towards an example of using these, and explain what the output is.