インターネットを活用した経済分析 - フリーソフト Rを使おう

Similar documents
(lm) lm AIC 2 / 1

DAA09

R John Fox R R R Console library(rcmdr) Rcmdr R GUI Windows R R SDI *1 R Console R 1 2 Windows XP Windows * 2 R R Console R ˆ R

Use R

untitled

1 15 R Part : website:

講義のーと : データ解析のための統計モデリング. 第3回

201711grade2.pdf

R Console >R ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R R Rcmdr Rcmdr Fox, 2007 Fox and Carvalho, 2012 R R 2

> usdata01 と打ち込んでエンター キーを押すと V1 V2 V : : : : のように表示され 読み込まれていることがわかる ここで V1, V2, V3 は R が列のデータに自 動的につけた変数名である ( variable

BMIdata.txt DT DT <- read.table("bmidata.txt") DT head(dt) names(dt) str(dt)

k2 ( :35 ) ( k2) (GLM) web web 1 :

J1順位と得点者数の関係分析

最小2乗法

第11回:線形回帰モデルのOLS推定

28

1 2 Windows 7 *3 Windows * 4 R R Console R R Console ˆ R GUI R R R *5 R 2 R R R 6.1 ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R Rconsole R --sdi R M

k3 ( :07 ) 2 (A) k = 1 (B) k = 7 y x x 1 (k2)?? x y (A) GLM (k

Rによる計量分析:データ解析と可視化 - 第2回 セットアップ

一般化線形 (混合) モデル (2) - ロジスティック回帰と GLMM

研修コーナー

パーキンソン病治療ガイドライン2002

untitled

²¾ÁÛ¾õ¶·É¾²ÁË¡¤Î¤¿¤á¤Î¥Ñ¥Ã¥±¡¼¥¸DCchoice ¡Ê»ÃÄêÈÇ¡Ë

<4D F736F F F696E74202D BD95CF97CA89F090CD F6489F18B4195AA90CD816A>

waseda2010a-jukaiki1-main.dvi

回帰分析 単回帰

1 R Windows R 1.1 R The R project web R web Download [CRAN] CRAN Mirrors Japan Download and Install R [Windows 9

2 / 39

1 kawaguchi p.1/81

こんにちは由美子です

と入力する すると最初の 25 行が表示される 1 行目は変数の名前であり 2 列目は企業番号 (1,,10),3 列目は西暦 (1935,,1954) を表している ( 他のパネルデータを分析する際もデ ータをこのように並べておかなくてはならない つまりまず i=1 を固定し i=1 の t に関

q( ) 2: R 2 R R R R C:nProgram FilesnRnrw1030) [File] [Change Dir] c:ndatadir OK 2

kubostat2017c p (c) Poisson regression, a generalized linear model (GLM) : :

R Commanderを用いたデータ解析

lec03

.3 ˆβ1 = S, S ˆβ0 = ȳ ˆβ1 S = (β0 + β1i i) β0 β1 S = (i β0 β1i) = 0 β0 S = (i β0 β1i)i = 0 β1 β0, β1 ȳ β0 β1 = 0, (i ȳ β1(i ))i = 0 {(i ȳ)(i ) β1(i ))

第90回日本感染症学会学術講演会抄録(I)

Ł\”ƒ-2005

R による共和分分析 1. 共和分分析を行う 1.1 パッケージ urca インスツールする 共和分分析をするために R のパッケージ urca をインスツールする パッケージとは通常の R には含まれていない 追加的な R のコマンドの集まりのようなものである R には追加的に 600 以上のパッ

卒業論文


講義のーと : データ解析のための統計モデリング. 第5回

高齢化とマクロ投資比率―国際パネルデータを用いた分析―

3/4/8:9 { } { } β β β α β α β β

カテゴリ変数と独立性の検定

151021slide.dvi

Rプログラミング

2016.

第121回関東連合産科婦人科学会総会・学術集会 プログラム・抄録

y i OLS [0, 1] OLS x i = (1, x 1,i,, x k,i ) β = (β 0, β 1,, β k ) G ( x i β) 1 G i 1 π i π i P {y i = 1 x i } = G (

オーストラリア研究紀要 36号(P)☆/3.橋本

第13回:交差項を含む回帰・弾力性の推定

The Value Of Interships - Adecco Asia White Paper 2015_no1

R R-console R R Rscript R-console GUI 1


( 28 ) ( ) ( ) 0 This note is c 2016, 2017 by Setsuo Taniguchi. It may be used for personal or classroom purposes, but not for commercial purp

σ t σ t σt nikkei HP nikkei4csv H R nikkei4<-readcsv("h:=y=ynikkei4csv",header=t) (1) nikkei header=t nikkei4csv 4 4 nikkei nikkei4<-dataframe(n

本文/目次(裏白)

1.2 R R Windows, Macintosh, Linux(Unix) Windows Mac R Linux redhat, debian, vinelinux ( ) RjpWiki ( RjpWiki Wiki

% 10%, 35%( 1029 ) p (a) 1 p 95% (b) 1 Std. Err. (c) p 40% 5% (d) p 1: STATA (1). prtesti One-sample test of pr

GDP

4 OLS 4 OLS 4.1 nurseries dual c dual i = c + βnurseries i + ε i (1) 1. OLS Workfile Quick - Estimate Equation OK Equation specification dual c nurser

‚åŁÎ“·„´Šš‡ðŠp‡¢‡½‹âfi`fiI…A…‰…S…−…Y…•‡ÌMarkovŸA“½fiI›ð’Í

plot type type= n text plot type= n text(x,y) iris 5 iris iris.label >iris.label<-rep(c(,, ),rep(50,3)) 2 13 >plot(iris[,1],iris

情報管理学科で学ぶ

スライド 1

% 15.8% 14.8% 15.0% 16.0% 16.5% 0.5% 16.1% 15.2% 16.9% 15.7% 17.1% 18.6% 0.4% 21.4% 15.8% 14.8

統計研修R分散分析(追加).indd


(2004 ) 2 (A) (B) (C) 3 (1987) (1988) Shimono and Tachibanaki(1985) (2008) , % 2 (1999) (2005) 3 (2005) (2006) (2008)

Stata11 whitepapers mwp-037 regress - regress regress. regress mpg weight foreign Source SS df MS Number of obs = 74 F(

Rによる計量分析:データ解析と可視化 - 第3回 Rの基礎とデータ操作・管理

DAA01

LA-VAR Toda- Yamamoto(1995) VAR (Lag Augmented vector autoregressive model LA-VAR ) 2 2 Nordhaus(1975) 3 1 (D2)

講義のーと : データ解析のための統計モデリング. 第2回

1 Stata SEM LightStone 4 SEM 4.. Alan C. Acock, Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press 3.

kubostat2017e p.1 I 2017 (e) GLM logistic regression : : :02 1 N y count data or

kubostat2015e p.2 how to specify Poisson regression model, a GLM GLM how to specify model, a GLM GLM logistic probability distribution Poisson distrib

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

物価変動の決定要因について ― 需給ギャップと物価変動の関係の国際比較を中心に―

Excess Capacity and Effectiveness of Policy Interventions: Evidence from the Cement Industry SMU

<4D F736F F F696E74202D2088E D8C768A7789C482CC8A778D5A F939D8C76835C FC96E52E >

「スウェーデン企業におけるワーク・ライフ・バランス調査 」報告書

1. 2 Blank and Winnick (1953) 1 Smith (1974) Shilling et al. (1987) Shilling et al. (1987) Frew and Jud (1988) James Shilling Voith (1992) (Shilling e

tnbp59-21_Web:P2/ky132379509610002944

.1 z = e x +xy y z y 1 1 x 0 1 z x y α β γ z = αx + βy + γ (.1) ax + by + cz = d (.1') a, b, c, d x-y-z (a, b, c). x-y-z 3 (0,

1 Stata SEM LightStone 3 2 SEM. 2., 2,. Alan C. Acock, Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press.

日本内科学会雑誌第97巻第7号


Microsoft PowerPoint - Econometrics

R R 16 ( 3 )


遺産相続、学歴及び退職金の決定要因に関する実証分析 『家族関係、就労、退職金及び教育・資産の世代間移転に関する世帯アンケート調査』

こんにちは由美子です

A

計量経済分析 2011 年度夏学期期末試験 担当 : 別所俊一郎 以下のすべてに答えなさい. 回答は日本語か英語でおこなうこと. 1. 次のそれぞれの記述が正しいかどうか判定し, 誤りである場合には理由, あるいはより適切な 記述はどのようなものかを述べなさい. (1) You have to wo

.. est table TwoSLS1 TwoSLS2 GMM het,b(%9.5f) se Variable TwoSLS1 TwoSLS2 GMM_het hi_empunion totchr

日本内科学会雑誌第98巻第4号

untitled

Transcription:

R 1 1 1 2017 2 15 2017 2 15 1/64

2 R 3 R R RESAS 2017 2 15 2/64

2 R 3 R R RESAS 2017 2 15 3/64

2-4 ( ) ( (80%) (20%) 2017 2 15 4/64

PC LAN R 2017 2 15 5/64

R R 2017 2 15 6/64

3-4 R 15 + 2017 2 15 7/64

R STATA Eviews MATLAB STATA R 2017 2 15 8/64

R 2017 2 15 9/64

R R Windows Mac Linux R Comprehensive R Archive Network (CRAN: ) http://cran.ism.ac.jp/ 2017 2 15 10/64

2017 2 15 11/64

2017 2 15 12/64

R R A B Word 2017 2 15 13/64

R > ( ) + esc 2017 2 15 14/64

(1): > x <- 1.5+2.5 # x > x [1] 4 > 2.5* x [1] 10 2017 2 15 15/64

(2): > y <- c(1,2,3) # y y = [ 1 2 3 ] > y * y [1] 1 4 9 2017 2 15 16/64

(2): y y = [ 1 2 3 ] 1 2 = 1 1 + 2 2 + 3 3 = 14 3 > y %*% y # % [1] 14 > z <- c(1,2,3,4,5,6) > z.mat <- matrix(z,nrow=2,ncol=3) > z.mat [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 2017 2 15 17/64

> z.mat[1,] [1] 1 3 5 > z.mat[,2] [1] 3 4 2017 2 15 18/64

(3): > f <- expression(x^2) > D(f,"x") 2*x > h <- expression(x^2+3*x*y) > D(h,"x") 2*x+3*y 2017 2 15 19/64

> testfunction<- function(x^2) > x<-seq(-5,10,0.1) > plot(x, testfunction(x),type="l") ggplot2 1 : y = x 2 2017 2 15 20/64

R R CRAN 8,000 2017 2 15 21/64

2 : 2017 2 15 22/64

Nippon (https://prs.ism.ac.jp/userjp/) 2013 ( ) 2017 2 15 23/64

Nippon (2013) > setwd("/users/xxxx/r/gis/nipponpackage") # > library(nippon) > library(rcolorbrewer) > library(maptools) > library(classint) # > data<-read.table("nipponpackagetest.csv",sep=",",header=true) > op <- par(bg = "skyblue") # # : > p <- JapanPrefecturesMap(col = "ivory") > colleges <- data$colleges # # ( ) > cols <- rev(brewer.pal(5, "RdYlBu")) # n > c1 <- classintervals(colleges, n = 5, style = "fisher") > colcode1 <- findcolours(c1, cols, cutlabels = FALSE) # # 1 ( > legtext1 <- paste0(names(attr(colcode1,"table")), " (", attr(colcode1, "table"),")") > p <- JapanPrefecturesMap(col = colcode1) # ( # ( > legend("bottomright", legend = legtext1,fill = cols, title = "Colleges",bg = "white") 2017 2 15 24/64

2017 2 15 25/64

(1) Nippon http://www.stat.go.jp/data/k-sugata/naiyou.htm#mokuji2 2017 2 15 26/64

2 R 2 R 3 R R RESAS 2017 2 15 27/64

2 R (π) (P Y ) (C(Y )) max Y π = P Y C(Y ) (1) Y 2017 2 15 28/64

2 R Hoover(2012, P331) 1 2008 Y = 9.63L 0.67 K 0.33 (2) Y L K Y = AL a K 1 a (A ) 1 Hoover, KD(2012) Applied intermediate macroeconomics, Cambridge University Press. 2017 2 15 29/64

2 R > plotfun(a*(l^0.7)*(k^0.3)~l&k, A=5,xlim=range(0,21), ylim=range(0,100), filled=false, surface=true ) mosaic A * (L^0.7) * (K^0.3) K L 2017 2 15 30/64

2 R > library(mosaic) > plotfun(a*(l^0.7)*(k^0.3)~l,k=20,a=5,xlim=range(-1,21), ylim=range(-5,105)) 80 A * (L^0.7) * (K^0.3) 60 40 20 0 0 5 10 15 20 L 2017 2 15 31/64

2 R K Y > plotfun(a*(l^0.7)*(k^0.3)~l,k=20,a=5,xlim=range(-1,21), ylim=range(-5,151)) > plotfun(a*(l^0.7)*(k^0.3)~l, K=40,A=5,xlim=range(-1,21), ylim=range(-5,151), lty=2,add=true ) A * (L^0.7) * (K^0.3) 100 50 0 0 5 10 15 20 L 2017 2 15 32/64

2 R A Y > plotfun(a*(l^0.7)*(k^0.3)~l,k=20,a=5,xlim=range(-1,21), ylim=range(-5,151)) > plotfun(a*(l^0.7)*(k^0.3)~l,k=20, A=10,xlim=range(-1,21), ylim=range(-5,151), lty=2,add=true ) A * (L^0.7) * (K^0.3) 100 50 0 0 5 10 15 20 L 2017 2 15 33/64

20 40 80 120 140 160 ( ) 2 R > plotfun(a*(l^0.7)*(k^0.3)~l&k,a=5,xlim=range(0,21), ylim=range(0,100), filled=false) 80 60 100 K 40 60 20 5 10 15 20 L 2017 2 15 34/64

3 R 2 R 3 R R RESAS 2017 2 15 35/64

3 R (U) U x (x, y) p x = U y(x, y) p y (3) U x (x, y) U(x,y) x, P i i 2017 2 15 36/64

3 R : (1) p x = 1, p y = 2 U = x + 2 x y + y (4) U x = 1 + x 1 2 y, U y = 1 + x y 1 2 (5) (3) y 1 2 x 1 2 = 1 2 (6) 2017 2 15 37/64

3 R : (2) : p x x + p y y = m ( m ) (3) x = mp y p x (p x + p y ), and y = mp x p y (p x + p y ) (7) m = 6 x = 4 y = 1 2017 2 15 38/64

3 R R max U = x + 2 x y + y (8) s.t. x + 2y = 6 (9) x = 4 y = 1 2017 2 15 39/64

3 R R 1 x< seq(0,5,1) # 0 5 1 2 y< seq(0,5,1) # 0 5 1 3 g< function(x,y) x+2 sqrt(x y)+y # 4 z< outer(x,y,g) # x y g 5 contour(x,y,z) # x-y 6 par(new=t) # 7 8 contour(x,y,z,level=9) # x-y z=9 9 par(new=t) 10 11 gg< function(x,y) x+2 y # 12 z< outer(x,y,gg) # x y gg 13 contour(x,y,z,level=6, col="red",lwd=3,xlab="x", ylab="y") 14 15 abline(h=1,lty=2) # x=1 ( ) 16 abline(v=4,lty=2) # y=4 ( ) 2017 2 15 40/64

3 R 2017 2 15 41/64

R 2 R 3 R R RESAS 2017 2 15 42/64

R 2017 2 15 43/64

R (2b) 2017 2 15 44/64

R (2c) 2017 2 15 45/64

R 2 i, j R D GDP R ij = GDP igdp j D ij (10) ln R ij = β 0 + β 1 ln GDP i + β 2 ln GDP j β 3 ln D ij + ϵ (11) 2017 2 15 46/64

R UN Comtrade CEPII (BACI) GDP World Development Indicators R WDI CEPII The CEPII Gravity Dataset 2017 2 15 47/64

R I Y = α + βx (12) 2 2017 2 15 48/64

R II (X i, Y i ) µ i µ i = Y i α βx i (13) 2 2017 2 15 49/64

R (1) J α β α β J = n ˆµ 2 i = (Y i α βx i ) 2 (14) J α = i=1 n [ 2(Y i α βx i )] = 0 (15) i=1 J β = n [ 2X i (Y i α βx i )] = 0 (16) i=1 2017 2 15 50/64

R (2) ˆβ = n i=1 (X i X)(Y i Y ) n i=1 (X i X) 2 (17) ˆα = Y ˆβX (18) ˆα ˆβ 2017 2 15 51/64

R : GDP WDI GDP 1 library(wdi) # WDI 2 3 WDIsearch(string="GDP") # GDP 4 5 dat < WDI(indicator= NY.GDP.MKTP.CD, country=c( JP, KR, CN ), start=1980, end=2012) 6 # 1980-2012 GDP 7 8 library(ggplot2) # 9 10 ggplot(dat, aes(year, NY.GDP.MKTP.CD/1000000000, color= country)) + geom line() + 11 xlab( Year ) + ylab( GDP (current billion US$) ) 2017 2 15 52/64

R GDP 7500 GDP (current billion US$) 5000 country China Japan Korea, Rep. 2500 0 1980 1990 2000 2010 Year 2017 2 15 53/64

R R : (1) 1 trade.lm< lm(log(trade) log(gdp)+log(gdp.china)+log( distance), data=dataset) 2 # OLS 3 4 summary(trade.lm) # 2017 2 15 54/64

R R : (2) 1 2 Coefficients: 3 Estimate Std. Er. t value Pr(> t ) 4 (Intercept) 0.06266 2.09973 0.030 0.97635 5 log(gdp) 1.14907 0.16279 7.059 2.05e 08 6 log(gdp.china) 0.72680 0.05279 13.768 2.39e 16 7 log(distance) 1.47430 0.41052 3.591 0.00093 8 9 Signif. codes: 0 0.001 0.01 0.05. 0.1 1 10 11 Residual standard error: 0.1927 on 38 degrees of freedom 12 Multiple R squared: 0.9716, Adjusted R squared: 0.9694 13 F statistic: 433.4 on 3 and 38 DF, p value: < 2.2e 16 2017 2 15 55/64

R (1) (null hypothesis) (H 0 ) (H 1 ) 2017 2 15 56/64

R (2) H 0 H 0 H 1 H 0 2017 2 15 57/64

R 3a OLS 2017 2 15 58/64

R R : (1) (colgpa) (hsgpa) (ACT) 1 library(foreign) # R 2 3 html< "http://fmwww.bc.edu/ec-p/data/wooldridge/gpa1.dta" # 4 5 gpa1< read.dta(html) # 6 7 GPAres< lm(colgpa hsgpa+act, data=gpa1) # 8 9 summary(gpares) # 2017 2 15 59/64

R R : (2) 1 Call:lm(formula = colgpa hsgpa + ACT, data = gpa1) 2 3 Residuals: 4 Min 1Q Median 3Q Max 5 0.85442 0.24666 0.02614 0.28127 0.85357 6 7 Coefficients: 8 Estimate Std. Error t value Pr(> t ) 9 (Intercept) 1.286328 0.340822 3.774 0.000238 10 hsgpa 0.453456 0.095813 4.733 5.42e 06 11 ACT 0.009426 0.010777 0.875 0.383297 12 13 Signif. codes: 0 0.001 0.01 0.05. 0.1 14 15 Residual standard error: 0.3403 on 138 degrees of freedom 16 Multiple R squared: 0.1764, Adjusted R squared: 0.1645 2017 2 15 60/64

R 3b OLS 2017 2 15 61/64

RESAS 2 R 3 R R RESAS 2017 2 15 62/64

RESAS RESAS RESAS RESAS RESAS 2017 2 15 63/64

RESAS Dayal, Vikram (2015) An Introduction to R for Quantitative Economics: Graphing, Simulating and Computing, Springer. Heisss, Florian (2016) Using R for Introductory Econometrics, www.urfie.net. ( ) (2008). (2000). (2012) RIETI (http://www.rieti.go.jp/users/tanaka-ayumu). (2016) R - -,. (1995). 2017 2 15 64/64