You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We still have a bug when using absoluteRisk with family = "glmnet". Specifically, the issue arises when we use fitSmoothHazard.fit with a matrix of covariate X without any column names:
library(casebase)
#> See example usage at http://sahirbhatnagar.com/casebase/
library(survival)
library(mvtnorm)
n<-75p<-5# Generate covariatesX<- rmvnorm(n=n, sigma= diag(p))
# Generate failure timesfail_times<- rexp(n=n,
rate=1)
# Generate censoring timescens_times<- runif(n=n, min=1, max=3) *
rexp(n=n, rate=1)
times<- pmin(fail_times, cens_times)
status<- as.numeric(fail_times<cens_times)
model<- fitSmoothHazard.fit(X, Surv(times, event=status),
time="time", event="status",
family="glmnet")
# Next line fails
absoluteRisk(model, time=1,
newdata=X[1:5, ])
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 88# No longer fails if we add column names
colnames(X) <- paste0("V", seq_len(p))
absoluteRisk(model, time=1,
newdata=X[1:5, ])
#> time #> 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000#> 1 0.5258076 0.5258076 0.5258076 0.5258076 0.5258076
When X has no column names, colnames(newdata) is simply NULL and therefore colnames(newdata) != object$timeVar is a zero-length logical vector. As a consequence, newdata2 is a matrix without any column!
The text was updated successfully, but these errors were encountered:
We still have a bug when using
absoluteRisk
withfamily = "glmnet"
. Specifically, the issue arises when we usefitSmoothHazard.fit
with a matrix of covariateX
without any column names:Created on 2021-06-30 by the reprex package (v2.0.0)
The culprit is these lines:
casebase/R/absoluteRisk.R
Lines 253 to 255 in c4d208c
When
X
has no column names,colnames(newdata)
is simplyNULL
and thereforecolnames(newdata) != object$timeVar
is a zero-length logical vector. As a consequence,newdata2
is a matrix without any column!The text was updated successfully, but these errors were encountered: