Skip to content

Commit

Permalink
Fixed int with not cp
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipMostert committed Aug 8, 2024
1 parent 3a21e75 commit 979b5e9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/blockedCV.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,24 @@ blockedCV <- function(data, options = list(),

})))

if (method == 'Predict') {

fams <- unlist(lapply(trainLiks, function(x) x$family)) == 'cp'

if (!any(fams)) {

ips <- caerulescensModel$.__enclos_env__$private$IPS
ips$respIPS <- 0
ipsLike <- inlabru::like(formula = respIPS ~ .,
include = formula_terms, E = ips$weight,
family = 'poisson', data = ips)
trainLiks[['ips']] <- ipsLike
uFam <- TRUE
} else uFam <- FALSE

} else uFam <- FALSE


comp_keep <- comp_terms %in% formula_terms

if (!all(comp_keep)) {
Expand Down Expand Up @@ -264,6 +282,8 @@ blockedCV <- function(data, options = list(),

optionsTrain <- append(options, foldOptions)

if (uFam) optionsTrain$control.family <- append(optionsTrain$control.family, list(list(link = 'log')))

##Calculate DIC for just this model?
trainedModel <- try(inlabru::bru(components = thinnedComponents,
trainLiks,
Expand Down Expand Up @@ -332,6 +352,7 @@ blockedCV <- function(data, options = list(),
if (inherits(testModel, 'try-error')) results[[paste(dataToUse, collapse = ' and ')]][[paste0('fold',fold)]] <- NA
else results[[paste(dataToUse, collapse = ' and ')]][[paste0('fold',fold)]] <- testModel$mlik[[1]] #trainedModel$mlik[[1]] -


}

}
Expand Down

0 comments on commit 979b5e9

Please sign in to comment.