Skip to content

Commit

Permalink
ensure lfo_cv returns only elpds for the evaluated timepoints
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjclark committed Nov 14, 2024
1 parent 73304bf commit 26e3ba2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions R/lfo_cv.mvgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ lfo_cv.mvgam = function(object,
}

fit_past <- update(object,
data = data_splits$data_train,
newdata = data_splits$data_test,
lfo = TRUE,
noncentred = noncentred,
silent = silent)
data = data_splits$data_train,
newdata = data_splits$data_test,
lfo = TRUE,
noncentred = noncentred,
silent = silent)

# Calculate log likelihoods of forecast observations for the next
# fc_horizon ahead observations
Expand Down Expand Up @@ -265,10 +265,10 @@ lfo_cv.mvgam = function(object,
approx_elpds[i + 1] <- log_sum_exp(lw + sum_rows(loglik_past[,fc_indices]))
}
}
return(structure(list(elpds = approx_elpds[(min_t + 1):N],
return(structure(list(elpds = approx_elpds[(min_t + 1):(N - fc_horizon)],
sum_ELPD = sum(approx_elpds, na.rm = TRUE),
pareto_ks = ks,
eval_timepoints = (min_t + 1):N,
pareto_ks = ks[-1],
eval_timepoints = (min_t + 1):(N - fc_horizon),
pareto_k_threshold = pareto_k_threshold),
class = 'mvgam_lfo'))
}
Expand Down

0 comments on commit 26e3ba2

Please sign in to comment.