Çeşitli Regresyon Modelleri

1.Model

Çoklu regresyon modeli

library(wooldridge) 
library(rmarkdown) 
data("fertil1")
paged_table(fertil1)
require(dplyr)
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
model1 <- lm(kids ~ educ + age + I(age^2) + black + east + northcen + west + farm + othrural + town + smcity + y74 + y76 + y78 + y80 + y82 + y84 -1 , data = fertil1)

y72 kukla değişkeni oluşturma

benimdata <- fertil1 %>%
  mutate(y72 = ifelse (year == 72, 1, 0) )

3.Model

model3 <- lm(kids ~ educ + age + I(age^2) + black + east + northcen + west + farm + othrural + town + smcity + y74 + y76 + y78 + y80 + y82 + y84 , data = benimdata)
summary(model3)
## 
## Call:
## lm(formula = kids ~ educ + age + I(age^2) + black + east + northcen + 
##     west + farm + othrural + town + smcity + y74 + y76 + y78 + 
##     y80 + y82 + y84, data = benimdata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9878 -1.0086 -0.0767  0.9331  4.6548 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -7.742457   3.051767  -2.537 0.011315 *  
## educ        -0.128427   0.018349  -6.999 4.44e-12 ***
## age          0.532135   0.138386   3.845 0.000127 ***
## I(age^2)    -0.005804   0.001564  -3.710 0.000217 ***
## black        1.075658   0.173536   6.198 8.02e-10 ***
## east         0.217324   0.132788   1.637 0.101992    
## northcen     0.363114   0.120897   3.004 0.002729 ** 
## west         0.197603   0.166913   1.184 0.236719    
## farm        -0.052557   0.147190  -0.357 0.721105    
## othrural    -0.162854   0.175442  -0.928 0.353481    
## town         0.084353   0.124531   0.677 0.498314    
## smcity       0.211879   0.160296   1.322 0.186507    
## y74          0.268183   0.172716   1.553 0.120771    
## y76         -0.097379   0.179046  -0.544 0.586633    
## y78         -0.068666   0.181684  -0.378 0.705544    
## y80         -0.071305   0.182771  -0.390 0.696511    
## y82         -0.522484   0.172436  -3.030 0.002502 ** 
## y84         -0.545166   0.174516  -3.124 0.001831 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.555 on 1111 degrees of freedom
## Multiple R-squared:  0.1295, Adjusted R-squared:  0.1162 
## F-statistic: 9.723 on 17 and 1111 DF,  p-value: < 2.2e-16

4.Model

model4 <- lm(kids ~ educ + age + I(age^2) + black + east + northcen + west + farm + othrural + town + smcity + y74 + y76 + y78 + y80 + y82 + y84 -1 , data = benimdata)
summary(model4)
## 
## Call:
## lm(formula = kids ~ educ + age + I(age^2) + black + east + northcen + 
##     west + farm + othrural + town + smcity + y74 + y76 + y78 + 
##     y80 + y82 + y84 - 1, data = benimdata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.2448 -1.0353 -0.0694  0.9946  4.7341 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## educ     -0.1341968  0.0182516  -7.353 3.76e-13 ***
## age       0.1832921  0.0156775  11.691  < 2e-16 ***
## I(age^2) -0.0018827  0.0002414  -7.799 1.43e-14 ***
## black     1.0533749  0.1737363   6.063 1.83e-09 ***
## east      0.2126060  0.1330990   1.597  0.11047    
## northcen  0.3497407  0.1210768   2.889  0.00394 ** 
## west      0.1723021  0.1670220   1.032  0.30248    
## farm     -0.0631578  0.1474899  -0.428  0.66858    
## othrural -0.1741518  0.1758137  -0.991  0.32212    
## town      0.0806074  0.1248263   0.646  0.51857    
## smcity    0.2160143  0.1606790   1.344  0.17910    
## y74       0.2345327  0.1726265   1.359  0.17454    
## y76      -0.1426876  0.1785877  -0.799  0.42447    
## y78      -0.1095388  0.1814099  -0.604  0.54609    
## y80      -0.0974441  0.1829256  -0.533  0.59435    
## y82      -0.5564083  0.1723366  -3.229  0.00128 ** 
## y84      -0.5913773  0.1739868  -3.399  0.00070 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.559 on 1112 degrees of freedom
## Multiple R-squared:  0.7667, Adjusted R-squared:  0.7632 
## F-statistic:   215 on 17 and 1112 DF,  p-value: < 2.2e-16
benimdata2 <- benimdata %>%
  mutate(sbt = 1)

5. Model

model5 <- lm(kids ~ educ + age + I(age^2) + black + east + northcen + west + farm + othrural + town + smcity + y74 + y76 + y78 + y80 + y82 + y84 -1 -sbt , data = benimdata2)
summary(model5)
## 
## Call:
## lm(formula = kids ~ educ + age + I(age^2) + black + east + northcen + 
##     west + farm + othrural + town + smcity + y74 + y76 + y78 + 
##     y80 + y82 + y84 - 1 - sbt, data = benimdata2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.2448 -1.0353 -0.0694  0.9946  4.7341 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## educ     -0.1341968  0.0182516  -7.353 3.76e-13 ***
## age       0.1832921  0.0156775  11.691  < 2e-16 ***
## I(age^2) -0.0018827  0.0002414  -7.799 1.43e-14 ***
## black     1.0533749  0.1737363   6.063 1.83e-09 ***
## east      0.2126060  0.1330990   1.597  0.11047    
## northcen  0.3497407  0.1210768   2.889  0.00394 ** 
## west      0.1723021  0.1670220   1.032  0.30248    
## farm     -0.0631578  0.1474899  -0.428  0.66858    
## othrural -0.1741518  0.1758137  -0.991  0.32212    
## town      0.0806074  0.1248263   0.646  0.51857    
## smcity    0.2160143  0.1606790   1.344  0.17910    
## y74       0.2345327  0.1726265   1.359  0.17454    
## y76      -0.1426876  0.1785877  -0.799  0.42447    
## y78      -0.1095388  0.1814099  -0.604  0.54609    
## y80      -0.0974441  0.1829256  -0.533  0.59435    
## y82      -0.5564083  0.1723366  -3.229  0.00128 ** 
## y84      -0.5913773  0.1739868  -3.399  0.00070 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.559 on 1112 degrees of freedom
## Multiple R-squared:  0.7667, Adjusted R-squared:  0.7632 
## F-statistic:   215 on 17 and 1112 DF,  p-value: < 2.2e-16
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
stargazer(model4, model5, type = 'text')
## 
## ============================================================
##                                     Dependent variable:     
##                                 ----------------------------
##                                             kids            
##                                      (1)            (2)     
## ------------------------------------------------------------
## educ                              -0.134***      -0.134***  
##                                    (0.018)        (0.018)   
##                                                             
## age                                0.183***      0.183***   
##                                    (0.016)        (0.016)   
##                                                             
## I(age2)                           -0.002***      -0.002***  
##                                    (0.0002)      (0.0002)   
##                                                             
## black                              1.053***      1.053***   
##                                    (0.174)        (0.174)   
##                                                             
## east                                0.213          0.213    
##                                    (0.133)        (0.133)   
##                                                             
## northcen                           0.350***      0.350***   
##                                    (0.121)        (0.121)   
##                                                             
## west                                0.172          0.172    
##                                    (0.167)        (0.167)   
##                                                             
## farm                                -0.063        -0.063    
##                                    (0.147)        (0.147)   
##                                                             
## othrural                            -0.174        -0.174    
##                                    (0.176)        (0.176)   
##                                                             
## town                                0.081          0.081    
##                                    (0.125)        (0.125)   
##                                                             
## smcity                              0.216          0.216    
##                                    (0.161)        (0.161)   
##                                                             
## y74                                 0.235          0.235    
##                                    (0.173)        (0.173)   
##                                                             
## y76                                 -0.143        -0.143    
##                                    (0.179)        (0.179)   
##                                                             
## y78                                 -0.110        -0.110    
##                                    (0.181)        (0.181)   
##                                                             
## y80                                 -0.097        -0.097    
##                                    (0.183)        (0.183)   
##                                                             
## y82                               -0.556***      -0.556***  
##                                    (0.172)        (0.172)   
##                                                             
## y84                               -0.591***      -0.591***  
##                                    (0.174)        (0.174)   
##                                                             
## ------------------------------------------------------------
## Observations                        1,129          1,129    
## R2                                  0.767          0.767    
## Adjusted R2                         0.763          0.763    
## Residual Std. Error (df = 1112)     1.559          1.559    
## F Statistic (df = 17; 1112)       215.005***    215.005***  
## ============================================================
## Note:                            *p<0.1; **p<0.05; ***p<0.01