2026-01-19
wooldridgeパッケージが未インストールの場合は実行install.packages("wooldridge")
wooldridgeパッケージの読み込みlibrary(wooldridge)
\[ crime = f(\text{wages}, \text{other\_income}, \text{freq\_arrest},\] \[ \text{freq\_convict}, \text{sentence}, \text{age}) \]
ここで、\(crime\):犯罪率、\(wages\):賃金、\(other\_income\):その他の収入、\(freq\_arrest\):逮捕頻度、\(freq\_convict\):有罪判決頻度、\(sentence\):刑罰の厳しさ、\(age\):年齢。
\[crime = \beta_0 + \beta_1 \text{wages} + \beta_2 \text{other\_income} + ... + u\]
ここで、 \(u\)は誤差項または撹乱項であり、観測されない要因を含む。
wage1 データセット## wage educ female
## 1 3.10 11 1
## 2 3.24 12 1
## 3 3.00 11 0
## 4 6.00 8 0
## 5 5.30 12 0
## 6 8.75 16 0
prminwge データセット (プエルトリコ)## year avgmin
## 1 1950 0.198
## 2 1951 0.209
## 3 1952 0.225
## 4 1953 0.311
## 5 1954 0.313
## 6 1955 0.369
hprice3 データセット(1)# 1978年のhpriceデータセットを抽出
hprice1978 <- subset(hprice3, year == 1978)
# hpriceデータセットの最初の数行を表示
head(hprice1978[, c("year", "price", "rooms")])## year price rooms
## 1 1978 60000 7
## 2 1978 40000 6
## 3 1978 34000 6
## 4 1978 63900 5
## 5 1978 44000 5
## 6 1978 46000 6
hprice3 データセット(2)# 1981年のhpriceデータセットを抽出
hprice1981 <- subset(hprice3, year == 1981)
# hpriceデータセットの最初の数行を表示
head(hprice1981[, c("year", "price", "rooms")])## year price rooms
## 180 1981 49000 6
## 181 1981 52000 5
## 182 1981 68000 6
## 183 1981 54000 6
## 184 1981 70000 6
## 185 1981 47000 6
crime3 データセット## district year crime
## 1 1 72 49.54
## 2 1 78 71.32
## 3 2 72 14.77
## 4 2 78 17.85
## 5 3 72 17.35
## 6 3 78 24.57