(lm) lm AIC 2 / 1

Similar documents
DAA09

untitled

1 15 R Part : website:

Use R

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

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

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

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

<4D F736F F F696E74202D BD95CF97CA89F090CD F6489F18B4195AA90CD816A>

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

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

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

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

201711grade2.pdf

untitled

1 kawaguchi p.1/81

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

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

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

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

最小2乗法

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

28

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

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

.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 ))

σ 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

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

回帰分析 単回帰

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

kubostat2018d p.2 :? bod size x and fertilization f change seed number? : a statistical model for this example? i response variable seed number : { i

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

yamadaiR(cEFA).pdf

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

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

2 / 39

<4D F736F F D20939D8C7689F090CD985F93C18EEA8D758B E646F63>

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

% 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

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

untitled

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

Microsoft Word - 計量研修テキスト_第5版).doc

lec03

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

mosaic Daniel Kaplan * 1 Nicholas J. Horton * 2 Randall Pruim * 3 Macalester College Amherst College Calvin College St. Paul, MN Amherst, MA Grand Rap

こんにちは由美子です

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

以下の内容について説明する 1. VAR モデル推定する 2. VAR モデルを用いて予測する 3. グレンジャーの因果性を検定する 4. インパルス応答関数を描く 1. VAR モデルを推定する ここでは VAR(p) モデル : R による時系列分析の方法 2 y t = c + Φ 1 y t

(2/24) : 1. R R R

Microsoft Word - 計量研修テキスト_第5版).doc

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

151021slide.dvi

情報管理学科で学ぶ

10:30 12:00 P.G. vs vs vs 2

p.1/22

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

1 Tokyo Daily Rainfall (mm) Days (mm)


こんにちは由美子です

R分散分析06.indd

2 と入力すると以下のようになる > x1<-c(1.52,2,3.01,9,2,6.3,5,11.2) > y1<-c(4,0.21,-1.5,8,2,6,9.915,5.2) > cor(x1,y1) [1] > cor.test(x1,y1) Pearson's produ

TOPIX30 2 / 37


卒業論文

目次 第 1 章序論 第 2 章データの概要 第 3 章 J リーグの現状 第 4 章分析 第 5 章まとめ 第 6 章今後の課題

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

H22 BioS (i) I treat1 II treat2 data d1; input group patno treat1 treat2; cards; ; run; I

4.9 Hausman Test Time Fixed Effects Model vs Time Random Effects Model Two-way Fixed Effects Model

Microsoft PowerPoint - Econometrics

R R 16 ( 3 )

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 (

st.dvi


I L01( Wed) : Time-stamp: Wed 07:38 JST hig e, ( ) L01 I(2017) 1 / 19

2. S 2 ɛ 3. ˆβ S 2 ɛ (n p 1)S 2 ɛ χ 2 n p 1 Z N(0, 1) S 2 χ 2 n T = Z/ S 2 /n n t- Z T = S2 /n t- n ( ) (n+1)/2 Γ((n + 1)/2) f(t) = 1 + t2 nπγ(n/2) n

H22 BioS t (i) treat1 treat2 data d1; input patno treat1 treat2; cards; ; run; 1 (i) treat = 1 treat =

SO(3) 7 = = 1 ( r ) + 1 r r r r ( l ) (5.17) l = 1 ( sin θ ) + sin θ θ θ ϕ (5.18) χ(r)ψ(θ, ϕ) l ψ = αψ (5.19) l 1 = i(sin ϕ θ l = i( cos ϕ θ l 3 = i ϕ


BR001

α β *2 α α β β α = α 1 β = 1 β 2.2 α 0 β *3 2.3 * *2 *3 *4 (µ A ) (µ P ) (µ A > µ P ) 10 (µ A = µ P + 10) 15 (µ A = µ P +

Microsoft Word - StatsDirectMA Web ver. 2.0.doc

Microsoft Word - 計量研修テキスト_第5版).doc

Microsoft Word - 計量研修テキスト_第5版).doc

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

ŠéŒØ‘÷†u…x…C…W…A…fi…l…b…g…‘†[…NfiüŒå†v(fl|ŁŠ−Ù) 4. −mŠ¦fiI’—Ÿ_ 4.1 −mŠ¦ŁªŁz‡Ì„v”Z

日本統計学会誌, 第44巻, 第2号, 251頁-270頁

MMXVC_H1

untitled

60 (W30)? 1. ( ) 2. ( ) web site URL ( :41 ) 1/ 77

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

10

AR(1) y t = φy t 1 + ɛ t, ɛ t N(0, σ 2 ) 1. Mean of y t given y t 1, y t 2, E(y t y t 1, y t 2, ) = φy t 1 2. Variance of y t given y t 1, y t

Statistics for finance Part II

Stata User Group Meeting in Kyoto / ( / ) Stata User Group Meeting in Kyoto / 21

2.1 R, ( ), Download R for Windows base. R ( ) R win.exe, 2.,.,.,. R > 3*5 # [1] 15 > c(19,76)+c(11,13)

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

untitled

2

ECCS. ECCS,. ( 2. Mac Do-file Editor. Mac Do-file Editor Windows Do-file Editor Top Do-file e

Transcription:

W707 s-taiji@is.titech.ac.jp 1 / 1

(lm) lm AIC 2 / 1

: y = β 1 x 1 + β 2 x 2 + + β d x d + β d+1 + ϵ (ϵ N(0, σ 2 )) y R: x R d : β i (i = 1,..., d):, β d+1 : ( ) (d = 1) y = β 1 x 1 + β 2 + ϵ (d > 1) y = β 1 x 1 + β 2 x 2 + + β d x d + β d+1 + ϵ 3 / 1

price 2e+07 4e+07 6e+07 8e+07 20 40 60 80 100 area 4 / 1

n ( ) (y i, x i ) R R d (i = 1,..., n) y 1 x 1 Y =. R n 1 1.., X =.. R n (d+1), ϵ = ϵ R n, x n 1 y n β ( ), Y = X β + ϵ. ϵ n ( ) ˆβ = (X X ) 1 X Y. Cramer-Rao ( ) 5 / 1

X ˆβ ( ( ) ) 1 1 n(ˆβ β ) N 0, σ 2 n X X. ( ) ˆβ = (X X ) 1 X Y = (X X ) 1 X (X β + ϵ) n(ˆβ β ) = n(x X ) 1 X ϵ. (1) ϵ i N(0, σ 2 ) 0. E[n(X X ) 1 X ϵϵ X (X X ) 1 ] = n(x X ) 1 X E[ϵϵ ]X (X X ) 1 = σ ( 2 1 n X X ) 1. σ 2 ( ) 6 / 1

ˆϵ ϵ ˆϵ = Y X ˆβ = X (β ˆβ) + ϵ = (I X (X X ) 1 X )ϵ S = ( 1 n X X ) 1 n( ˆβ j βj )/ S jj t(n (d + 1)) ˆϵ 2 /(n (d + 1)) ( n (d + 1) t ). β j : β j = 0 n ˆβ j / S jj ˆϵ 2 /(n (d + 1)) t α(n (d + 1)) βj = 0 t α t α (βj = 0 ˆβ j ) 7 / 1

1 ˆϵ = Y X ˆβ = X (β ˆβ) + ϵ = (I X (X X ) 1 X )ϵ 0 ˆβ β = (X X ) 1 X ϵ (Eq. (1)) E[ˆϵ(ˆβ β ) ] = O ˆϵ ˆβ β ( ) 2 (I X (X X ) 1 X ) n (d + 1) ˆϵ 2 /σ 2 n (d + 1) χ 2 3 n( ˆβ j β j )/ S jj N(0, σ 2 ) n( ˆβj β j )/ S jj 4 ˆϵ 2 /(n (d+1)) χ2 t σ 2 8 / 1

: F (H 0 ) Ȳ = H 0 : β 1 = β 2 = = β d = 0 vs H 1 : F = X ˆβ 1Ȳ 2 /d ˆϵ 2 F (d, n d 1). /(n (d + 1)) n i=1 y i n (R 2 ) (R 2 A ) R 2 = 1 Y X ˆβ 2 Y 1Ȳ, 2 R2 A = 1 Y X ˆβ 2 /(n d 1) Y 1Ȳ 2 /(n 1) 9 / 1

AIC (overfit), AIC (Akaike Information Criterion) d M d AIC : ˆθ Md M d AIC = 2 log(p({x i } n i=1 ˆθ Md )) + 2m. AIC = 2 + 2 AIC 10 / 1

AIC ( ) ( ) AIC KL-divergence ( KL-divergence) ( ) ( ) 11 / 1

( ) http://www.land.mlit.go.jp/webland/download.html 12 / 1

RC SRC ( ) {0, 1} RC 1, SRC 0 13 / 1

: lm(formula, data, subset, weights, na.action, method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, contrasts = NULL, offset,...) formula data subset weights na.action NA 14 / 1

formula y x y x1 + x2 y x1 * x2 y x - 1 y 1 + x + I(xˆ2) y x z y., data = y = β 1 x + b + ϵ y = β 1 x1 + β 2 x2 + b + ϵ y = β 1 x1 + β 2 x2 + β 3 x1x2 + b + ϵ ( ) y = β 1 x + ϵ : y = b + β 1 x + β 2 x 2 + ϵ z y x y x 1,..., x d y = b + d j=1 β jx j + ϵ x <- seq(-10,10); y<- 3*x + rnorm(21); lm(y ~ x) # y x x <- seq(-10,10); z <- seq(-10,10)^2; y<- 3*x + 4*z + rnorm(21); datain <- data.frame(x=x,z=z,y=y) lm(y ~ x, data=datain) # y x lm(y ~., data=datain) # y y 15 / 1

x <- read.csv("setagaya_manshion.csv") sman = data.frame(price=x[[1]],walk=x[[3]],area=x[[5]], str=ifelse(x[[6]]==" ",1,0),kenpei=x[[7]],youseki=x[[8]], tikunen=x[[9]],kyuko=x[[10]]) # 0-1 plot(sman) # 0 10 20 0.0 0.6 100 400 0.0 0.6 price 2e+07 0 10 20 walk area 20 80 0.0 0.6 str kenpei 40 60 80 100 400 youseki tikunen 1970 2000 0.0 0.6 kyuko 16 / 1

(lm) sman.lm <- lm(price ~ area,data=sman) # OK plot(sman$area,sman$price, xlab="area",ylab="price") # abline(sman.lm, lwd=1, col="blue") price 2e+07 4e+07 6e+07 8e+07 20 40 60 80 100 area 17 / 1

(summary) > summary(sman.lm) Call: lm(formula = price ~ area, data = sman) Residuals: Min 1Q Median 3Q Max -16082568-5634345 -789511 4806399 16822060 Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) -1029167 1519818-0.677 0.5 area 673025 26408 25.485 <2e-16 *** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1 Residual standard error: 7594000 on 128 degrees of freedom Multiple R-squared: 0.8354, Adjusted R-squared: 0.8341 F-statistic: 649.5 on 1 and 128 DF, p-value: < 2.2e-16 18 / 1

(1) Call: lm(formula = price ~ area, data = sman) Residuals: Min 1Q Median 3Q Max -16082568-5634345 -789511 4806399 16822060 y i ŷ i = y i ˆβ x 19 / 1

(2) Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) -1029167 1519818-0.677 0.5 area 673025 26408 25.485 <2e-16 *** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1 t- p- (Intercept). t- p- 0 y area ( α = 0.05 ) 20 / 1

(3) Residual standard error: 7594000 on 128 degrees of freedom (σ ) 130 1 + 130-2=128. F-statistic: 649.5 on 1 and 128 DF, p-value: < 2.2e-16 β = 0 F (d, n d 1) ( ) (α = 0.05) Multiple R-squared: 0.8354, Adjusted R-squared: 0.8341 (Adjusted R-squared) Adjusted 21 / 1

par(mfrow=c(2,2)) # Figure 2x2 plot(sman.lm) Residuals Standardized residuals 2e+07 0e+00 2e+07 0.0 0.5 1.0 1.5 Residuals vs Fitted 96 58 1e+07 3e+07 5e+07 7e+07 39 Fitted values Scale Location 39 96 58 1e+07 3e+07 5e+07 7e+07 Standardized residuals Standardized residuals 2 1 0 1 2 2 1 0 1 2 Normal Q Q 96 58 39 2 1 0 1 2 Theoretical Quantiles Residuals vs Leverage 58 43 45 Cook s distance 0.00 0.01 0.02 0.03 0.04 0.05 ( ) : ŷ i vs y i ŷ i ( ) Q-Q : Q-Q ( ) Scale-Location : ( ) Cook : ( ). 0.5 Fitted values Leverage 22 / 1

predict interval= confidence ( ˆβ X ) area.plot <- seq(min(sman$area)*0.9,max(sman$area)*1.1,by=1) # sman.con <- predict(sman.lm, data.frame(area=area.plot),interval="confidence") # price 2e+07 4e+07 6e+07 8e+07 1e+08 20 40 60 80 100 120 area (m^2) 23 / 1

> sman.lm3 <- lm(price ~ area + tikunen, data=sman) > (AIC(sman.lm3)) [1] 4443.881 AIC( ) AIC sman.lmall <- lm(price ~., data=sman) sman.lmaic <- step(sman.lmall) summary(sman.lmaic) step( ) AIC ( ) walk + area + tikunen 24 / 1

> shapiro.test(sman.lmaic$residuals) Shapiro-Wilk normality test data: sman.lmaic$residuals W = 0.9874, p-value = 0.2806 25 / 1

QQ qqnorm(sman.lmaic$residual) Normal Q Q Plot Sample Quantiles 1.5e+07 5.0e+06 5.0e+06 1.5e+07 2 1 0 1 2 Theoretical Quantiles QQ 26 / 1