• 検索結果がありません。

ミクロ経済 2016micro6

N/A
N/A
Protected

Academic year: 2018

シェア "ミクロ経済 2016micro6"

Copied!
20
0
0

読み込み中.... (全文を見る)

全文

(1)

1

経済 第6回 析演習

担当講師 長塚昌生

氏 学籍番号 担当課題

課題

析結果 ン 文章 整形 長塚 出

作成 セッ

R

日 作業手順 白菜 セッ 演習 各自 菜 指定

析環境 作成

菜 生産地 ン ン 消 地 ン ン 検索

セ セッ 作成

セ 作成

R 実行

作成

0 ータ分析環境の作成

ソコン 立 く い ッ 2016micro

前 作業用 作成 く い

Google等検索 ン ン 立 日 作業 多い Youtube等 遊

い く い 検索画面 長塚昌生 or masaonagatsuka 検索 担当講

HP

(2)

2

HP 講義資料 経済

経済 講義資料ペ い 20160525○○

作業 ン く い

.野菜の生産地 ンキン 、消費地 ンキン の検索

検索 ン ン 地域 入 物 検索 菜等 生産消 地 ン ン

ペ ッ 来 農水省 HP 1次 取得 望 い

時間 都合 今回 使用

生産地 ン ン 白菜 H26

順位 降順 表示

コ ペ 各自 他 菜 行う 論文 ン

表 手 打 込 埋 く い

(3)

3

.エ セ での ータセッ の作成

次 セ セッ 作成

作業 2016microhakusai 新 作成

く い 各自 演習 nasudaikon 作成

検索 ン ン 検索 内 検索欄 青果物

検索

11 H26 果物 ほう 24

青果物卸売 場調査報告 産地別 言う ペ あ ペ 移

く い 1 121 個 先 ほ 作 ッ

2016micro > hakusai

様 成25 菜 主要消 地域別 産地別 卸売数 及 卸売価格1-11-8

いうペ 成25 1 12 く い hakusai

様 成26 菜 主要消 地域別 産地別 卸売数 及 卸売価格1-11-8

うペ 成25 1 12 く い hakusai

36 2016micro

20160525hakusai_template.xls いう

セ ン year month 埋 い

HokkaiQ

(4)

4

く い 成24 1 2012 セ 開 計 い

行 [ctrl] + [shift] + [] 1行選択 2012 1

2012 1 2014 12 一度

保存 hakusai_data hakusai 保存

作成 20160625hakusai 存在 い人

失敗 人 わ い人 開い い く い

(5)

5

.エ セ で フの作成

hakusai_data 開い

概観 析 い

各地域別 生産 卸売価格 海道全体 幌 東

全体 台 関東全体 京浜 九州全体 九州 全体 大都 圏 入 子式

い 点 注意 全国 総生産 (TotalQ) 全国 均価格(AvergeP)

作成

セ 最後2列 新 TotalQ AverageP いう変数 作

TotalQ 1 京浜 九州 除い 地域 生産 Q 合わ

計算 行い (=SUM(C2,G2,K2,O2,Q2,S2,U2,W2,Y2))

AverageP 1 京浜 九州 除い 地域 卸売価格

計算 行い (=AVERAGE(D2,H2,L2,P2,R2,T2,V2,X2,Z2))

1 生産 均価格 出来 3 総生産 均価

格 求 く い

計算 hakusai2014_2016 保存

(6)

6

均価格 推移

新 い セ hakusai2014_2016 開い hakusai2014_2016

[Cntl] + [A] 全範 選択 [Cntl] + [C]

新 い セ 右 ッ 値(V)

新 い セ hakusai_graph 保存

今回 系列 少 い 価格 度別 取 新 い列 作成

作成1

hakusai_graph year month AverageP

[Sheet2] 12 価格 13 価格 14 価格

度 取

12 価格 13 価格 14 価格 選択 挿入

白菜 別価格推移

生産 卸売価格 推移

hakusai_graph year month TotalQ AverageP

[Sheet3]

1 系列 複数 作成 手順 度別 検索

出 く http://www4.synapse.ne.jp/yone/excel2010/excel2010_graph_ore2.html

(7)

7

year month TotalQ AverageP month TotalQ

間 列 挿入 yearmonth 作成 2012/1 打 込 自動的 Jan-12

変換 ッ 14 作成

yearmonth TotalQ AverageP 全範 選択 挿入

い 価格 数 棒 く

棒 右 ッ 系列 種類 変更

(8)

8

AverageP [ 種類] 集合縦棒 [2]

白菜生産 均価格推移 保存

操作変数 取得

推計 操作変数 気象 必要 検索 ン ン 気象庁 検索

気象庁HP 各種 資料 過去 気象 検索

都道府県検索 茨城 妻 最大生産地 ほ い 各自 菜

場所 異 注意 2012 値 表示 セ コ

ペ 続 2013 2014 合計降水 均気温

日照時間 外 削除

20160525weathertemplate 保存 ibaraki_weather

hakusa_graph あわ 20160525whethertemplate

気象

前 保存 種類CSV 選択 hakusai2012_2014

保存

hakusai2012_2014 R 使う

(9)

9

R ス プ の実行

R

R 統計ソ いう 無料 いう 自由 意味

ソ コ 公開 使用者 新 ッ 自由 作成

世界中 人 使う 出来 爆発的 使用者 増加中

R

R 言語 script画面 コンソ 画面 出力 使用

R セッ

R 開い File Change directory ( 変更)

ッ 置い 2016micro > hakusai 指定 OK

ッ 行 方 コン 自 ○○ ッ

各自 析 行う際 nasu等 変更

20160525R_hakusai_scriptfile いう 開く

R New script 開い

20160525R_hakusai_scriptfile 内容 [Ctrl][A] 全選択

[Ctrl][C] 画面 [Ctrl][V]

(10)

10

前 保存 20160625hakusai

hakusai hakusai2012_2014.csv 確認

1 実行 いく

(11)

11

R

# 記号 いう性質 利用

解 行 い

##白菜 需要関数 推定##

#1.

#2. 最小 乗法推定

#3.操作変数 用い 時方程式 2段階最小 乗法推定

#4.需要 価格弾力性 推定

##1. ##

hakusai<-read.csv("hakusai2012_2014.csv",header=TRUE)

A<-B B 言う対象物 A 格納

read.csv csv

"hakusai2012_2014.csv" 変数 "" 行う

header=TRUE 1行目 変数 場合TRUE 変数 い場合

FALSE

# #

head(hakusai,3)

# 3行表示 #

出力結果 一部略

> head(hakusai,3)

year month hokkaiQ hokkaiP sapporoQ sapporoP tohokuQ tohokuP 1 2012 1 1674 68 1515 67 2465 62 2 2012 2 1660 83 1534 82 2598 79 3 2012 3 1215 136 1136 136 2029 122

3行目 出力 いう head(data, 3)

12行出 い 込 確認 OK

(12)

12 attach(hakusai)

# hakusai 直接 変数 #

ッ 関数 使わ い場合 推計式 指定 変数 指定 い

う長く 間違えや い attach否定派 人 い

例 ン 最小 乗法

attach model1<-lm(TotalQ~AverageP)

attach model1<-lm(hakusai$TotalQ~hakusai$AverageP)

変数 指定 あ 必要 あ

##2. 最小 乗法推定##

model1<-lm(TotalQ~AverageP)#lm:linear model(regression), Y~X:X Y 回帰 # summary(model1)#結果 表示(推定 )#

出力結果 Coefficients:

Estimate Std. Error t value Pr(>|t|) (Intercept) 70165.8 10267.6 6.834 7.27e-08 *** AverageP -238.4 136.7 -1.743 0.0903 . ---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 18560 on 34 degrees of freedom

Multiple R-squared: 0.08206, Adjusted R-squared: 0.05506 F-statistic: 3.04 on 1 and 34 DF, p-value: 0.0903

方 大 YX+ε いう回帰 析 X 1変 均的 Y

変 示 非 明変数Q 出 い

Coefficients 係数 Y X+ε いう

Estimate 係数 推定値 Intercept AverageP 相当

Std. Error 標準誤差 係数

t value t 係数 一般 2 or 2 い値

Pr(>|t|) p t 表現 係数 0 近いほ

推定結果 生産 Q 70165.8-238.4P いう 価格P 1

取引 Q 238.4 価格P い 意 推定値 い

信頼 い 結果 いう

(13)

13

plot(model1)#( ) 残差 #

plot関数 く関数 YX 指定 普通 X Y

得 い い 散 当 具合

示 正規QQ ッ 出力

##3.操作変数 用い 時方程式 2段階最小 乗法推定##

#3.1 時方程式 推定#

##systemfit ##

選択 Japan Tokyo(hyogo ) package “systemfit” library(systemfit)# "Systemfit" #

# 8 推定 実行#

supA<-TotalQ~AverageP+factor(month)+IbaAveTemp##供給推計式 生産 Q 価格P

+ 次 +気温##

demA<-TotalQ~AverageP##需要推計式 生産 価格P##

systemA<-list(supply=supA,demand=demA)##需要 供給 定義## inst<-~IbaAveTemp+factor(month)##供給推計式 操作変数 定義## sysolsA<-systemfit(systemA,data=hakusai)##1段階 推計##

summary(sysolsA)##1段階 推計式 結果 表示##

sys2slsA<-systemfit(systemA,"2SLS",inst=inst,data=hakusai)##2段階最小 乗法 実行

##

summary(sys2slsA)##2段階最小 乗法 結果 表示##

(14)

14

出力結果 通常 1段階OLS

> supA<-TotalQ~AverageP+factor(month)+IbaAveTemp

> demA<-TotalQ~AverageP

> systemA<-list(supply=supA,demand=demA)

> inst<-~IbaAveTemp+factor(month)

> sysolsA<-systemfit(systemA,data=hakusai)

> summary(sysolsA)

systemfit results method: OLS

N DF SSR detRCov OLS-R2 McElroy-R2 system 72 56 11784221653 1.13434e+15 0.538174 0.985458

N DF SSR MSE RMSE R2 Adj R2 supply 36 22 72903876 3313813 1820.39 0.994286 0.990909 demand 36 34 11711317777 344450523 18559.38 0.082062 0.055064

The covariance matrix of the residuals supply demand

supply 3313813 2665630 demand 2665630 344450523

The correlations of the residuals supply demand supply 1.0000000 0.0788992 demand 0.0788992 1.0000000

OLS estimates for 'supply' (equation 1)

Model Formula: TotalQ ~ AverageP + factor(month) + IbaAveTemp

Estimate Std. Error t value Pr(>|t|) (Intercept) 68584.17057 2511.83542 27.30440 < 2.22e-16 *** AverageP -2.83566 20.27107 -0.13989 0.89002201 factor(month)2 -651.76464 1582.59598 -0.41183 0.68444704

(15)

15

factor(month)3 -16838.71774 3537.30235 -4.76033 9.4278e-05 *** factor(month)4 -21388.99645 5578.10723 -3.83445 0.00090236 *** factor(month)5 -20409.65524 8306.07342 -2.45720 0.02235611 * factor(month)6 -24801.52955 9931.80031 -2.49718 0.02049277 * factor(month)7 -21021.16444 11972.92331 -1.75573 0.09305067 . factor(month)8 -20651.98225 13030.17785 -1.58493 0.12725152 factor(month)9 -6738.13840 11191.45106 -0.60208 0.55327673 factor(month)10 23120.20560 7850.75160 2.94497 0.00748922 ** factor(month)11 12433.52042 4283.68926 2.90253 0.00825738 ** factor(month)12 14869.45922 1778.22785 8.36195 2.8099e-08 *** IbaAveTemp -589.96331 524.22587 -1.12540 0.27254816 ---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1820.388026 on 22 degrees of freedom Number of observations: 36 Degrees of Freedom: 22

SSR: 72903876.413505 MSE: 3313812.56425 Root MSE: 1820.388026 Multiple R-Squared: 0.994286 Adjusted R-Squared: 0.990909

OLS estimates for 'demand' (equation 2) Model Formula: TotalQ ~ AverageP

Estimate Std. Error t value Pr(>|t|) (Intercept) 70165.813 10267.637 6.83369 7.2735e-08 *** AverageP -238.411 136.749 -1.74343 0.090297 . ---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 18559.378299 on 34 degrees of freedom Number of observations: 36 Degrees of Freedom: 34

SSR: 11711317776.5514 MSE: 344450522.839748 Root MSE: 18559.378299 Multiple R-Squared: 0.082062 Adjusted R-Squared: 0.055064

(16)

16

♯次 2段階OLS 実行

> sys2slsA<-systemfit(systemA,"2SLS",inst=inst,data=hakusai)

> summary(sys2slsA)

出力結果

systemfit results method: 2SLS

N DF SSR detRCov OLS-R2 McElroy-R2 system 72 56 12429210008 1.52301e+15 0.512897 0.980766

N DF SSR MSE RMSE R2 Adj R2 supply 36 22 97911452 4450521 2109.63 0.992326 0.987791 demand 36 34 12331298556 362685252 19044.30 0.033468 0.005040

The covariance matrix of the residuals supply demand

supply 4450521 9546237 demand 9546237 362685252

The correlations of the residuals supply demand supply 1.000000 0.237608 demand 0.237608 1.000000

2SLS estimates for 'supply' (equation 1)

Model Formula: TotalQ ~ AverageP + factor(month) + IbaAveTemp Instruments: ~IbaAveTemp + factor(month)

Estimate Std. Error t value Pr(>|t|) (Intercept) 7.41391e+04 1.13555e+10 1e-05 0.99999 AverageP -5.85220e+01 1.13836e+08 0e+00 1.00000 factor(month)2 3.25883e+02 1.99853e+09 0e+00 1.00000 factor(month)3 -1.14406e+04 1.10351e+10 0e+00 1.00000 factor(month)4 -1.33236e+04 1.64876e+10 0e+00 1.00000

(17)

17

factor(month)5 -8.48910e+03 2.43683e+10 0e+00 1.00000 factor(month)6 -1.00252e+04 3.02061e+10 0e+00 1.00000 factor(month)7 -3.05288e+03 3.67313e+10 0e+00 1.00000 factor(month)8 -2.09563e+02 4.17890e+10 0e+00 1.00000 factor(month)9 1.12099e+04 3.66898e+10 0e+00 1.00000 factor(month)10 3.44447e+04 2.31498e+10 0e+00 1.00000 factor(month)11 1.80996e+04 1.15828e+10 0e+00 1.00000 factor(month)12 1.59404e+04 2.18927e+09 1e-05 0.99999 IbaAveTemp -1.37227e+03 1.59921e+09 0e+00 1.00000

Residual standard error: 2109.62569 on 22 degrees of freedom Number of observations: 36 Degrees of Freedom: 22

SSR: 97911452.096453 MSE: 4450520.549839 Root MSE: 2109.62569 Multiple R-Squared: 0.992326 Adjusted R-Squared: 0.987791

2SLS estimates for 'demand' (equation 2) Model Formula: TotalQ ~ AverageP

Instruments: ~IbaAveTemp + factor(month)

Estimate Std. Error t value Pr(>|t|) (Intercept) 83300.992 13769.857 6.04952 7.4284e-07 *** AverageP -421.875 187.149 -2.25422 0.030738 * ---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 19044.29709 on 34 degrees of freedom Number of observations: 36 Degrees of Freedom: 34

SSR: 12331298555.873 MSE: 362685251.643325 Root MSE: 19044.29709 Multiple R-Squared: 0.033468 Adjusted R-Squared: 0.00504

(18)

18 解

出力 全部書 大 最後 2SLS 出力 第1段階 供給

ッ 与え 変数 入 回帰 実行 結果 入 需要 回帰

析 い 来 い い 解 い 最後

供給 ッ 入 需要関数 推定 係数 -238.4 -421.8

急 いう

#3.2. コン 変数 追加 推計 精度

#

#month*price dummy supB<-

TotalQ~AverageP+factor(month)+IbaAveTemp+factor(month)*AverageP##SupplyEquat ion##

demB<-TotalQ~AverageP##Demand Equation##

systemB<-list(supply=supB,demand=demB)##Define Supply and Demand as System## inst<-~IbaAveTemp+factor(month)+factor(month)*AverageP##Define Instrumental Variable for supply##

sysolsB<-systemfit(systemB,data=hakusai)##1st system estimation## summary(sysolsB)##Summary table for 1st estimation##

sys2slsB<-systemfit(systemB,"2SLS",inst=inst,data=hakusai)##System fit for 2SLS## summary(sys2slsB)##Summary table for 2SLS estimation##

#2month_lag_dummy supC<-

TotalQ~AverageP+factor(month)+IbaAveTemp+lag(month,2)##SupplyEquation## demC<-TotalQ~AverageP##Demand Equation##

systemC<-list(supply=supC,demand=demC)##Define Supply and Demand as System## inst<-~IbaAveTemp+factor(month)+lag(month,2)##Define Instrumental Variable for supply##

sysolsC<-systemfit(systemC,data=hakusai)##1st system estimation## summary(sysolsC)##Summary table for 1st estimation##

sys2slsC<-systemfit(systemC,"2SLS",inst=inst,data=hakusai)##System fit for 2SLS## summary(sys2slsC)##Summary table for 2SLS estimation##

(19)

19

#4.需要 価格弾力性 推計#

# 時方程式 推計式 対数log 推定 需要 価格弾力性値 #

supD<-log(TotalQ)~log(AverageP)+IbaAveTemp+factor(month) demD<-log(TotalQ)~log(AverageP)

systemD<-list(supply=supD,demand=demD) inst<-~IbaAveTemp+factor(month)

sysolsD<-systemfit(systemD,data=hakusai) summary(sysolsD)

sys2slsD<-systemfit(systemD,"2SLS",inst=inst,data=hakusai) summary(sys2slsD)

出力結果

途中 飛

2SLS estimates for 'demand' (equation 2) Model Formula: log(TotalQ) ~ log(AverageP) Instruments: ~IbaAveTemp + factor(month)

Estimate Std. Error t value Pr(>|t|) (Intercept) 13.828972 1.299951 10.6381 2.3377e-12 *** log(AverageP) -0.712626 0.307101 -2.3205 0.026448 * ---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.368823 on 34 degrees of freedom Number of observations: 36 Degrees of Freedom: 34 SSR: 4.625024 MSE: 0.13603 Root MSE: 0.368823

Multiple R-Squared: 0.005042 Adjusted R-Squared: -0.024221

対数 取 回帰 析 弾力性 推定 詳 く 計 経済学

聞く 教員 聞い く い log(AverageP) 推定値 -0.71 1

白菜 必需品 価格弾力性 小 い財 あ 10 水準 意

(20)

20

. ポー の作成

各自指定 菜 様 析 終え

3点 開い く い

(1) 20160626MSword

(2) 20160626MSword (3) 20160626推定結果表

(1) 各自 結果 結果

章 編集 く い 書い 前 保存 各自 nagatsuka_nasu

前 課題 入 保存 く い

(2) 注意書 (3) 最後 推定結

果 張 表 各自 推定結果 張 保存 い く

各自 作業 進 保存 く い

書 あ 添

1

2 作成 セッ

3 R 実行 形式 保存

件 中間

文 長塚先生

○○

出い

査収 ほ く 願いい

○○ 書い

[email protected] 5 31日午後24 00

参照

関連したドキュメント

Since there do exist PBQ filtrations, the comparison between the log-growth filtrations and the Frobenius slope filtrations for PBQ modules both at the generic point and at the

AHP involves three basic elements: (1) it describes a complex, multicriteria problem with objective or subjective elements as a hierarchy; (2) it estimates the relative weights

In the spirit of our semimartingale norm, we introduce a norm for the barriers of DRB- SDEs and provide a priori estimates for the solution of DRBSDEs based on our new barrier

Finally, in the Appendix, we prove the well-known fact that the category of ket coverings of a connected locally noetherian fs log scheme is a Galois category; this implies,

These healthy states are characterized by the absence of inflammatory markers, which in the context of the model described above, correspond to equilibrium states in which

(The Elliott-Halberstam conjecture does allow one to take B = 2 in (1.39), and therefore leads to small improve- ments in Huxley’s results, which for r ≥ 2 are weaker than the result

Log abelian varieties are defined as certain sheaves in the classical ´etale topol- ogy in [KKN08a], however the log flat topology is needed for studying some problems, for example

We prove tight- ness of the recentered maximum of the Gaussian fields and provide exponentially decaying bounds on the right and left tails.. Display (1.1) implies that the