Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[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 <[email protected]>
To
[email protected]
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')
end
use http://www.stata-press.com/data/r11/cancer, 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:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/