Sync portfolio laboratory source

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

16
analysis.R Normal file
View file

@ -0,0 +1,16 @@
# Синтетические данные и расчёт метрик для обоих дашбордов.
set.seed(2026)
years <- runif(150, 0, 30)
education <- sample(10:18, 150, replace = TRUE)
income <- exp(9 + 0.035 * years + 0.07 * education + rnorm(150, 0, 0.22))
model <- lm(log(income) ~ years + education)
result <- data.frame(term = names(coef(model))[-1], multiplier = exp(unname(coef(model)[-1])))
stopifnot(abs(mean(residuals(model))) < 1e-10)
# Проверяет конечность основной метрики перед экспортом.
stopifnot(nrow(result) > 1, all(is.finite(result$multiplier)))
if (sys.nframe() == 0L) {
arguments <- commandArgs(trailingOnly = TRUE)
stopifnot(length(arguments) == 1L)
write.csv(result, arguments[1], row.names = FALSE)
}