lab-06/analysis.R

16 lines
795 B
R

# Синтетические данные и расчёт метрик для обоих дашбордов.
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)
}