Skip to content

Commit

Permalink
fix predict function without fixedData
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Devaux authored and Anthony Devaux committed Feb 23, 2024
1 parent 19f873b commit 1d638a8
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@
#' @export
predict.DynForest <- function(object,
timeData = NULL, fixedData = NULL,
idVar, timeVar,
t0 = NULL, ...){
idVar, timeVar, t0 = NULL, ...){

Longitudinal <- Factor <- Numeric <- NULL

if (!methods::is(object,"DynForest")){
stop("'object' should be an object of 'DynForest' class!")
Expand Down Expand Up @@ -129,7 +130,7 @@ predict.DynForest <- function(object,
timeData <- timeData[which(timeData[,idVar]%in%timeData_id_noNA),]

}else{
stop("No subject has at least one measurement by marker !")
stop("One measurement or more is required for each marker by subject!")
}

Inputs <- c(Inputs, "timeData")
Expand Down Expand Up @@ -167,8 +168,6 @@ predict.DynForest <- function(object,
id = timeData[,idVar],
time = timeData[,timeVar],
model = object$Longitudinal.model)
}else{
Longitudinal <- NULL
}

if (!is.null(fixedData)){
Expand All @@ -183,16 +182,12 @@ predict.DynForest <- function(object,
Factor <- list(type = "Factor",
X = subset(fixedData, select = names(var_fact[which(var_fact==T)])),
id = fixedData[,idVar])
}else{
Factor <- NULL
}

if (length(var_num[which(var_num==T)])>0){
Numeric <- list(type = "Numeric",
X = subset(fixedData, select = names(var_num[which(var_num==T)])),
id = fixedData[,idVar])
}else{
Numeric <- NULL
}

}
Expand Down

0 comments on commit 1d638a8

Please sign in to comment.