TGViewer
Biostatistics on the Table Biostatistics on the Table @tabulated_stats · 341 subscribers
Post #211 286
Biostatistics on the Table Пришла в голову следующая задачка: Думаю, что многие знают, что t-тест Стьюдента является просто частным случаем МНК регрессии. set.seed(42) x <- rep(0:1, times = c(10, 15)) y <- rnorm(length(x), mean = x) t.test(y ~ x, var.equal = TRUE) |> broom::tidy()…
Я нашел такое.
В нем для воспроизведения важны не только структура дисперсии, но и использование REML и аппроксимация df по Саттервайту.
set.seed(42)
x <- rep(0:1, times = c(10, 15))
y <- rnorm(length(x), mean = x)

t.test(y ~ x, var.equal = FALSE) |>
broom::tidy() |>
dplyr::select(
estimate, statistic, df = parameter, p.value
)
#> # A tibble: 1 × 4
#> estimate statistic df p.value
#> <dbl> <dbl> <dbl> <dbl>
#> 1 -0.400 -0.845 22.4 0.407

nlme::gls(
y ~ x,
weights = nlme::varIdent(form = ~ 1 | x),
method = "REML"
) |>
emmeans::emmeans(~ x, mode = "satterthwaite") |>
emmeans::contrast("revpairwise") |>
tibble::as_tibble() |>
dplyr::select(
estimate,
statistic = t.ratio,
df, p.value
)
#> # A tibble: 1 × 4
#> estimate statistic df p.value
#> <dbl> <dbl> <dbl> <dbl>
#> 1 0.400 0.845 22.4 0.407
  • 👍 2
More from @tabulated_stats
  1. Sep 1, 2026video post
  2. Sep 1, 2026Признаки агрессивной маркетинговой кампании Stan 😄
  3. Sep 1, 2026Alex Andorra выпустил интервью с основными авторами Bayesian Workflow
  4. Aug 29, 2026Друзья, у меня новость, прошу вас максимальный репост! Наш многолетний труд по разбору уко…
  5. Aug 27, 2026🗓 1-4 сентября 2026 📍Встречаемся в центре Москвы: Цифровое деловое пространство, Покровк…
  6. Aug 25, 2026Bayesian Workflow free pdf! https://statmodeling.stat.columbia.edu/2026/08/25/bayesian-wor…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →