I recently tried to fit some Anderson Gill models using the rstpm2 package. For this, I wanted to use a counting type Surv() object. This works out nicely when specifying the Surv() call without explicitly setting the type argument to counting. However, when I did explicitly specified type = "counting" in the Surv() call, I received the following error:
error: element-wise multiplication: incompatible matrix dimensions: 686x1 and 1x1
Reproducible example
# Load package
library(rstpm2)
# Attache breast cancer dataset
data(brcancer2)
# Define start time
brcancer2 <- transform(brcancer,
startTime = ifelse(hormon == 0, rectime * 0.5, 0))
# Stpm2 call without explicit specification of the type argument
stpm2(Surv(startTime, rectime, censrec == 1) ~ hormon,
data = brcancer2,
df = 3))
# Stpm2 call with explicit specification of the type argument
# Do not run, this will cause your R-session to terminate
stpm2(Surv(startTime, rectime, censrec == 1, type = "counting") ~ hormon,
data = brcancer2,
df = 3))
Those two models should be equivalent, since the default type of Surv is counting if the event variable is not of type factor and two times are specified as is the case in the example above. Do you know what might cause this issue? I just wanted to be explicit about the type in my script, so that I don't need to remember the deafults of Surv() when reading through my code in the future.
Thank you for your help!
Kindly,
Joshua
Session info
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_Sweden.1252 LC_CTYPE=English_Sweden.1252 LC_MONETARY=English_Sweden.1252
[4] LC_NUMERIC=C LC_TIME=English_Sweden.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstpm2_1.5.2 survival_3.2-11
loaded via a namespace (and not attached):
[1] bdsmatrix_1.3-4 Rcpp_1.0.7 lattice_0.20-44 mvtnorm_1.1-2
[5] MASS_7.3-54 grid_4.1.0 nlme_3.1-152 stats4_4.1.0
[9] Matrix_1.3-3 bbmle_1.0.24 deSolve_1.28 tools_4.1.0
[13] numDeriv_2016.8-1.1 compiler_4.1.0 mgcv_1.8-35
Joshua: this is a nice catch. The parsing of the event indicator assumes that type was not specified. Now corrected on GitHub (see f47373be0e629304ef9154b280fc218758f17687).
Dear Mark,
I recently tried to fit some Anderson Gill models using the rstpm2 package. For this, I wanted to use a counting type
Surv()
object. This works out nicely when specifying theSurv()
call without explicitly setting thetype
argument tocounting
. However, when I did explicitly specifiedtype = "counting"
in theSurv()
call, I received the following error:Reproducible example
Those two models should be equivalent, since the default type of
Surv
iscounting
if the event variable is not of type factor and two times are specified as is the case in the example above. Do you know what might cause this issue? I just wanted to be explicit about the type in my script, so that I don't need to remember the deafults ofSurv()
when reading through my code in the future.Thank you for your help!
Kindly, Joshua
Session info