Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: ml methods d1 and d2 and robust / clustered standard errors

From   Timothée Carayol <>
Subject   st: ml methods d1 and d2 and robust / clustered standard errors
Date   Tue, 21 Sep 2010 19:19:23 +0100

Dear Statalist,

I am left rather confused with Stata's response to my attempts to
obtain robust standard errors using the -ml- command with method d1 or
d2 evaluator in Stata 11.
I tried to reproduce (word by word) the Stata 11 base reference
manual's example on this (page 1081); with no success.

My input:

cap program drop weib1
program  weib1
args  todo  b  lnf  g  negH  g1  g2 //  negH,  g1,  and  g2  are  new
tempvar  t1  t2
mleval  `t1'  =  `b',  eq(1)
mleval  `t2'  =  `b',  eq(2)
local  t  "$ML_y1"
local  d  "$ML_y2"
tempvar  p  M  R
quietly  gen  double  `p'  =  exp(`t2')
quietly  gen  double  `M'  =  (`t'*exp(-`t1'))^`p'
quietly  gen  double  `R'  =  ln(`t')-`t1'
mlsum  `lnf'  =  -`M'  +  `d'*(`t2'-`t1'  +  (`p'-1)*`R')
if  (`todo'==0  |  `lnf'>=.)  exit
tempname  d1  d2
quietly  replace  `g1'  =  `p'*(`M'-`d') /*  <--  new         */
quietly  replace  `g2'  =  `d'  -  `R'*`p'*(`M'-`d')       /*  <--
new         */
mlvecsum  `lnf'  `d1'    =  `g1',  eq(1) /*  <--  changed  */
mlvecsum  `lnf'  `d2'    =  `g2',  eq(2) /*  <--  changed  */
matrix  `g'  =  (`d1',`d2')

use,  clear

gen drug2 = drug==2
gen drug3 = drug==3

ml  model  d1  weib1  (studytime  died  =  drug2  drug3  age)  /s,  vce(robust)
ml  maximize

Stata's output:

option vce(robust) is not allowed with evaltype d1

In my understanding, the g1 and g2 variables should allow Stata to
calculate the robust standard errors. It does work in Stata 10 and
10.1; but fails with Stata 11 and 11.1. So I can fix it by using
-version 10-, but out of curiosity mainly I'd like to get it to work
in versions 11 and 11.1.

Many thanks
Timothee Carayol
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index