mclements / rstpm2

An R package for generalised survival models
28 stars 11 forks source link

multcomp::glht throws error on stpm2 objects #10

Closed alexploner closed 5 years ago

alexploner commented 5 years ago

This is somewhat surprising, as you really only need a coef- and a vcov-method, both of which stpm2has... but look at this (from the documentation):

library(rstpm2)
data(brcancer)
fit <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=3)
library(multcomp)
contr = matrix(c(0, 1, 0, 0, 0), nrow=1)
glht(fit, contr)

throws error

Error : $ operator not defined for this S4 class
Error in modelparm.default(model, ...) : 
  no ‘coef’ method for ‘model’ found!

which seems to fly in the face of coef(fit) actually working as expected - presumably invoking the mle2-method? The error message seems to indicate that for some reason, stats:::coef.default was deployed by modelparm...?

Thanks!