close
Warning:
Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.
- Timestamp:
-
Dec 20, 2010, 9:33:46 PM (14 years ago)
- Author:
-
Víctor de Buen Remiro
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v2
|
v3
|
|
7 | 7 | Abstract class |
8 | 8 | [source:/tolp/OfficialTolArchiveNetwork/QltvRespModel/WgtBoolReg.tol @WgtBoolReg] |
9 | | is the base to inherit weighted boolean regressions as logit or probit or any other |
10 | | given justthe scalar distribution function. |
| 9 | is the base to inherit weighted boolean regressions as logit or probit or any other, |
| 10 | given just the scalar distribution function [[LatexEquation( F )]] and the |
| 11 | corresponding density function [[LatexEquation( f )]]. In a weighted regression |
| 12 | each row of input data has a distinct weight in the likelihood function. For |
| 13 | example, it can be very usefull to handle with data extrated from an stratified |
| 14 | sample. |
11 | 15 | |
12 | 16 | This class implements max-likelihood by means of package |
13 | | [wiki/OfficialTolArchiveNetworkNonLinGloOpt NonLinGloOpt] and bayesian estimation |
14 | | using [wiki/OfficialTolArchiveNetworkBysSampler BysSampler]. |
| 17 | [wiki:OfficialTolArchiveNetworkNonLinGloOpt NonLinGloOpt] and bayesian estimation |
| 18 | using [wiki:OfficialTolArchiveNetworkBysSampler BysSampler]. |
| 19 | |
| 20 | Let be |
| 21 | * [[LatexEquation( X\in\mathbb{R}^{m\times n} )]] the regression input matrix |
| 22 | * [[LatexEquation( w\in\mathbb{R}^{m} )]] the vector of weights of each register |
| 23 | * [[LatexEquation( y\in\mathbb{R}^{m} )]] the regression output matrix |
| 24 | |
| 25 | The hypotesis is that [[LatexEquation( \forall i=1 \dots m )]] |
| 26 | |
| 27 | [[LatexEquation( y_{i}\sim Bernoulli\left(\pi_{i}\right) )]] |
| 28 | [[LatexEquation( \pi_{i}=Pr\left[y_{i}=1\right] = F\left(X_{i}\beta\right) )]] |
| 29 | |
| 30 | The likelihood function is then |
| 31 | |
| 32 | [[LatexEquation( lk\left(\beta\right)=\underset{i}{\underset{i}{\prod}\pi_{i}^{w_{i}y_{i}}\left(1-\pi_{i}\right)^{w_{i}\left(1-y_{i}\right)}} )]] |
| 33 | |
| 34 | and its logarithm |
| 35 | |
| 36 | [[LatexEquation( L\left(\beta\right)=\ln\left(lk\left(\beta\right)\right)=\underset{i}{\sum}w_{i}\left(y_{i}\ln\left(\pi_{i}\right)+\left(1-y_{i}\right)\ln\left(1-\pi_{i}\right)\right) )]] |
| 37 | |
| 38 | The gradient of the logarithm of the likelihood function will be |
| 39 | |
| 40 | [[LatexEquation( \frac{\partial L\left(\beta\right)}{\partial\beta_{j}}=\underset{i}{\sum}w_{i}\left(y_{i}\frac{f\left(x_{i}\beta\right)}{F\left(x_{i}\beta\right)}-\left(1-y_{i}\right)\frac{f\left(x_{i}\beta\right)}{1-F\left(x_{i}\beta\right)}\right)x_{ij} )]] |
| 41 | |
| 42 | and the hessian is |
| 43 | |
| 44 | [[LatexEquation( \frac{\partial L\left(\beta\right)}{\partial\beta_{i}\partial_{j}}=\underset{k}{\sum}w_{k}\left(y_{k}\frac{f'\left(x_{k}\beta\right)F\left(x_{k}\beta\right)-f^{2}\left(x_{k}\beta\right)}{F^{2}\left(x_{k}\beta\right)}-\left(1-y_{k}\right)\frac{f'\left(x_{k}\beta\right)\left(1-F\left(x_{k}\beta\right)\right)+f^{2}\left(x_{k}\beta\right)}{\left(1-F\left(x_{k}\beta\right)\right)^{2}}\right)x_{ik}x_{jk} )]] |
| 45 | |
15 | 46 | |
16 | 47 | User can and should define scalar truncated normal or uniform prior information and |
… |
… |
|
25 | 56 | has no upper bound. |
26 | 57 | |
27 | | It's also allowed to give any set of constraining linear inequations [[BR]] [[BR]] |
| 58 | It's also allowed to give any set of constraining linear inequations if they |
| 59 | are compatible with lower and upper bounds [[BR]] [[BR]] |
28 | 60 | [[LatexEquation( A \beta \le a )]] [[BR]] [[BR]] |
29 | 61 | |
… |
… |
|
34 | 66 | that handles with weighted logit regressions. |
35 | 67 | |
| 68 | In this case we have that scalar distribution is the logistic one. |
| 69 | |
| 70 | [[LatexEquation( F\left(z\right) = \frac{1}{1+e^{-z}} )]] [[BR]] [[BR]] |
| 71 | |
| 72 | [[LatexEquation( f\left(z\right) = \frac{e^{-z}}{\left(1+e^{-z}\right)^2} ]] [[BR]] [[BR]] |
| 73 | |
| 74 | [[LatexEquation( f'\left(z\right) = -f\left(z\right) F\left(z\right) \left(1-e^{-z}\right) ]] [[BR]] [[BR]] |
| 75 | |
| 76 | [[LatexEquation( L\left(\beta\right)=\underset{i}{\sum}w_{i}\left(y_{i}x_{i}^{t}\beta-\ln\left(1+e^{x_{i}^{t}\beta}\right)\right) )]] |
| 77 | |
| 78 | [[LatexEquation( \frac{\partial L\left(\beta\right)}{\partial\beta_{j}}=\underset{i}{\sum}w_{i}\left(y_{i}x_{ij}-x_{ij}\left(\frac{e^{x_{i}^{t}\beta}}{1+e^{x_{i}^{t}\beta}}\right)\right)=\underset{i}{\sum}w_{i}x_{ij}\left(y_{i}-\left(\frac{e^{x_{i}^{t}\beta}}{1+e^{x_{i}^{t}\beta}}\right)\right) )]] |
| 79 | |
| 80 | [[LatexEquation( \frac{\partial L\left(\beta\right)}{\partial\beta_{i}\partial_{j}}=-\underset{k}{\sum}w_{k}\frac{\left(1+e^{x_{k}^{t}\beta}\right)e^{x_{k}^{t}\beta}x_{ki}x_{kj}-\left(e^{x_{k}^{t}\beta}\right)^{2}x_{ki}x_{kj}}{\left(1+e^{x_{k}^{t}\beta}\right)}=-\underset{k}{\sum}x_{ki}x_{kj}w_{k}\pi_{i}\left(1-\pi_{i}\right) )]] |
| 81 | |
36 | 82 | |
37 | 83 | === Weighted Probit Regression === |
… |
… |
|
40 | 86 | [source:/tolp/OfficialTolArchiveNetwork/QltvRespModel/WgtBoolReg.tol @WgtBoolReg] |
41 | 87 | that handles with weighted probit regressions. |
| 88 | |
| 89 | In this case we have that scalar distribution is the standard normal one. |
| 90 | |
| 91 | [[LatexEquation( F\left(z\right) = F_{0,1}\left(z\right) )]] [[BR]] [[BR]] |
| 92 | |
| 93 | [[LatexEquation( f\left(z\right) = f_{0,1}\left(z\right) )]] [[BR]] [[BR]] |
| 94 | |
| 95 | [[LatexEquation( f'\left(z\right) = -z f_{0,1}\left(z\right) ]] [[BR]] [[BR]] |
| 96 | |
| 97 | [[LatexEquation( L\left(\beta\right)=\underset{i}{\sum}w_{i}\left(y_{i}x_{i}^{t}\beta-\ln\left(1+e^{x_{i}^{t}\beta}\right)\right) )]] |
| 98 | |
| 99 | [[LatexEquation( \frac{\partial L\left(\beta\right)}{\partial\beta_{j}}=\underset{i}{\sum}w_{i}\left(y_{i}\frac{f_{0,1}\left(x_{i}\beta\right)}{F_{0,1}\left(x_{i}\beta\right)}-\left(1-y_{i}\right)\frac{f_{0,1}\left(x_{i}\beta\right)}{1-F_{0,1}\left(x_{i}\beta\right)}\right)x_{ij} )]] |
| 100 | |
| 101 | [[LatexEquation( \frac{\partial L\left(\beta\right)}{\partial\beta_{i}\partial_{j}}=-\underset{k}{\sum}w_{k}f_{0,1}\left(x_{k}\beta\right)\left(y_{k}\frac{zF_{0,1}\left(x_{k}\beta\right)+f_{0,1}\left(x_{k}\beta\right)}{F_{0,1}^{2}\left(x_{k}\beta\right)}+\left(1-y_{k}\right)\frac{-z\left(1-F_{0,1}\left(x_{k}\beta\right)\right)+f_{0,1}\left(x_{k}\beta\right)}{\left(1-F_{0,1}\left(x_{k}\beta\right)\right)^{2}}\right)x_{ik}x_{jk} )]] |