Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Error using hotdeck with mlogit : Are you sure varname is in the model??


From   "Grealy, Patrick J" <[email protected]>
To   <[email protected]>
Subject   st: Error using hotdeck with mlogit : Are you sure varname is in the model??
Date   Fri, 29 Jul 2005 14:21:51 -0500

Hi,
I wonder if there are any hotdeck users who might help me. I'm also
sending this to Adrian Mander, the author of hotdeck.

I've used hotdeck in the past with command(logistic ...) but this is the
first time using command(mlogit ...) and it fails with an error. The
error is:
>        Are you sure drug2 is in the model??
>        r(111);

My Stata log below includes some successful commands as well as the
command that fails, all using the same dataset. I believe hotdeck runs
under version 6. I ran test_hot.do with version control for version 9
and version 8.2 and got the same results.

Thanks,
Pat G.
------------------------------------------------------------------------
----
       log:  c:\test_hot.log
  log type:  text
 opened on:  29 Jul 2005, 14:10:51

. do c:\test_hot, nostop

. version 9

. about

Stata/SE 9.0 for Windows
Born 05 Jul 2005
Copyright (C) 1985-2005

Total physical memory:     1046508 KB
Available physical memory:  631004 KB

Single-user Stata for Windows perpetual license:
       Serial number:  8199044330
         Licensed to:  Patrick Grealy
                       UTSPH

. which hotdeck
c:\ado\plus\h\hotdeck.ado
*! Date        : 16 July 2003
*! Version     : 1.61
*! Authors     : Adrian Mander/David Clayton
*! Email       : [email protected]
*! Description : Hotdeck imputation

. 
. sysuse cancer
(Patient Survival in Drug Trial)

. 
. gen drug2 = .                          // drug2 is 0/1 for
placebo/drug2
(48 missing values generated)

. replace drug2=0 if drug==1
(20 real changes made)

. replace drug2=1 if drug==2
(14 real changes made)

. 
. replace died=. if age==55 | age==65    // create missing events to
test
(6 real changes made, 6 to missing)

. label define dlbl 0 "Survived" 1 "Died"

. label val died dlbl

. 
. gen died_age = died                    // died_age is 0/1/2 test
variable
(6 missing values generated)

. replace died_age = 2 if age >= 55 & died < .
(23 real changes made)

. label define dalbl 0 "Survived" 1 "Died,age < 55" 2 "Died,age 55+"

. label val died_age dalbl

. 
. tab died_age drug2, miss

               |              drug2
      died_age |         0          1          . |     Total
---------------+---------------------------------+----------
      Survived |         0          4          5 |         9 
 Died,age < 55 |         8          1          1 |        10 
  Died,age 55+ |        10          7          6 |        23 
             . |         2          2          2 |         6 
---------------+---------------------------------+----------
         Total |        20         14         14 |        48 


. 
. mlogit died_age drug2 age, rrr baseoutcome(0) // this seems to work ok

Iteration 0:   log likelihood = -28.551096
Iteration 1:   log likelihood = -11.584359
Iteration 2:   log likelihood = -6.3870374
Iteration 3:   log likelihood = -3.6979512
Iteration 4:   log likelihood = -2.0471784
Iteration 5:   log likelihood = -1.0230007
Iteration 6:   log likelihood = -.46376887
Iteration 7:   log likelihood = -.19303895
Iteration 8:   log likelihood = -.07527831
Iteration 9:   log likelihood =  -.0283324
Iteration 10:  log likelihood = -.01051255
Iteration 11:  log likelihood =  -.0038799
Iteration 12:  log likelihood = -.00142909
Iteration 13:  log likelihood = -.00052598
Iteration 14:  log likelihood = -.00019353
Iteration 15:  log likelihood =  -.0000712
Iteration 16:  log likelihood = -.00002619
Iteration 17:  log likelihood = -9.637e-06
Iteration 18:  log likelihood = -3.545e-06
Iteration 19:  log likelihood = -1.304e-06
Iteration 20:  log likelihood = -4.798e-07
Iteration 21:  log likelihood = -1.765e-07
Iteration 22:  log likelihood = -6.493e-08
Iteration 23:  log likelihood = -2.389e-08
Iteration 24:  log likelihood = -8.787e-09
Iteration 25:  log likelihood = -3.233e-09
Iteration 26:  log likelihood = -1.189e-09
Iteration 27:  log likelihood = -4.375e-10
Iteration 28:  log likelihood = -1.609e-10
Iteration 29:  log likelihood = -5.921e-11
Iteration 30:  log likelihood = -2.178e-11
Iteration 31:  log likelihood = -8.013e-12
Iteration 32:  log likelihood = -2.949e-12
Iteration 33:  log likelihood = -1.093e-12
Iteration 34:  log likelihood = -4.023e-13
Iteration 35:  log likelihood = -1.482e-13
Iteration 36:  log likelihood = -5.085e-14
Iteration 37:  log likelihood = -1.910e-14
Iteration 38:  log likelihood = -9.437e-15
Iteration 39:  log likelihood = -6.439e-15
Iteration 40:  log likelihood = -7.772e-16
Iteration 41:  log likelihood = -4.441e-16

Multinomial logistic regression                   Number of obs   =
30
                                                  LR chi2(4)      =
57.10
                                                  Prob > chi2     =
0.0000
Log likelihood = -4.441e-16                       Pseudo R2       =
1.0000

------------------------------------------------------------------------
----
    died_age |        RRR   Std. Err.      z    P>|z|   [95% Conf.
Interval]
-------------+----------------------------------------------------------
----
Died,age <55 |
       drug2 |   9.7e-130   4.5e-121    -0.00   1.000          0
.
         age |   1.62e-16   8.73e-09    -0.00   1.000          0
.
-------------+----------------------------------------------------------
----
Died,age 55+ |
       drug2 |   .0157184    4366115    -0.00   1.000          0
.
         age |   3.15e+08          .        .       .          .
.
------------------------------------------------------------------------
----
(died_age==Survived is the base outcome)

. 
. * why doesn't the following hotdeck work? i get the error: /*
>        Are you sure drug2 is in the model??
>        r(111);
> */
. 
. hotdeck died_age, by(drug2) ///
> command(mlogit died_age drug2 age, rrr baseoutcome(1)) ///
> parms(drug2 age) impute(5) seed(65432)
DELETING all matrices....

Missing Patterns
----------------

Table of the Missing data patterns 
 * signifies missing and - is not missing

Varlist order: died_age

    Missing |
    pattern |      Freq.     Percent        Cum.
------------+-----------------------------------
          * |          6       12.50       12.50
          - |         42       87.50      100.00
------------+-----------------------------------
      Total |         48      100.00

STRATUM information
-------------------

Listing the number observed (No_obs) and 
the number missing (No_miss) in each stratum

  +--------------------------+
  | drug2   No_obs   No_miss |
  |--------------------------|
  |     0       18         2 |
  |     1       12         2 |
  |     .       12         2 |
  +--------------------------+


   34
(Patient Survival in Drug Trial)
Are you sure drug2 is in the model??
r(111);

. 
. * the following hotdeck using logistic instead of mlogit seems to work
. 
. hotdeck died, by(drug2) ///
> command(logistic died drug2 age) ///
> parms(drug2 age) impute(5) seed(65432)
DELETING all matrices....

Missing Patterns
----------------

Table of the Missing data patterns 
 * signifies missing and - is not missing

Varlist order: died

    Missing |
    pattern |      Freq.     Percent        Cum.
------------+-----------------------------------
          * |          6       12.50       12.50
          - |         42       87.50      100.00
------------+-----------------------------------
      Total |         48      100.00

STRATUM information
-------------------

Listing the number observed (No_obs) and 
the number missing (No_miss) in each stratum

  +--------------------------+
  | drug2   No_obs   No_miss |
  |--------------------------|
  |     0       18         2 |
  |     1       12         2 |
  |     .       12         2 |
  +--------------------------+


   34
(Patient Survival in Drug Trial)
(Patient Survival in Drug Trial)
(Patient Survival in Drug Trial)
(Patient Survival in Drug Trial)
(Patient Survival in Drug Trial)

                   Number of Obs.               =  34
                   No. of Imputations           =  5
                   % Lines of Missing Data      =  82.352941 %
                   F( 17.207 ,2)                =     4.2202
                   Prob > F                     =     0.0323
------------------------------------------------------------------------
----
Variable |  Average   Between   Within     Total      df        t
p-value
         |  Coef.     Imp. SE   Imp. SE     SE                         
---------+--------------------------------------------------------------
----
drug2    | -3.3562     0.154     1.216     1.227   11232.5  -2.734
0.006
age      |  0.1031     0.029     0.084     0.090     267.6   1.149
0.252
---------+--------------------------------------------------------------
----
Variable |  [95% Conf. Interval]
---------+--------------------------------------------------------------
----
drug2    |   -6.1078   -0.6046
age      |   -0.0992    0.3053
------------------------------------------------------------------------
----

. 
end of do-file

. log close
       log:  c:\test_hot.log
  log type:  text
 closed on:  29 Jul 2005, 14:10:59
------------------------------------------------------------------------
----

*
*   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/



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