Есть ли способ извлечь функциональную форму функции правдоподобия, которая формируется функцией msm в R?
Как я могу извлечь функцию правдоподобия, которая формируется в примере ниже? Я хочу попробовать и реализовать свою собственную версию алгоритма максимизации квазиньютона, чтобы улучшить мое понимание.
library(msm)
# look at transition counts
statetable.msm(state, PTNUM, data = cav)
# define transition intensity matrix
# 1's mean a transition can occur
# 0's mean a transition should not occur
# any number can be placed on the diagonal as R overwrites the diagonals
# prior to maximising
q <- rbind(
c(0, 1, 0, 1),
c(1, 0, 1, 1),
c(0, 1, 0, 1),
c(0, 0, 0, 0)
)
# fit msm to the data
# the fnscale rescales the likelihood to prevent overflow
msm.fit <- msm(state ~ years, PTNUM, data = cav, qmatrix = q, control=list(fnscale=4000))