Skip to content

Commit

Permalink
Render all formats
Browse files Browse the repository at this point in the history
  • Loading branch information
remlapmot committed Mar 2, 2024
1 parent 8ecdc50 commit 2b17c26
Show file tree
Hide file tree
Showing 37 changed files with 5,849 additions and 5,849 deletions.
Binary file modified data/fig1.dta
Binary file not shown.
Binary file modified data/fig2.dta
Binary file not shown.
Binary file modified data/fig3.dta
Binary file not shown.
Binary file modified data/nhefs-formatted.dta
Binary file not shown.
Binary file modified data/nhefs-highprice.dta
Binary file not shown.
Binary file modified data/nhefs-ps.dta
Binary file not shown.
Binary file modified data/nhefs-wcens.dta
Binary file not shown.
Binary file modified data/nhefs_std.dta
Binary file not shown.
Binary file modified data/nhefs_std1.dta
Binary file not shown.
Binary file modified data/nhefs_std2.dta
Binary file not shown.
Binary file modified data/nhefs_surv.dta
Binary file not shown.
Binary file modified data/observe.mmat
Binary file not shown.
142 changes: 71 additions & 71 deletions docs/11-why-model-r.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ plot(A, Y)

```r
summary(Y[A == 0])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 10.0 27.5 60.0 67.5 87.5 170.0
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 10.0 27.5 60.0 67.5 87.5 170.0
summary(Y[A == 1])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 50.0 105.0 160.0 146.2 185.0 220.0
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 50.0 105.0 160.0 146.2 185.0 220.0

A2 <- c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4)
Y2 <- c(110, 80, 50, 40, 170, 30, 70, 50, 110, 50, 180,
Expand All @@ -39,17 +39,17 @@ plot(A2, Y2)

```r
summary(Y2[A2 == 1])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 40.0 47.5 65.0 70.0 87.5 110.0
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 40.0 47.5 65.0 70.0 87.5 110.0
summary(Y2[A2 == 2])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 30 45 60 80 95 170
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 30 45 60 80 95 170
summary(Y2[A2 == 3])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 50.0 95.0 120.0 117.5 142.5 180.0
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 50.0 95.0 120.0 117.5 142.5 180.0
summary(Y2[A2 == 4])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 150.0 187.5 205.0 195.0 212.5 220.0
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 150.0 187.5 205.0 195.0 212.5 220.0
```


Expand All @@ -74,47 +74,47 @@ plot(Y3 ~ A3)
```r

summary(glm(Y3 ~ A3))
##
## Call:
## glm(formula = Y3 ~ A3)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 24.5464 21.3300 1.151 0.269094
## A3 2.1372 0.3997 5.347 0.000103 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 1944.109)
##
## Null deviance: 82800 on 15 degrees of freedom
## Residual deviance: 27218 on 14 degrees of freedom
## AIC: 170.43
##
## Number of Fisher Scoring iterations: 2
#>
#> Call:
#> glm(formula = Y3 ~ A3)
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 24.5464 21.3300 1.151 0.269094
#> A3 2.1372 0.3997 5.347 0.000103 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> (Dispersion parameter for gaussian family taken to be 1944.109)
#>
#> Null deviance: 82800 on 15 degrees of freedom
#> Residual deviance: 27218 on 14 degrees of freedom
#> AIC: 170.43
#>
#> Number of Fisher Scoring iterations: 2
predict(glm(Y3 ~ A3), data.frame(A3 = 90))
## 1
## 216.89
#> 1
#> 216.89

summary(glm(Y ~ A))
##
## Call:
## glm(formula = Y ~ A)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 67.50 19.72 3.424 0.00412 **
## A 78.75 27.88 2.824 0.01352 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 3109.821)
##
## Null deviance: 68344 on 15 degrees of freedom
## Residual deviance: 43538 on 14 degrees of freedom
## AIC: 177.95
##
## Number of Fisher Scoring iterations: 2
#>
#> Call:
#> glm(formula = Y ~ A)
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 67.50 19.72 3.424 0.00412 **
#> A 78.75 27.88 2.824 0.01352 *
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> (Dispersion parameter for gaussian family taken to be 3109.821)
#>
#> Null deviance: 68344 on 15 degrees of freedom
#> Residual deviance: 43538 on 14 degrees of freedom
#> AIC: 177.95
#>
#> Number of Fisher Scoring iterations: 2
```

## Program 11.3
Expand All @@ -128,26 +128,26 @@ Asq <- A3 * A3

mod3 <- glm(Y3 ~ A3 + Asq)
summary(mod3)
##
## Call:
## glm(formula = Y3 ~ A3 + Asq)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.40688 31.74777 -0.233 0.8192
## A3 4.10723 1.53088 2.683 0.0188 *
## Asq -0.02038 0.01532 -1.331 0.2062
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 1842.697)
##
## Null deviance: 82800 on 15 degrees of freedom
## Residual deviance: 23955 on 13 degrees of freedom
## AIC: 170.39
##
## Number of Fisher Scoring iterations: 2
#>
#> Call:
#> glm(formula = Y3 ~ A3 + Asq)
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -7.40688 31.74777 -0.233 0.8192
#> A3 4.10723 1.53088 2.683 0.0188 *
#> Asq -0.02038 0.01532 -1.331 0.2062
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> (Dispersion parameter for gaussian family taken to be 1842.697)
#>
#> Null deviance: 82800 on 15 degrees of freedom
#> Residual deviance: 23955 on 13 degrees of freedom
#> AIC: 170.39
#>
#> Number of Fisher Scoring iterations: 2
predict(mod3, data.frame(cbind(A3 = 90, Asq = 8100)))
## 1
## 197.1269
#> 1
#> 197.1269
```
Loading

0 comments on commit 2b17c26

Please sign in to comment.