library(wooldridge)
## Warning: package 'wooldridge' was built under R version 4.1.3
library(rmarkdown)
data(savings)
## Warning in data(savings): data set 'savings' not found
paged_table(saving)
summary(saving)
##       sav               inc             size            educ      
##  Min.   :-5577.0   Min.   :  750   Min.   : 2.00   Min.   : 2.00  
##  1st Qu.:  194.5   1st Qu.: 6510   1st Qu.: 3.00   1st Qu.: 9.00  
##  Median :  982.0   Median : 8776   Median : 4.00   Median :12.00  
##  Mean   : 1582.5   Mean   : 9941   Mean   : 4.35   Mean   :11.58  
##  3rd Qu.: 1834.8   3rd Qu.:11903   3rd Qu.: 5.00   3rd Qu.:13.00  
##  Max.   :25405.0   Max.   :32080   Max.   :10.00   Max.   :20.00  
##       age            black           cons       
##  Min.   :26.00   Min.   :0.00   Min.   :-13055  
##  1st Qu.:33.00   1st Qu.:0.00   1st Qu.:  5732  
##  Median :38.50   Median :0.00   Median :  7562  
##  Mean   :38.77   Mean   :0.07   Mean   :  8359  
##  3rd Qu.:44.00   3rd Qu.:0.00   3rd Qu.:  9864  
##  Max.   :54.00   Max.   :1.00   Max.   : 30280

lm(formula = sav~inc+size+educ+age+black+cons, data = saving)
## 
## Call:
## lm(formula = sav ~ inc + size + educ + age + black + cons, data = saving)
## 
## Coefficients:
## (Intercept)          inc         size         educ          age        black  
##   7.276e-12    1.000e+00   -2.328e-14   -1.750e-13    6.048e-14    4.514e-12  
##        cons  
##  -1.000e+00

standardizasyon

lm(scale(sav)~0+scale(inc)+scale(size)+scale(educ)+scale(age)+scale(cons),data = saving)
## 
## Call:
## lm(formula = scale(sav) ~ 0 + scale(inc) + scale(size) + scale(educ) + 
##     scale(age) + scale(cons), data = saving)
## 
## Coefficients:
##  scale(inc)  scale(size)  scale(educ)   scale(age)  scale(cons)  
##   1.700e+00    4.020e-17    1.297e-16    9.930e-18   -1.744e+00

yorum

bu eşitlik bizi şöyle gösteriyor yıllık gelirinde bir artiş meydana geldiğinde tasarrufta 1.7 artişi olacak bunanla birlikte aile boyutunda bir artiş tasarrufa 4.02 artırır eğitim ise 1.29 artişa sepeb olur ancak yıllık tüketim harcamalarinda bir artiş tasarrufta 1.744 bir azalişa neden olur.

##log

x2<- lm((sav)~log(inc)+size+age+log(educ)+(cons)+black, data = saving)
summary(x2)
## 
## Call:
## lm(formula = (sav) ~ log(inc) + size + age + log(educ) + (cons) + 
##     black, data = saving)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3274.6 -1071.7  -452.4   169.0  8513.9 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -5.204e+04  5.153e+03 -10.099  < 2e-16 ***
## log(inc)     6.416e+03  6.703e+02   9.572 1.65e-15 ***
## size        -1.167e+02  1.450e+02  -0.805    0.423    
## age          4.383e+01  3.185e+01   1.376    0.172    
## log(educ)   -1.972e+02  7.866e+02  -0.251    0.803    
## cons        -6.395e-01  5.518e-02 -11.590  < 2e-16 ***
## black        8.758e+02  8.636e+02   1.014    0.313    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2096 on 93 degrees of freedom
## Multiple R-squared:  0.6177, Adjusted R-squared:  0.593 
## F-statistic: 25.04 on 6 and 93 DF,  p-value: < 2.2e-16
anova(x2)
## Analysis of Variance Table
## 
## Response: (sav)
##           Df    Sum Sq   Mean Sq  F value    Pr(>F)    
## log(inc)   1  61651293  61651293  14.0376 0.0003107 ***
## size       1    372158    372158   0.0847 0.7716243    
## age        1    796910    796910   0.1815 0.6711129    
## log(educ)  1   4748654   4748654   1.0812 0.3011161    
## cons       1 587738578 587738578 133.8246 < 2.2e-16 ***
## black      1   4517257   4517257   1.0286 0.3131301    
## Residuals 93 408442746   4391857                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

##stargazer

model1<- lm(formula =sav~inc+age+educ, data = saving)
summary(model1)
## 
## Call:
## lm(formula = sav ~ inc + age + educ, data = saving)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -7340  -1153   -498    451  22634 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept) -995.12489 2390.34748  -0.416    0.678
## inc            0.10794    0.07071   1.527    0.130
## age           -3.58236   48.59161  -0.074    0.941
## educ         141.92262  113.84312   1.247    0.216
## 
## Residual standard error: 3199 on 96 degrees of freedom
## Multiple R-squared:  0.08041,    Adjusted R-squared:  0.05167 
## F-statistic: 2.798 on 3 and 96 DF,  p-value: 0.04421

##yorum bu durumda bakıldığında gelirdeki bir artiş tasarrufa 0.107 artiş neden olur,eğitim ise 141.92 bir artişi olacak, ancak yaştaki bir artişi tasarrufa 3.58 bir azalişa neden olur.

model2<- lm(formula =sav~inc+age+cons, data = saving)
summary(model2)
## 
## Call:
## lm(formula = sav ~ inc + age + cons, data = saving)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -1.93e-11 -5.92e-13 -2.05e-13  3.19e-13  3.55e-11 
## 
## Coefficients:
##               Estimate Std. Error    t value Pr(>|t|)    
## (Intercept)  5.821e-12  2.291e-12  2.540e+00   0.0127 *  
## inc          1.000e+00  1.384e-16  7.227e+15   <2e-16 ***
## age          5.426e-14  5.976e-14  9.080e-01   0.3661    
## cons        -1.000e+00  1.345e-16 -7.436e+15   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.249e-12 on 96 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 1.972e+31 on 3 and 96 DF,  p-value: < 2.2e-16

##yorum burda baktiğimizda gelirde bir artiş tasarrufa 1.00 bi artişi olacak, bununla birlikte yaş artiğinda tasarrufta 5.42 bir artişi olur, şayet tüketim harcamalarda bir artiş tasarrufa 1.00 bir azaliş gösterir.

model3<- lm(formula =sav~inc+size+cons, data = saving)
summary(model3)
## 
## Call:
## lm(formula = sav ~ inc + size + cons, data = saving)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -2.047e-11 -5.160e-13 -2.010e-13  7.400e-14  3.568e-11 
## 
## Coefficients:
##               Estimate Std. Error    t value Pr(>|t|)    
## (Intercept)  8.731e-12  1.619e-12  5.392e+00    5e-07 ***
## inc          1.000e+00  1.404e-16  7.123e+15   <2e-16 ***
## size        -1.231e-13  2.932e-13 -4.200e-01    0.676    
## cons        -1.000e+00  1.369e-16 -7.305e+15   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.33e-12 on 96 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 1.899e+31 on 3 and 96 DF,  p-value: < 2.2e-16

##yorum bu durumda da gelirde bir artiş olduğunda tasarrufta da 1.00 artiş olur, aile boyutunda bir artiş meydana gelirse tasarrufta 1.23 bir azaliş olacak, bununla birlikte tüketim harcamalarda bir artişi tasarrufa 1.00 bir azalişa sepeb olur.

stargazer::stargazer(model1,model2,model3, type = "text")
## 
## =============================================================================================================================================
##                                                                             Dependent variable:                                              
##                               ---------------------------------------------------------------------------------------------------------------
##                                                                                     sav                                                      
##                                   (1)                            (2)                                               (3)                       
## ---------------------------------------------------------------------------------------------------------------------------------------------
## inc                              0.108                        1.000***                                          1.000***                     
##                                 (0.071)                        (0.000)                                           (0.000)                     
##                                                                                                                                              
## age                             -3.582                          0.000                                                                        
##                                (48.592)                        (0.000)                                                                       
##                                                                                                                                              
## educ                            141.923                                                                                                      
##                                (113.843)                                                                                                     
##                                                                                                                                              
## size                                                                                                             -0.000                      
##                                                                                                                  (0.000)                     
##                                                                                                                                              
## cons                                                          -1.000***                                         -1.000***                    
##                                                                (0.000)                                           (0.000)                     
##                                                                                                                                              
## Constant                       -995.125                        0.000**                                          0.000***                     
##                               (2,390.347)                      (0.000)                                           (0.000)                     
##                                                                                                                                              
## ---------------------------------------------------------------------------------------------------------------------------------------------
## Observations                      100                            100                                               100                       
## R2                               0.080                          1.000                                             1.000                      
## Adjusted R2                      0.052                          1.000                                             1.000                      
## Residual Std. Error (df = 96)  3,198.910                        0.000                                             0.000                      
## F Statistic (df = 3; 96)        2.798**   19,721,230,461,319,009,982,424,668,602,660.000*** 18,994,891,856,087,826,118,828,200,666,486.000***
## =============================================================================================================================================
## Note:                                                                                                             *p<0.1; **p<0.05; ***p<0.01

##interceptli fonksiyonu

summary(lm(formula = sav~inc+size+educ+age+black+cons, data = saving))
## 
## Call:
## lm(formula = sav ~ inc + size + educ + age + black + cons, data = saving)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -1.980e-11 -5.037e-13  2.110e-14  6.543e-13  2.992e-11 
## 
## Coefficients:
##               Estimate Std. Error    t value Pr(>|t|)    
## (Intercept)  7.276e-12  3.556e-12  2.046e+00  0.04359 *  
## inc          1.000e+00  1.459e-16  6.852e+15  < 2e-16 ***
## size        -2.328e-14  2.798e-13 -8.300e-02  0.93386    
## educ        -1.750e-13  1.484e-13 -1.179e+00  0.24130    
## age          6.048e-14  6.275e-14  9.640e-01  0.33764    
## black        4.514e-12  1.642e-12  2.749e+00  0.00718 ** 
## cons        -1.000e+00  1.294e-16 -7.730e+15  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.049e-12 on 93 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 1.086e+31 on 6 and 93 DF,  p-value: < 2.2e-16

##interceptsiz fonksiyonu

summary(lm(formula = sav~inc+size+educ+age+black+cons-1, data = saving))
## Warning in summary.lm(lm(formula = sav ~ inc + size + educ + age + black + :
## essentially perfect fit: summary may be unreliable
## 
## Call:
## lm(formula = sav ~ inc + size + educ + age + black + cons - 1, 
##     data = saving)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -2.080e-12 -4.819e-13 -7.020e-14  4.106e-13  8.331e-12 
## 
## Coefficients:
##         Estimate Std. Error    t value Pr(>|t|)    
## inc    1.000e+00  4.322e-17  2.314e+16  < 2e-16 ***
## size   8.796e-14  7.344e-14  1.198e+00 0.234026    
## educ  -3.398e-14  3.495e-14 -9.720e-01 0.333509    
## age   -7.193e-15  1.037e-14 -6.940e-01 0.489582    
## black  1.857e-12  4.879e-13  3.806e+00 0.000251 ***
## cons  -1.000e+00  3.904e-17 -2.562e+16  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.224e-12 on 94 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 1.467e+32 on 6 and 94 DF,  p-value: < 2.2e-16