Ano_CrossValid() for subseasonal forecast
Hi @aho,
I am testing the use of Ano_CrossValid() for the subseasonal case with a sample data and the results are different. You can see the code below.
In the subseasonal case, the dimension in which the cross validation will be applied is called 'syear'.
Do you mind taking a look?
Cheers,
Núria
forecast <- array(1:(10 * 20 * 5),
c(sdate = 10, syear = 20, ensemble = 5))
reference <- array(1:(10 * 20 * 4),
c(sdate = 10, syear = 20))
reference2 <- s2dv::InsertDim(reference, posdim = 3, lendim = 1, name = 'ensemble')
ano_s2dv <- s2dv::Ano_CrossValid(forecast, reference2, time_dim = c('syear'),
dat_dim = c('sdate', 'ensemble'),
memb_dim = 'ensemble', memb = FALSE)
range(ano_s2dv$exp)
anomaly_crossval <- function(data) {
avg <- NA * dim(data)['syear'] # one avg per year
for (t in 1:dim(data)['syear']) {
avg[t]<- mean(data[,-t,])
}
data <- Apply(data, c('syear'), function(x) x - avg)[[1]]
}
reference <- s2dv::InsertDim(reference, posdim = 3, lendim = 1, name = 'ensemble')
ano_fun_exp <- anomaly_crossval(forecast)
ano_fun_obs <- anomaly_crossval(reference)
> range(ano_fun_exp)
[1] -504.5 504.5
> range(ano_s2dv$exp)
[1] -500 500
> range(ano_fun_obs)
[1] -104.5 104.5
> range(ano_s2dv$obs)
[1] -100 100