[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

# st: Re: Logit with constraints and no constant

 From "Rodrigo A. Alfaro" <[email protected]> To <[email protected]> Subject st: Re: Logit with constraints and no constant Date Tue, 26 Sep 2006 10:14:51 -0400

```Hi,

Also, I could not add constraint to -mlogit-. The following
is the result using auto dataset:

sysuse auto
(1978 Automobile Data)

constraint define 1 _cons = 0

mlogit  foreign mpg weight, const(1)

invalid syntax
r(198);

I wrote a easy program to replicate logit... and you
can add constraint. If you want to use [if] and [in]
statement you have to improve the base-program.

program mylogit
1. version 8
2. args lnf theta
3. tempvar cdf
4. quietly gen double `cdf' = exp(`theta')/(1+exp(`theta'))
5. quietly replace `lnf'=ln(`cdf') if \$ML_y1!=0
6. quietly replace `lnf'=ln(1-`cdf') if \$ML_y1==0
7. end

************** Example **********************

/// Comparing with logit and mlogit

ml model lf mylogit (foreign =mpg weight)

ml maximize, nolog

Number of obs   =
74
Wald chi2(2)    =
17.78
Log likelihood = -27.175156                       Prob > chi2     =
0.0001

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
mpg |  -.1685869   .0919175    -1.83   0.067    -.3487418
011568
weight |  -.0039067   .0010116    -3.86
000    -.0058894    -.001924
_cons |   13.70837   4.518709     3.03   0.002     4.851859
22.56488
------------------------------------------------------------------------------

logit  foreign mpg weight, nolog

Logit estimates                                   Number of obs   =
74
LR chi2(2)      =
35.72
Prob > chi2     =
0.0000
Log likelihood = -27.175156                       Pseudo R2       =
0.3966

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
mpg |  -.1685869   .0919174    -1.83   0.067    -.3487418
011568
weight |  -.0039067   .0010116    -3.86
000    -.0058894    -.001924
_cons |   13.70837   4.518707     3.03   0.002     4.851864
22.56487
------------------------------------------------------------------------------

mlogit  foreign mpg weight, nolog

Multinomial logistic regression                   Number of obs   =
74
LR chi2(2)      =
35.72
Prob > chi2     =
0.0000
Log likelihood = -27.175156                       Pseudo R2       =
0.3966

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
Foreign      |
mpg |  -.1685869   .0919174    -1.83   0.067    -.3487418
011568
weight |  -.0039067   .0010116    -3.86
000    -.0058894    -.001924
_cons |   13.70837   4.518707     3.03   0.002     4.851864
22.56487
------------------------------------------------------------------------------
(Outcome foreign==Domestic is the comparison group)

/// Comparing with mlogit under noconstant option

ml model lf mylogit (foreign = mpg weight, nocons)

ml maximize, nolog

Number of obs   =
74
Wald chi2(2)    =
19.84
Log likelihood = -33.080146                       Prob > chi2     =
0.0000

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
mpg |   .1077839   .0321631     3.35   0.001     .0447455
1708224
weight |  -.0011884     .00028    -4.24
0.000    -.0017371   -.0006397
------------------------------------------------------------------------------

mlogit  foreign mpg weight, nocons nolog

Multinomial logistic regression                   Number of obs   =
74
LR chi2(2)      =
36.43
Prob > chi2     =
0.0000
Log likelihood = -33.080146                       Pseudo R2       =
0.3551

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
Foreign      |
mpg |   .1077839   .0321613     3.35   0.001     .0447489
170819
weight |  -.0011884   .0002799    -4.24
0.000     -.001737   -.0006397
------------------------------------------------------------------------------
(Outcome foreign==Domestic is the comparison group)

/// Alternative you can use the constraint of nonconstant

ml model lf mylogit (foreign =mpg weight), const(1)

ml maximize, nolog

Number of obs   =
74
Wald chi2(2)    =
19.84
Log likelihood = -33.080146                       Prob > chi2     =
0.0000

( 1)  [eq1]_cons = 0
------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
mpg |   .1077839   .0321614     3.35   0.001     .0447488
1708191
weight |  -.0011884   .0002799    -4.24
0.000    -.0017371   -.0006397
_cons |  (dropped)
------------------------------------------------------------------------------

***************** End example *******************************

----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Tuesday, September 26, 2006 7:31 AM
Subject: st: Logit with constraints and no constant

I want to estimate a logit with constraints and no constant, does anybody
know if this is possible.

Logit does not seem to allow constraints, so I have used mlogit, but when I
include constraints and nocon I get the error : "redundant or inconsistent
constraints".

Is there any practical reason for this?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

• References:

 © Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index