[R]例2.2 風速と直流発電量(「線形回帰分析」(朝倉書店)pp.62-67)その1
p.63に掲載されている3つのモデルについて、それぞれlm関数を使って計算している。表2.1(p.62)の値をCSV形式で入力したtable2_1.csvをカレントディレクトリに置いておくこと。
> dtf <- read.csv("table2_1.csv", header = TRUE)
> xxi <- as.double(dtf$WV)
> yyi <- as.double(dtf$DC)
> # 式(2.28)
> r1 <- lm(yyi ~ 1 + xxi)
> print(summary(r1))
Call:
lm(formula = yyi ~ 1 + xxi)
Residuals:
Min 1Q Median 3Q Max
-0.59869 -0.14099 0.06059 0.17262 0.32184
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.13088 0.12599 1.039 0.31
xxi 0.24115 0.01905 12.659 7.55e-12 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2361 on 23 degrees of freedom
Multiple R-squared: 0.8745, Adjusted R-squared: 0.869
F-statistic: 160.3 on 1 and 23 DF, p-value: 7.546e-12
> # 式(2.29)
> r2 <- lm(yyi ~ 1 + log(xxi))
> print(summary(r2))
Call:
lm(formula = yyi ~ 1 + log(xxi))
Residuals:
Min 1Q Median 3Q Max
-0.31619 -0.07685 0.02395 0.11139 0.23029
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.83036 0.11083 -7.493 1.3e-07 ***
log(xxi) 1.41677 0.06234 22.728 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1376 on 23 degrees of freedom
Multiple R-squared: 0.9574, Adjusted R-squared: 0.9555
F-statistic: 516.6 on 1 and 23 DF, p-value: < 2.2e-16
> # 式(2.30)
> r3 <- lm(yyi ~ 1 + I(1 / xxi))
> print(summary(r3))
Call:
lm(formula = yyi ~ 1 + I(1/xxi))
Residuals:
Min 1Q Median 3Q Max
-0.20547 -0.04940 0.01100 0.08352 0.12204
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.9789 0.0449 66.34 <2e-16 ***
I(1/xxi) -6.9345 0.2064 -33.59 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.09417 on 23 degrees of freedom
Multiple R-squared: 0.98, Adjusted R-squared: 0.9792
F-statistic: 1128 on 1 and 23 DF, p-value: < 2.2e-16
« [R]貨幣賃金率変化率の回帰モデルの推定(「線形回帰分析」(朝倉書店)pp.119-120) | トップページ | [R]例2.2 風速と直流発電量(「線形回帰分析」(朝倉書店)pp.62-67)その2 »
「R(本の計算を再現)」カテゴリの記事
- [R]ガンマ関数の値の計算(「入門 統計解析 -医学・自然科学編」(東京図書)pp.120-121)(2025.01.24)
- [R]グループに対するダミー変数(性別)(「44の例題で学ぶ計量経済学」(オーム社)pp.231-232)(2023.11.28)
- [R]重回帰モデルにおける仮説検定(「44の例題で学ぶ計量経済学」(オーム社)pp.205-206)(2023.11.27)
- [R]重回帰モデルにおけるt検定(「44の例題で学ぶ計量経済学」(オーム社)pp.185-188)(2023.11.26)
- [R]平均勤続年数と所定内賃金(「線形回帰分析」(朝倉書店)pp.116-118)(2023.11.06)
« [R]貨幣賃金率変化率の回帰モデルの推定(「線形回帰分析」(朝倉書店)pp.119-120) | トップページ | [R]例2.2 風速と直流発電量(「線形回帰分析」(朝倉書店)pp.62-67)その2 »

コメント