Skip to content

Commit

Permalink
in regressCens added a small number to avoi log 0 in the loglikelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRianiUNIPR committed May 8, 2024
1 parent 2b7a8f4 commit 5f14248
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions toolbox/regression/regressCens.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
% More About:
%
%
% The issue is one where data is censored such that while we observe the
% value, it is not the true value, which would extend beyond the range of
% the observed data. This is very commonly seen in cases where the
% dependent variable has been given some arbitrary cutoff at the lower or
% upper end of the range, often resulting in floor or ceiling effects
% respectively. The conceptual idea is that we are interested in modeling
% the underlying latent variable that would not have such restriction if it
% was actually observed.
%
% In the standard Tobit model (Tobin 1958), we have a dependent variable $y$ that is left-censored at zero:
% \begin{eqnarray}
% y_i^* & = & x_i^{\prime} \beta+\varepsilon_i \\
Expand Down Expand Up @@ -391,7 +400,7 @@


if sum(obsBelow) + sum(obsAbove) == 0
error('FSDA:regressCens:WrongInputOpt',"there are no censored observations")
warning('FSDA:regressCens:WrongInputOpt',"there are no censored observations")
end

if sum(obsBetween) == 0
Expand Down Expand Up @@ -464,6 +473,6 @@
yhat=Xin*beta;
dZ=-sum(ya.*log(normcdf((left-yhat)/sigma)+1e-12)+...
yb.*log(normcdf((yhat-right)/sigma)+1e-12)+...
+yab.*(log(normpdf((yin-yhat)/sigma))-log(sigma)));
+yab.*(log( normpdf((yin-yhat)/sigma)+1e-12 )-log(sigma)));
end
end

0 comments on commit 5f14248

Please sign in to comment.