Skip to content

Likelihood of models with constant vs piece-wise constant rates #117

@ellessenne

Description

@ellessenne

Hi,

I hope all is well.
I have a question about the likelihood of models with constant rates vs the likelihood of models with piece-wise constant rates:

library(msm)
twoway4.q <- rbind(
  c(-0.5, 0.25, 0, 0.25),
  c(0.166, -0.498, 0.166, 0.166),
  c(0, 0.25, -0.5, 0.25),
  c(0, 0, 0, 0)
)
cav.msm0 <- msm(
  state ~ years,
  subject = PTNUM,
  data = cav,
  qmatrix = twoway4.q,
  obstype = 1
)
cav.msm1 <- msm(
  state ~ years,
  subject = PTNUM,
  data = cav,
  qmatrix = twoway4.q,
  obstype = 1,
  pci = fivenum(cav$years)[2:4]
)
logLik.msm(cav.msm0)
#> 'log Lik.' -1993.044 (df=7)
logLik.msm(cav.msm1)
#> 'log Lik.' -2009.05 (df=28)
lrtest.msm(cav.msm0, cav.msm1)
#>          -2 log LR df p
#> cav.msm1 -32.01333 21 1

Created on 2025-09-18 with reprex v2.1.1

I was expecting model cav.msm0 to be nested within cav.msm1, but the likelihood values do not seem comparable. Is this because of the expanded dataset constructed by {msm} under the hood to implement the pci argument?

Many thanks,

Alessandro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions