X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FF_Neighbors.R;h=3abd0fffa7919b04a9540c1ce438042bdf144d1b;hb=613a986f1517ab5a641771da62eba6c7f5a41577;hp=f1aecb5ccb637a581e1984f444564786ce561ff6;hpb=469529710f56c790ae932b45d13fed2e34bcabf2;p=talweg.git diff --git a/pkg/R/F_Neighbors.R b/pkg/R/F_Neighbors.R index f1aecb5..3abd0ff 100644 --- a/pkg/R/F_Neighbors.R +++ b/pkg/R/F_Neighbors.R @@ -164,17 +164,16 @@ NeighborsForecaster = setRefClass( { h_exo = ifelse(simtype=="mix", h[2], h) - # TODO: [rnormand] if predict_at == 0h then we should use measures from day minus 1 - M = matrix( nrow=1+length(fdays_indices), ncol=1+length(dat[[today]]$exo_hat) ) - M[1,] = c( dat[[today]]$level, as.double(dat[[today]]$exo_hat) ) + M = matrix( nrow=1+length(fdays_indices), ncol=1+length(dat[[today]]$exo) ) + M[1,] = c( dat[[today]]$level, as.double(dat[[today]]$exo) ) for (i in seq_along(fdays_indices)) { M[i+1,] = c( dat[[ fdays_indices[i] ]]$level, - as.double(dat[[ fdays_indices[i] ]]$exo_hat) ) + as.double(dat[[ fdays_indices[i] ]]$exo) ) } sigma = cov(M) #NOTE: robust covariance is way too slow - sigma_inv = qr.solve(sigma) + sigma_inv = solve(sigma) #TODO: use pseudo-inverse if needed? # Distances from last observed day to days in the past distances2 = rep(NA, nrow(M)-1)