| Version 22 (modified by , 16 years ago) ( diff ) |
|---|
Package QltvRespModel
Max-likelihood and bayesian estimation of qualitative response models.
Weighted Boolean Regresions
Abstract class @WgtBoolReg is the base to inherit weighted boolean regressions as logit or probit or any other, given just the scalar distribution function LatexEquation( F ) and the corresponding density function LatexEquation( f ). In a weighted regression each row of input data has a distinct weight in the likelihood function. For example, it can be very usefull to handle with data extrated from an stratified sample.
This class implements max-likelihood estimation by means of package NonLinGloOpt and bayesian simulation using BysSampler.
Let be
- LatexEquation( X\in\mathbb{R}^{m\times n} ) the regression input matrix
- LatexEquation( w\in\mathbb{R}^{m} ) the vector of weights of each register
- LatexEquation( y\in\mathbb{R}^{m} ) the regression output matrix
The hypotesis is that LatexEquation( \forall i=1 \dots m )
LatexEquation( y_{i}\sim Bernoulli\left(\pi_{i}\right) )
LatexEquation( \pi_{i}=Pr\left[y_{i}=1\right] = F\left(X_{i}\beta\right) )
The likelihood function is then
and its logarithm
The gradient of the logarithm of the likelihood function will be
and the hessian is
User can and should define scalar truncated normal or uniform prior information and
bounds for all variables for which he/she has robust knowledge.
LatexEquation( \beta_k \sim N\left(\nu_k, \sigma_k \right) )
LatexEquation( l_k \le \beta_k \le u_k \wedge l_k < u_k)
When LatexEquation( \sigma_k ) is infinite or unknown we will express a uniform
prior.
When LatexEquation( l_k = -\infty) or unknown we will express that variable
has no lower bound.
When LatexEquation( u_k = +\infty) or unknown we will express that variable
has no upper bound.
It's also allowed to give any set of constraining linear inequations if they
are compatible with lower and upper bounds
LatexEquation( A \beta \le a )
Weighted Logit Regression
Class @WgtLogit is an specialization of class @WgtBoolReg that handles with weighted logit regressions.
In this case we have that scalar distribution is the logistic one.
Scalar cumulant:
Scalar density:
LatexEquation( f\left(z\right) = \frac{e^{-z}}{\left(1+e^{-z}\right)^2} )
Scalar density derivative:
LatexEquation( f'\left(z\right) = - f\left(z\right) F\left(z\right) {\left(1-e^{-z}\right)} )
Logarithm of likelihood:
Gradient:
Hessian:
From the standpoint of arithmetic discrete numerical calculation must take into account that
For this reason we must carefully try to contain the exponential expressions.
In this case it will use the following asymptotic equalities
LatexEquation( \ln\left(1+e^{-z}\right)\;\overset{z\rightarrow-\infty}{\longrightarrow}\;-z )
LatexEquation( \frac{e^{-z}}{1+e^{-z}}\;\overset{z\rightarrow-\infty}{\longrightarrow}\;1 )
Weighted Probit Regression
Class @WgtProbit is an specialization of class @WgtBoolReg that handles with weighted probit regressions.
In this case we have that scalar distribution is the standard normal one.
Scalar cumulant:
Scalar density:
Scalar density derivative:
Logarithm of likelihood:
Gradient:
Hessian:
To avoid numerical problems will use the following equality
The function logarithm of complemetary error function
LatexEquation( \ln\left(1-erf\left(u\right)\right) )
is implemented as gsl_sf_log_erfc that is available in TOL.
In the gradient it appears two times the Hazard function
LatexEquation( h\left(z\right)=\frac{\phi\left(z\right)}{1-\Phi\left(z\right)}=\frac{\phi\left(z\right)}{\Phi\left(-z\right)} )
LatexEquation( \frac{\phi\left(z\right)}{\Phi\left(z\right)}=\frac{\phi\left(-z\right)}{\Phi\left(z\right)}=h\left(-z\right) )
decreases rapidly as LatexEquation(z) approaches LatexEquation(-\infty) and asymptotes to LatexEquation(h\left(z\right) \sim z ) as LatexEquation(z) approaches LatexEquation(+\infty.)
Hazard function is implemented as gsl_sf_hazard that is also available in TOL.
