説明のためのモデリングの背景

tidyverse で学ぶモデリング

Albert Y. Kim

Assistant Professor of Statistical and Data Sciences

コース概要

  1. モデリングの概要:理論と用語
  2. 回帰:
    • 単回帰
    • 重回帰
  3. モデルの評価
tidyverse で学ぶモデリング

モデリングの一般的な定式化

$$

$$y = f(\vec{x}) + \epsilon$$

各記号の意味:

  • $y$:目的変数
  • $\vec{x}$:説明変数/予測変数
  • $f()$:$y$ と $\vec{x}$ の関係を表す関数(=シグナル
  • $\epsilon$:非系統的誤差成分(=ノイズ
tidyverse で学ぶモデリング

2つのモデリングシナリオ

モデリングの目的:

  • 説明:$\vec{x}$ は説明変数
  • 予測:$\vec{x}$ は予測変数
tidyverse で学ぶモデリング

説明のためのモデリングの例

テキサス大学オースティン校による授業評価スコアの研究(openintro.org にて公開)。

問い:教員の属性から授業評価スコアの差異を説明できるか?

変数

  • $y$:学生評価による平均授業 score
  • $\vec{x}$:rankgenderagebty_avg などの属性
tidyverse で学ぶモデリング

説明のためのモデリングの例

ModernDive.commoderndive パッケージより:

library(dplyr)
library(moderndive)
glimpse(evals)
Observations: 463
Variables: 13
$ ID           <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
$ score        <dbl> 4.7, 4.1, 3.9, 4.8, 4.6, 4.3...
$ age          <int> 36, 36, 36, 36, 59, 59, 59, 51...
$ bty_avg      <dbl> 5.000, 5.000, 5.000, 5.000...
$ gender       <fct> female, female, female, female...
...
tidyverse で学ぶモデリング

探索的データ分析

探索的データ分析(EDA)の3つの基本ステップ:

  1. データの確認
  2. 可視化の作成
  3. 要約統計量の計算
tidyverse で学ぶモデリング

探索的データ分析

library(ggplot2)
ggplot(evals, aes(x = score)) +
  geom_histogram(binwidth = 0.25) + 
  labs(x = "teaching score", y = "count")
tidyverse で学ぶモデリング

探索的データ分析

tidyverse で学ぶモデリング

探索的データ分析

# Compute mean, median, and standard deviation
evals %>%
  summarize(mean_score = mean(score), 
            median_score = median(score),
            sd_score = sd(score))
# A tibble: 1 x 3
  mean_score median_score sd_score
       <dbl>        <dbl>    <dbl>
1       4.17          4.3    0.544
tidyverse で学ぶモデリング

練習しましょう!

tidyverse で学ぶモデリング

Preparing Video For Download...