『社会科学のためのデータ分析入門』練習問題の解答第4章

『社会科学のためのデータ分析入門』の第4章解答です。

 

繰り返しますが、自分も初学者なので間違いやミスは大いにありえます。

訂正すべきところや誤りについてはコメント欄に投稿していただけると嬉しいです。

イワマ

問題文が難しい。。。

イワマ

大学受験の時も、問題文を誤読しないことが大切だったので、

誤読しないように頑張ります!

イワマ

(まあ、すでに何問かか読み間違えてるかも。。。。)

練習問題4.5.1

1

R
> #1
> #2008
> intrade08 <- read.csv("intrade08.csv") 
> press08 <- read.csv("pres08.csv") 
> prevote08 <- intrade08[intrade08$day == "2008-11-03",] 
> prevote08$margins <- prevote08$PriceD - prevote08$PriceR 
> press08$margins <- press08$Obama - press08$McCain 
> prevote08$state[sign(prevote08$margins) != sign(press08$margins)] 
[1] IN MO
51 Levels: AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC ... WY
> 
> #2012
> intrade12 <- read.csv("intrade12.csv") 
> press12 <- read.csv("pres12.csv") 
> prevote12 <- intrade12[intrade12$day == "2012-11-05",] 
> margine <- na.omit(merge(prevote12, press12, by = "state")) #州の数を揃える#NA除去 
> margine$margins_prevote <- margine$PriceD - margine$PriceR 
> margine$margins_press <- margine$Obama - margine$Romney 
> margine$state[sign(margine$margins_prevote) != sign(margine$margins_press)]
[1] FL
50 Levels: AK AL AR AZ CA CO CT DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD ... WY
> 

 

解答

・2008年はインディアナ州(IN)とモンタナ州(MO)の州が誤って分類された。

 

・世論調査による分類に比べてイントレードのほうが精度が高かった。

 

・また、2012年のイントレードでの分類で誤ってのはフロリダ州(FL)だけであった。

 

・2008年より2012年の賭博市場のほうがうまく予測できたと言える。

 

・総じて世論調査よりイントレードでの分析のほうが精度が高く、効率的市場仮説が機能している(正しい)可能性があると言える。

イワマ

世論調査より賭博市場のほうが、正しい結果を予想しているの面白い

イワマ

「intrade12.csv」の州が50個、「pres12.csv」の州は51個だったので。。

イワマ

州をキーにしてマージしました。

 

2

コード
> #2
> #margine
> margine08 <- merge(intrade08, press08, by = "state") 
> margine08$day <- as.Date(margine08$day) 
> margine08$DaysToElection <- as.Date("2008-11-04") - margine08$day 
> Obama.pred <- rep(NA, 90) 
> #roop
> for (i in 1:90){
+   day.data <- subset(margine08, subset = (DaysToElection == (90 - i)))
+   Obama.pred[i] <- sum(day.data$EV[day.data$PriceD > day.data$PriceR])
+ }
> #plot
> plot(90:1,Obama.pred,
+      type = "b", col = "blue", 
+      xlim = c(90,1),ylim = c(200,400),
+      xlab = "DaysToElection", ylab = "Estimated number of EV",
+      main = "Estimated number of EV for 90 days")
> points(0, 365, pch = 19, col = "blue")
> abline(v = 0)

 

 

解答

実際の選挙結果とイントレードから予測された直前の予想選挙結果がほぼ同数である

 

イワマ

結構、正確に見えるなあ

 

 

3

コード
> #3
> State.EV <- subset(margine08, DaysToElection == 1, select = c(state, EV)) 
> Obama.pred <- rep(NA, 90) 
> for(i in 1:90){
+   week.data <- subset(margine08, subset = ((DaysToElection <= (90 - i +7)) & (DaysToElection > (90 - i))))
+   Obama.pred[i] <- sum(State.EV$EV + [tapply(week.data$PriceD, week.data$state, mean) > 
+                            tapply(week.data$PriceR, week.data$state, mean)])
+ }
> 
> #plot
> plot(90:1,Obama.pred,
+      type = "b", col = "blue", 
+      xlim = c(90,1),ylim = c(200,400),
+      xlab = "DaysToElection", ylab = "Estimated number of EV",
+      main = "Estimated number of EV for 90 days MA ver")
> points(0, 365, pch = 19, col = "blue")
> abline(v = 0)

 

 

解答

移動平均価格を用いた方が、日足価格より数値のボラティリティが減少する

イワマ

移動平均のほうがボラが下がるのか。。。

イワマ

そりゃ平均だから、当たり前か

イワマ

平均だと数値が安定するって考え方は、何かに使えそうだな

 

4

コード

> #4
> polls08 <- read.csv("polls08.csv") 
> polls08$middate <- as.Date(polls08$middate) 
> polls08$DaysToElection <- as.Date("2008-11-04") - polls08$middate 
> st.names <- unique(polls08$state) 
> obamapoll.pred <- rep(NA, 51) 
> state.pred <- rep(NA, 51) 
> for (i in 1:90){
+   for (j in 1:51){
+     state.data <- subset(polls08, subset = (state == st.names[j]))
+     num <- which(abs(state.data$DaysToElection - i) 
+ == min(abs(state.data$DaysToElection - i))) # 最も近い値を持つ要素の番号 
+ if (state.data$Obama[num] 
> state.data$McCain[num]){
+       State.EV$Obama[j] <- TRUE
+     } else {
+       State.EV$Obama[j] <- FALSE
+     }                                          
+   }
+   obamapoll.pred[i] <- sum(State.EV$EV[State.EV$Obama == TRUE]) 
+ } 

> 
> 
> #plot
> plot(90:1,obamapoll.pred,
+      type = "b", col = "blue", 
+      xlim = c(90,1),ylim = c(150,400),
+      xlab = "DaysToElection", ylab = "Estimated number of EV",
+      main = "Estimated number of EV for 90 days poll08 ver")
> points(0, 365, pch = 19, col = "blue")
> abline(v = 0)

 

 

イワマ

いや、なんかもう絶対違う。。。

イワマ

どこが間違ってるか、誰かコメント等で教えていただけると嬉しいです

5

 

コード

> #5
> premargine08 <- merge(prevote08, press08, by = "state") 
> lm(margins.y ~ margins.x, data = premargine08)

Call:
lm(formula = margins.y ~ margins.x, data = premargine08)

Coefficients:
(Intercept)    margins.x  
     1.3027       0.2291  


> poll.pred <- rep(NA, 51) 
> names(poll.pred) <- as.character(st.names) 
> polls08$margin <- polls08$Obama - polls08$McCain 
> for (i in 1:51){
+   state.data <- subset(polls08,
+                        subset = (state == st.names[i]))
+   latest <- subset(state.data,
+                    DaysToElection == min(DaysToElection))
+   poll.pred[i] <- mean(latest$margin) + } 
> 
> press08$poll <- poll.pred > lm(margins ~ poll, data = press08)

Call:
lm(formula = margins ~ poll, data = press08)

Coefficients:
(Intercept)         poll  
     0.7091       1.1086  

 

 

解答
・価格マージンが10増えると、勝利マージンは約2.29パーセントポイント増える
・世論調査でのマージンが10パーセント増えると、勝利マージンは約11.09パーセントポイント増える

イワマ

上の結果から結局何が言えるの?というところがわからなかった

イワマ

バイアスのことを言えば良いのか、結果のモデルのあてはまりなのか。。。???

 

 

6

コード

> #6
> lm(margins_press ~ margins_prevote, data = margine12)

Call:
lm(formula = margins_press ~ margins_prevote, data = margine12)

Coefficients:
    (Intercept)  margins_prevote  
        -0.1220           0.2044  

> 
> 
> polls12 <- read.csv("polls12.csv") 
> poll.pred <- rep(NA, 47) 
> st.names <- unique(polls12$state) 
> names(poll.pred) <- as.character(st.names) 
> polls12$margin <- polls12$Obama - polls12$Romney 
> polls12$middate <- as.Date(polls12$middate) 
> polls12$DaysToElection <- as.Date("2012-11-06") - polls12$middate 
> for (i in 1:47){
+   state.data <- subset(polls12,
+                        subset = (state == st.names[i]))
+   latest <- subset(state.data,
+                    DaysToElection == min(DaysToElection))
+   poll.pred[i] <- mean(latest$margin) + } 
> 
> DF <- data.frame(poll = poll.pred, state = st.names) 
> pollmargine12 <- merge(polls12, DF, by = "state") 
> lm(margin ~ poll, data = pollmargine12)

Call:
lm(formula = margin ~ poll, data = pollmargine12)

Coefficients:
(Intercept)         poll  
     0.6405       0.9816  
解答
・価格マージンが10増えると、勝利マージンは約2.04パーセントポイント増える

・世論調査でのマージンが10パーセント増えると、勝利マージンは約9.82パーセントポイント増える

・2008年と2012年で、係数に似た値がでているため、2008年のモデルで2012年の結果を予測することは可能

・しかし2008年に限ってはイントレードの切片が大きく異なっているため、正確には予測できない可能性が大きい

 

イワマ

州の名前をユニークでとったら47しかでてこなかったのは、なぜだ!???

 

4.5.2

1

コード

> #1
> progresa <- read.csv("progresa.csv") 
> tapply(progresa$t2000 , progresa$treatment, mean)
       0        1 
63.81483 68.08451 
> tapply(progresa$pri2000s , progresa$treatment, mean)
       0        1 
34.48895 38.11145 
> lm(t2000 ~ treatment , data = progresa)

Call:
lm(formula = t2000 ~ treatment, data = progresa)

Coefficients:
(Intercept)    treatment  
      63.81         4.27  

> lm(pri2000s ~ treatment , data = progresa)

Call:
lm(formula = pri2000s ~ treatment, data = progresa)

Coefficients:
(Intercept)    treatment  
     34.489        3.622  
解答

トリートメントを受けた選挙区のほうが、平均投票率と平均得票率は高かった。

また回帰分析の結果から、トリートメントを受けた選挙区になると、

投票率が4.27%あがり、得票率が約3.622%あがる。

イワマ

ばらまき作戦成功

 

2

コード

> #2
> t2000.model <- lm(t2000 ~ treatment + avgpoverty + pobtot1994 + votos1994 + pri1994 + + pan1994 + prd1994 , data = progresa) > summary(t2000.model)

Call:
lm(formula = t2000 ~ treatment + avgpoverty + pobtot1994 + votos1994 + 
    pri1994 + pan1994 + prd1994, data = progresa)

Residuals:
    Min      1Q  Median      3Q     Max 
-50.173 -11.924  -2.938   6.972 302.183 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) 64.0117350 17.3115236   3.698 0.000247 ***
treatment    4.5494445  3.1346655   1.451 0.147454    
avgpoverty   0.3102553  3.5223779   0.088 0.929855    
pobtot1994  -0.0012128  0.0002316  -5.236 2.63e-07 ***
votos1994   -0.0261518  0.0354456  -0.738 0.461059    
pri1994      0.0360555  0.0409173   0.881 0.378739    
pan1994      0.0265376  0.0595018   0.446 0.655836    
prd1994      0.0175753  0.0426669   0.412 0.680615    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 29.95 on 409 degrees of freedom
Multiple R-squared:  0.0785,	Adjusted R-squared:  0.06273 
F-statistic: 4.978 on 7 and 409 DF,  p-value: 2.01e-05

> pri2000s.model <- lm(pri2000s ~ treatment + avgpoverty + pobtot1994 + votos1994 + pri1994 + + pan1994 + prd1994 , data = progresa) > summary(pri2000s.model)

Call:
lm(formula = pri2000s ~ treatment + avgpoverty + pobtot1994 + 
    votos1994 + pri1994 + pan1994 + prd1994, data = progresa)

Residuals:
    Min      1Q  Median      3Q     Max 
-32.297  -9.854  -1.322   6.468  94.918 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) 37.9500862  9.4239516   4.027 6.73e-05 ***
treatment    2.9277395  1.7064319   1.716  0.08697 .  
avgpoverty   0.5329801  1.9174926   0.278  0.78119    
pobtot1994  -0.0004996  0.0001261  -3.962 8.77e-05 ***
votos1994   -0.0417278  0.0192957  -2.163  0.03116 *  
pri1994      0.0624589  0.0222744   2.804  0.00529 ** 
pan1994     -0.0487349  0.0323913  -1.505  0.13321    
prd1994     -0.0287363  0.0232268  -1.237  0.21672    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 16.3 on 409 degrees of freedom
Multiple R-squared:  0.2206,	Adjusted R-squared:  0.2073 
F-statistic: 16.54 on 7 and 409 DF,  p-value: < 2.2e-16
解答

トリートメントを受けた選挙区になると、

投票率が4.54%あがり、得票率が約2.92%あがる。

・前問の結果と、切片はそれぞれ+0.3%、-0.7%と異なった。

イワマ

前問の結果との違いが大きいのか小さいのかよくわからない

 

3

コード

> #3
> t2000.share <- lm(t2000 ~ treatment + avgpoverty + I(log(votos1994)) + t1994 + pri1994s + + pan1994s + prd1994s , data = progresa) > summary(t2000.share)

Call:
lm(formula = t2000 ~ treatment + avgpoverty + I(log(votos1994)) + 
    t1994 + pri1994s + pan1994s + prd1994s, data = progresa)

Residuals:
     Min       1Q   Median       3Q      Max 
-121.929   -7.366   -0.933    5.474  177.177 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)        23.6041    12.9055   1.829 0.068128 .  
treatment          -0.3552     1.8069  -0.197 0.844269    
avgpoverty          2.6091     1.8667   1.398 0.162972    
I(log(votos1994))  -4.9811     1.3395  -3.719 0.000228 ***
t1994               0.7397     0.1307   5.658 2.88e-08 ***
pri1994s            0.1630     0.1365   1.195 0.232924    
pan1994s            0.6442     0.2102   3.065 0.002318 ** 
prd1994s            0.2813     0.1463   1.923 0.055236 .  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 17.19 on 409 degrees of freedom
Multiple R-squared:  0.6965,	Adjusted R-squared:  0.6913 
F-statistic: 134.1 on 7 and 409 DF,  p-value: < 2.2e-16 > 
> pri200s.share <- lm(pri2000s ~ treatment + avgpoverty + I(log(votos1994)) + t1994 + pri1994s + + pan1994s + prd1994s , data = progresa) > summary(pri200s.share)

Call:
lm(formula = pri2000s ~ treatment + avgpoverty + I(log(votos1994)) + 
    t1994 + pri1994s + pan1994s + prd1994s, data = progresa)

Residuals:
    Min      1Q  Median      3Q     Max 
-66.159  -7.154  -0.122   6.311  58.162 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)       30.95745    8.94802   3.460 0.000598 ***
treatment          0.08599    1.25281   0.069 0.945313    
avgpoverty         2.59262    1.29430   2.003 0.045825 *  
I(log(votos1994)) -5.67673    0.92877  -6.112 2.30e-09 ***
t1994              0.11784    0.09065   1.300 0.194339    
pri1994s           0.49695    0.09463   5.252 2.43e-07 ***
pan1994s          -0.16209    0.14572  -1.112 0.266662    
prd1994s          -0.06799    0.10145  -0.670 0.503119    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 11.92 on 409 degrees of freedom
Multiple R-squared:  0.5836,	Adjusted R-squared:  0.5765 
F-statistic:  81.9 on 7 and 409 DF,  p-value: < 2.2e-16

 

解答

トリートメントを受けた選挙区になると、

投票率が-0.36%あがり、得票率が約0.08%あがる.

・前問の結果と大きく異なる

・調整済み決定係数が、前問は約0.06・約0.21で、本問は約0.69・約0.58であった。

・本問のモデルのほうが、データによく当てはまっていると言える

 

 

 

4

コード

> #4
> #選挙区人口
> boxplot(pobtot1994 ~ treatment, data = progresa,
+         main = "Total population of constituencies",
+         ylim = c(0,4000),
+         names = c("controll", "treatment"))
> 
> #平均貧困指数
> boxplot(avgpoverty ~ treatment, data = progresa,
+         main = "Average poverty index",
+         names = c("controll", "treatment"))
> 
> #投票率
> boxplot(t1994 ~ treatment, data = progresa,
+         main = "Voting rate",
+         ylim = c(0,130),
+         names = c("controll", "treatment"))
> 
> #PRI支持率
> boxplot(pri1994s ~ treatment, data = progresa,
+         main = "pri rating",
+         ylim = c(0,130),
+         names = c("controll", "treatment"))

解答

・コントロールグループとトリートメントグループに大きな違いは見られない

 

 

 

 

 

 

4.5.3

1

解答
・非連続的な点で他のことが起こっていないと仮定が必要で、
本問の場合非連続的な点とは人口のしきい値である。

・この仮定が成立しないのは、汚職が蔓延し人口に関係なく特定の地域に肩入れされている現象があるシナリオ等である。

・回帰分断デザインの利点は潜在的なバイアスを回避できるが、欠点として得られる因果効果の推定値が非連続な点付近に対してのみ適用されることである。

イワマ

教科書に書いてあることを自分なりに解釈したら、こうなったけど、もしかしたら思い切り間違えているかもしれない。。

2

コード

> #2
> transfer <- read.csv("transfer.csv") 
> threshold <- c(10188, 13584, 16980) 
> 
> for (i in 1:1787){
+   num <- which(abs(transfer$pop82[i] - threshold) 
+ == min(abs(transfer$pop82[i] - threshold))) 
+ if(min(transfer$pop82[i] - threshold) >= 0){
+     transfer$difference[i] <- 
+       min(transfer$pop82[i] - threshold) * 100 / threshold[num]}
+   else{transfer$difference[i] <-   
+     -(min(abs(transfer$pop82[i] - threshold)) * 100 / threshold[num])}}

 

 

3

コード

> #3
> city.within3 <-  subset(transfer, subset = (difference <= 3 & difference >= -3))
> city.plus3 <-  subset(transfer, subset = (difference <= 3 & difference >= 0))
> city.minus3 <- subset(transfer, subset = (difference <= 0 & difference >= -3))
> educ.plus <- lm(educ91 ~ difference, data = city.plus3) 
> educ.minus <- lm(educ91 ~ difference, data = city.minus3) 
> literate.plus <- lm(literate91 ~ difference, data = city.plus3) 
> literate.minus <- lm(literate91 ~ difference, data = city.minus3) 
> poverty.plus <- lm(poverty91 ~ difference, data = city.plus3) 
> poverty.minus <- lm(poverty91 ~ difference, data = city.minus3) > educ.plus

Call:
lm(formula = educ91 ~ difference, data = city.plus3)

Coefficients:
(Intercept)   difference  
     4.9460      -0.2027  

> educ.minus

Call:
lm(formula = educ91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
     4.6573       0.0916  

> literate.plus

Call:
lm(formula = literate91 ~ difference, data = city.plus3)

Coefficients:
(Intercept)   difference  
    0.82195     -0.01698  

> literate.minus

Call:
lm(formula = literate91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
   0.799797     0.008147  

> poverty.plus

Call:
lm(formula = poverty91 ~ difference, data = city.plus3)

Coefficients:
(Intercept)   difference  
    0.55912      0.01432  

> poverty.minus

Call:
lm(formula = poverty91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
    0.56407     -0.03485  

 

4

コード

> #4
> preeduc.plus <- predict(educ.plus) 
> preeduc.minus <- predict(educ.minus) 
> preliterate.plus <- predict(literate.plus) 
> preliterate.minus <- predict(literate.minus) 
> prepoverty.plus <- predict(poverty.plus) 
> prepoverty.minus <- predict(poverty.minus) 
> 
> 
> plot(city.whthin3$difference, city.whthin3$educ91,
+      main = "education",
+      ylab = "educ91", xlab = "difference")
> lines(city.plus3$difference,preeduc.plus, col = "blue")
> lines(city.minus3$difference,preeduc.minus, col = "red")
> 
> plot(city.whthin3$difference, city.whthin3$literate91,
+      main = "literate",
+      ylab = "literate91", xlab = "difference")
> lines(city.plus3$difference,preliterate.plus, col = "blue")
> lines(city.minus3$difference,preliterate.minus, col = "red")
> 
> plot(city.whthin3$difference, city.whthin3$poverty91,
+      main = "poverty",
+      ylab = "poverty91", xlab = "difference")
> lines(city.plus3$difference,prepoverty.plus, col = "blue")
> lines(city.minus3$difference,prepoverty.minus, col = "red") 

 

解答

下に比べて、しきい値が上になると教育年数や識字率は、上がっている。

しかし貧困率に関してはあまり変化がないように見える

イワマ

貧困率のところはなんでなんだ。。。

 

5

コード

> #5
> mean(city.plus3$educ91) - mean(city.minus3$educ91)
[1] 0.1258492
> mean(city.plus3$literate91) - mean(city.minus3$literate91)
[1] 0.009218204
> mean(city.plus3$poverty91) - mean(city.minus3$poverty91)
[1] -0.03507338
解答

・問3に比べて、正負は同じだが差は小さい

・ここで用いられる仮定は

 

 

6

コード

> #6
> for (i in 1:4){
+   city.plus <- subset(transfer, subset = (difference <= i+1 & difference >= i))
+   educ.plus <- lm(educ91 ~ difference, data = city.plus)
+   print(i)
+   print(educ.plus)
+   literate.plus <- lm(literate91 ~ difference, data = city.plus)
+   print(literate.plus)
+   poverty.plus <- lm(poverty91 ~ difference, data = city.plus) 
+ print(poverty.plus) 
+ }

 [1] 1 
Call:
 lm(formula = educ91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
4.69814 -0.04874
 
Call:
 lm(formula = literate91 ~ difference, data = city.plus) 
Coefficients:
 (Intercept) difference 
0.81454 -0.01595 

Call:
 lm(formula = poverty91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
0.55234 0.02517 

[1] 2 
Call: 
lm(formula = educ91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
2.6203 0.7301 

Call: 
lm(formula = literate91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
0.55356 0.09298 

Call: 
lm(formula = poverty91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
0.9411 -0.1418 

[1] 3 
Call: 
lm(formula = educ91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
11.060 -1.879 

Call: 
lm(formula = literate91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
1.4669 -0.2068 

Call: 
lm(formula = poverty91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
-0.029 0.188 

[1] 4 
Call: 
lm(formula = educ91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
-2.922 1.724 

Call: 
lm(formula = literate91 ~ difference, data = city.plus) 
Coefficients:
(Intercept) difference 
0.2310 0.1388 

Call: 
lm(formula = poverty91 ~ difference, data = city.plus) 
Coefficients: 
(Intercept) difference 
1.3346 -0.1666 
> 
> for (i in -5:-2){
+   city.minus <- subset(transfer, subset = (difference <= i+1 & difference >= i))
+   educ.miunus <- lm(educ91 ~ difference, data = city.minus)
+   print(i)
+   print(educ.minus)
+   literate.minus <- lm(literate91 ~ difference, data = city.minus)
+   print(literate.minus)
+   poverty.minus <- lm(poverty91 ~ difference, data = city.minus)
+   print(poverty.minus)
+ }
[1] -5

Call:
lm(formula = educ91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
     4.6573       0.0916  


Call:
lm(formula = literate91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.97784      0.03681  


Call:
lm(formula = poverty91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
   0.615315     0.007889  

[1] -4

Call:
lm(formula = educ91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
     4.6573       0.0916  


Call:
lm(formula = literate91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.98777      0.05692  


Call:
lm(formula = poverty91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.33496     -0.07922  

[1] -3

Call:
lm(formula = educ91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
     4.6573       0.0916  


Call:
lm(formula = literate91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.85491      0.02883  


Call:
lm(formula = poverty91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.45477     -0.07875  

[1] -2

Call:
lm(formula = educ91 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
     4.6573       0.0916  


Call:
lm(formula = literate91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.82061      0.02652  


Call:
lm(formula = poverty91 ~ difference, data = city.minus)

Coefficients:
(Intercept)   difference  
    0.57819     -0.02614  

イワマ

うっす

7

コード

> #7
> educ80.plus <- lm(educ80 ~ difference, data = city.plus3) 
> educ80.minus <- lm(educ80 ~ difference, data = city.minus3) 
> poverty80.plus <- lm(poverty80 ~ difference, data = city.plus3) 
> poverty80.minus <- lm(poverty80 ~ difference, data = city.minus3) 
> educ80.plus

Call:
lm(formula = educ80 ~ difference, data = city.plus3)

Coefficients:
(Intercept)   difference  
    1.95650     -0.05936  

> educ80.minus

Call:
lm(formula = educ80 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
    1.97746      0.05454  

> poverty80.plus

Call:
lm(formula = poverty80 ~ difference, data = city.plus3)

Coefficients:
(Intercept)   difference  
    0.55521      0.02633  

> poverty80.minus

Call:
lm(formula = poverty80 ~ difference, data = city.minus3)

Coefficients:
(Intercept)   difference  
     0.5573      -0.0338  

8 Comments

匿名

下巻の5章の練習問題1の解答をつくってくださると非常にありがたいです…。急ぎで必要です。。

返信する
匿名

下巻の第5章の5.1.1の練習問題の解説が至急でほしいです…!!
ぜひともおねがいします。

返信する
匿名

ありがとうございます。
下巻の第5章の5.1.1の練習問題の解説が知りたいです…。ぜひぜひよろしくおねがいします。

返信する
あい

はじめまして。いつもブログを楽しみに拝見しております。
丁度同じ本で勉強をしており、4章を終えたところで、下巻も一緒に勉強したいと思っています。更新を楽しみにしています!!!

返信する
じんたん

下巻の解答をお願いします!
授業で取り扱っているのですが、
進みが悪くて

返信する

コメントを残す

メールアドレスが公開されることはありません。

CAPTCHA