Sync portfolio laboratory source

This commit is contained in:
portfolio 2026-11-26 13:13:27 +03:00
commit cc224fe873
5 changed files with 88 additions and 0 deletions

17
analysis.R Normal file
View file

@ -0,0 +1,17 @@
# Синтетические данные и расчёт метрик для обоих дашбордов.
set.seed(2026)
t <- 1:56
observed <- 100 + 0.8 * t + 9 * sin(2 * pi * t / 4) + rnorm(length(t), 0, 2)
series <- ts(observed[1:48], frequency = 4)
model <- arima(series, order = c(1, 0, 0), seasonal = list(order = c(0, 1, 0), period = 4))
forecast <- as.numeric(predict(model, n.ahead = 8)$pred)
result <- data.frame(quarter = 49:56, actual = observed[49:56], forecast,
absolute_error = abs(observed[49:56] - forecast))
# Проверяет конечность основной метрики перед экспортом.
stopifnot(nrow(result) > 1, all(is.finite(result$absolute_error)))
if (sys.nframe() == 0L) {
arguments <- commandArgs(trailingOnly = TRUE)
stopifnot(length(arguments) == 1L)
write.csv(result, arguments[1], row.names = FALSE)
}