library(wooldridge)
library(rmarkdown)
data("bwght")
paged_table(bwght)
RMARKDOWN 1 rmarkdown (why we use rmarkdown in our r program -> when we want to tabulate the data on that time we use rmakdown for exmaple page_table and let’s clarify with example above)
summary(lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc + motheduc + motheduc + parity + male + white +
cigs + lbwght + bwghtlbs +packs +lfaminc, data = bwght))
##
## Call:
## lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc +
## motheduc + motheduc + parity + male + white + cigs + lbwght +
## bwghtlbs + packs + lfaminc, data = bwght)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.348 -5.165 -3.064 2.014 55.458
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -70.20275 20.70144 -3.391 0.000719 ***
## cigtax -0.10012 0.06465 -1.549 0.121739
## cigprice 0.06165 0.04905 1.257 0.209052
## bwght -0.03950 0.05069 -0.779 0.435971
## fatheduc 0.51772 0.11582 4.470 8.57e-06 ***
## motheduc 0.28182 0.13184 2.138 0.032755 *
## parity -0.02661 0.27278 -0.098 0.922309
## male 0.06681 0.47654 0.140 0.888532
## white 0.75768 0.67676 1.120 0.263124
## cigs -0.03565 0.04609 -0.773 0.439420
## lbwght 4.51843 5.41458 0.834 0.404171
## bwghtlbs NA NA NA NA
## packs NA NA NA NA
## lfaminc 20.87751 0.38522 54.196 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.142 on 1179 degrees of freedom
## (197 observations deleted due to missingness)
## Multiple R-squared: 0.7963, Adjusted R-squared: 0.7944
## F-statistic: 419 on 11 and 1179 DF, p-value: < 2.2e-16
model111 <- lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc + motheduc + motheduc + parity + male + white +
cigs + lbwght + bwghtlbs +packs +lfaminc, data = bwght)
summary(model111)
##
## Call:
## lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc +
## motheduc + motheduc + parity + male + white + cigs + lbwght +
## bwghtlbs + packs + lfaminc, data = bwght)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.348 -5.165 -3.064 2.014 55.458
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -70.20275 20.70144 -3.391 0.000719 ***
## cigtax -0.10012 0.06465 -1.549 0.121739
## cigprice 0.06165 0.04905 1.257 0.209052
## bwght -0.03950 0.05069 -0.779 0.435971
## fatheduc 0.51772 0.11582 4.470 8.57e-06 ***
## motheduc 0.28182 0.13184 2.138 0.032755 *
## parity -0.02661 0.27278 -0.098 0.922309
## male 0.06681 0.47654 0.140 0.888532
## white 0.75768 0.67676 1.120 0.263124
## cigs -0.03565 0.04609 -0.773 0.439420
## lbwght 4.51843 5.41458 0.834 0.404171
## bwghtlbs NA NA NA NA
## packs NA NA NA NA
## lfaminc 20.87751 0.38522 54.196 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.142 on 1179 degrees of freedom
## (197 observations deleted due to missingness)
## Multiple R-squared: 0.7963, Adjusted R-squared: 0.7944
## F-statistic: 419 on 11 and 1179 DF, p-value: < 2.2e-16
model22 <- lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc + motheduc + motheduc + parity + male + white +
cigs + lbwght + bwghtlbs +packs +lfaminc, data = bwght)
summary(model22)
##
## Call:
## lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc +
## motheduc + motheduc + parity + male + white + cigs + lbwght +
## bwghtlbs + packs + lfaminc, data = bwght)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.348 -5.165 -3.064 2.014 55.458
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -70.20275 20.70144 -3.391 0.000719 ***
## cigtax -0.10012 0.06465 -1.549 0.121739
## cigprice 0.06165 0.04905 1.257 0.209052
## bwght -0.03950 0.05069 -0.779 0.435971
## fatheduc 0.51772 0.11582 4.470 8.57e-06 ***
## motheduc 0.28182 0.13184 2.138 0.032755 *
## parity -0.02661 0.27278 -0.098 0.922309
## male 0.06681 0.47654 0.140 0.888532
## white 0.75768 0.67676 1.120 0.263124
## cigs -0.03565 0.04609 -0.773 0.439420
## lbwght 4.51843 5.41458 0.834 0.404171
## bwghtlbs NA NA NA NA
## packs NA NA NA NA
## lfaminc 20.87751 0.38522 54.196 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.142 on 1179 degrees of freedom
## (197 observations deleted due to missingness)
## Multiple R-squared: 0.7963, Adjusted R-squared: 0.7944
## F-statistic: 419 on 11 and 1179 DF, p-value: < 2.2e-16
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
qplot(bwght$parity, bwght$male)
## Warning: `qplot()` was deprecated in ggplot2 3.4.0.
qplot(bwght$parity, bwght$male) + geom_smooth(method = "lm", se = F)
## `geom_smooth()` using formula = 'y ~ x'
library(wooldridge)
data("airquality")
summary(lm(lm(formula = faminc ~ cigtax + cigprice + bwght + fatheduc + motheduc + motheduc + parity + male + white +
cigs + lbwght + bwghtlbs +packs +lfaminc, data = bwght)))
##
## Call:
## lm(formula = lm(formula = faminc ~ cigtax + cigprice + bwght +
## fatheduc + motheduc + motheduc + parity + male + white +
## cigs + lbwght + bwghtlbs + packs + lfaminc, data = bwght))
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.348 -5.165 -3.064 2.014 55.458
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -70.20275 20.70144 -3.391 0.000719 ***
## cigtax -0.10012 0.06465 -1.549 0.121739
## cigprice 0.06165 0.04905 1.257 0.209052
## bwght -0.03950 0.05069 -0.779 0.435971
## fatheduc 0.51772 0.11582 4.470 8.57e-06 ***
## motheduc 0.28182 0.13184 2.138 0.032755 *
## parity -0.02661 0.27278 -0.098 0.922309
## male 0.06681 0.47654 0.140 0.888532
## white 0.75768 0.67676 1.120 0.263124
## cigs -0.03565 0.04609 -0.773 0.439420
## lbwght 4.51843 5.41458 0.834 0.404171
## bwghtlbs NA NA NA NA
## packs NA NA NA NA
## lfaminc 20.87751 0.38522 54.196 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.142 on 1179 degrees of freedom
## (197 observations deleted due to missingness)
## Multiple R-squared: 0.7963, Adjusted R-squared: 0.7944
## F-statistic: 419 on 11 and 1179 DF, p-value: < 2.2e-16
In our study with wanted to consider the impact of cigarette on the weight of newborn children. We see the corelation that can be noticed. This research is made by looking the monthly income of the mother and also the race of mother.
A data.frame with 1388 observations on 14 variables:
faminc: 1988 family income, $1000s
cigtax: cig. tax in home state, 1988
cigprice: cig. price in home state, 1988
bwght: birth weight, ounces
fatheduc: father’s yrs of educ
motheduc: mother’s yrs of educ
parity: birth order of child
male: =1 if male child
white: =1 if white
cigs: cigs smked per day while preg
lbwght: log of bwght
bwghtlbs: birth weight, pounds
packs: packs smked per day while preg
lfaminc: log(faminc) bwghti ≡ birth weight of newborn baby born to mother i, in grams; cigsi ≡ average number of cigarettes smoked per day during pregnancy by mother i Used in Text