Open jackbrookes opened 5 years ago
Thanks for sharing the code! One quick question: How is data_fun
getting the data if not passed as an argument?
In my code, data_fun
is a function made from a function, something like:
make_data_fun <- function(df) {
return(function(indexes) df[indexes])
}
I do this because my input data is not actually a dataframe but a list, so removing observations isn't as simple as subsetting with [
like the above example.
I see. Still, the data is not explicitly passed inside the code, which may be confusing to people trying to use your function.
Hello, I am very interested in using this technique to compare a set of time-series models. However, my models are written directly in stan and I interface with them through
rstan
.I have been working on a function to perform approximate LFO like the one you have here: https://github.com/paul-buerkner/LFO-CV-paper/blob/master/sim_functions.R#L123-L204
Computing log likelihood and re-sampling data can vary on a case by case basis, so here's my attempt at a general function. It takes two functions as parameters, which return log likelihood of (new or existing) observations using a
stanfit
object, and a new slice of input observations according to requested indexes respectively. Just posting here as it might be helpful and hopefully someone can spot any errors.EDIT: Modified
data_fun
usage for clarity, now pass dataset as well as subsetting function