Dear Stata users,
Due to a separation problem in my data, I need to code the ML function for Cox regression with penalized likelihood. I thought about using the approximation of Firth, which consists of adding 1/2*ln(det(I)) to the Ln(Likelihood), where I is the Fisher's Information Matrix. This same idea was programmed by Joseph Coveney in 2008 for logistic regression in the ado-file firthlogit. In this ado-file the Fisher's information matrix is constructed by the ml-evaluator during maximization, assuming the variance of a Bernoulli distribution (p * (1-p)).
I do not know how to build the Fisher's information matrix for the Cox regression. What is the distribution and variance assumed? Any help will be really appreciated.
I'm using the following evaluator (method d0):
program define mycox2_d0
version 9.1
args todo b lnf
local negt "$ML_y1" // $ML_y1 is -t
local d "$ML_y2" // $ML_y2 is d
tempvar xb B A sumd last L
mleval `xb' = `b'
// data assumed already sorted by `negt' and `d'
local byby "by `negt' `d'"
local wxb "$ML_w*`xb'"
quietly {
gen double `B' = sum($ML_w*exp(`xb'))
`byby': gen double `A' = cond(_n==_N, sum(`wxb'), .) if `d'==1
`byby': gen `sumd' = cond(_n==_N, sum($ML_w*`d'), .)
`byby': gen byte `last' = (_n==_N & `d' == 1)
gen double `L' = `A' - `sumd'*ln(`B') if `last'
mlsum `lnf' = `L' if `last', noweight
/* Construct Fisher information matrix I */
/* Penalized lnf (+ ln(det(I))/ 2) */
}
end
Due to a separation problem in my data, I need to code the ML function for Cox regression with penalized likelihood. I thought about using the approximation of Firth, which consists of adding 1/2*ln(det(I)) to the Ln(Likelihood), where I is the Fisher's Information Matrix. This same idea was programmed by Joseph Coveney in 2008 for logistic regression in the ado-file firthlogit. In this ado-file the Fisher's information matrix is constructed by the ml-evaluator during maximization, assuming the variance of a Bernoulli distribution (p * (1-p)).
I do not know how to build the Fisher's information matrix for the Cox regression. What is the distribution and variance assumed? Any help will be really appreciated.
I'm using the following evaluator (method d0):
program define mycox2_d0
version 9.1
args todo b lnf
local negt "$ML_y1" // $ML_y1 is -t
local d "$ML_y2" // $ML_y2 is d
tempvar xb B A sumd last L
mleval `xb' = `b'
// data assumed already sorted by `negt' and `d'
local byby "by `negt' `d'"
local wxb "$ML_w*`xb'"
quietly {
gen double `B' = sum($ML_w*exp(`xb'))
`byby': gen double `A' = cond(_n==_N, sum(`wxb'), .) if `d'==1
`byby': gen `sumd' = cond(_n==_N, sum($ML_w*`d'), .)
`byby': gen byte `last' = (_n==_N & `d' == 1)
gen double `L' = `A' - `sumd'*ln(`B') if `last'
mlsum `lnf' = `L' if `last', noweight
/* Construct Fisher information matrix I */
/* Penalized lnf (+ ln(det(I))/ 2) */
}
end