Introduction

The purpose of this report is to examine what factors influences the time of sleep. Our analysis will be based on a database “sleep75”, which was prepared by Jeff E.Biddle and Daniel S.Hamermesh, and used in their worked titled “Sleep and the Allocation of Time” from 1989. It is worth noting that the collected data come from the 1970s.

Introducing the data

Presentation of variable names and types

## Rows: 706
## Columns: 34
## $ age      <dbl> 32, 31, 44, 30, 64, 41, 35, 47, 32, 30, 43, 23, 24, 48, 33, 2~
## $ black    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ case     <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18~
## $ clerical <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ construc <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ educ     <dbl> 12, 14, 17, 12, 14, 12, 12, 13, 17, 15, 8, 16, 16, 5, 12, 12,~
## $ earns74  <dbl> 0, 9500, 42500, 42500, 2500, 0, 8250, 0, 18750, 11750, 21250,~
## $ gdhlth   <dbl> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1~
## $ inlf     <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~
## $ leis1    <dbl> 3529, 2140, 4595, 3211, 4052, 4812, 4787, 3544, 4359, 4211, 2~
## $ leis2    <dbl> 3479, 2140, 4505, 3211, 4007, 4797, 4157, 3469, 4359, 4061, 1~
## $ leis3    <dbl> 3479, 2140, 4227, 3211, 4007, 4797, 4157, 3439, 4121, 4061, 1~
## $ smsa     <dbl> 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1~
## $ lhrwage  <chr> "1.9558610000000001", "0.35767399999999999", "3.021887", "2.2~
## $ lothinc  <dbl> 10.075380, 0.000000, 0.000000, 0.000000, 9.328213, 10.657280,~
## $ male     <dbl> 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1~
## $ marr     <dbl> 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0~
## $ prot     <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0~
## $ rlxall   <dbl> 3163, 2920, 3038, 3083, 3493, 4078, 3810, 3033, 3606, 3168, 1~
## $ selfe    <dbl> 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1~
## $ sleep    <dbl> 3113, 2920, 2670, 3083, 3448, 4063, 3180, 2928, 3368, 3018, 1~
## $ slpnaps  <dbl> 3163, 2920, 2760, 3083, 3493, 4078, 3810, 3003, 3368, 3168, 1~
## $ south    <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ spsepay  <dbl> 0, 0, 20000, 5000, 2400, 0, 12000, 0, 0, 6000, 0, 3000, 3000,~
## $ spwrk75  <dbl> 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0~
## $ totwrk   <dbl> 3438, 5020, 2815, 3786, 2580, 1205, 2113, 3608, 2353, 2851, 6~
## $ union    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ worknrm  <dbl> 3438, 5020, 2815, 3786, 2580, 0, 2113, 3608, 2353, 2851, 6415~
## $ workscnd <dbl> 0, 0, 0, 0, 0, 1205, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ exper    <dbl> 14, 11, 21, 12, 44, 23, 17, 28, 9, 9, 29, 1, 2, 37, 15, 5, 23~
## $ yngkid   <dbl> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0~
## $ yrsmarr  <dbl> 13, 0, 0, 12, 33, 23, 0, 24, 11, 7, 23, 4, 4, 0, 9, 4, 21, 17~
## $ hrwage   <chr> "7.070004", "1.429999", "20.530000000000001", "9.619998000000~
## $ agesq    <dbl> 1024, 961, 1936, 900, 4096, 1681, 1225, 2209, 1024, 900, 1849~
##       age            black              case          clerical     
##  Min.   :23.00   Min.   :0.00000   Min.   :  1.0   Min.   :0.0000  
##  1st Qu.:29.00   1st Qu.:0.00000   1st Qu.:177.2   1st Qu.:0.0000  
##  Median :36.00   Median :0.00000   Median :353.5   Median :0.0000  
##  Mean   :38.82   Mean   :0.04958   Mean   :353.5   Mean   :0.1823  
##  3rd Qu.:48.00   3rd Qu.:0.00000   3rd Qu.:529.8   3rd Qu.:0.1823  
##  Max.   :65.00   Max.   :1.00000   Max.   :706.0   Max.   :1.0000  
##     construc            educ          earns74          gdhlth      
##  Min.   :0.00000   Min.   : 1.00   Min.   :    0   Min.   :0.0000  
##  1st Qu.:0.00000   1st Qu.:12.00   1st Qu.: 2500   1st Qu.:1.0000  
##  Median :0.00000   Median :12.00   Median : 8250   Median :1.0000  
##  Mean   :0.03008   Mean   :12.78   Mean   : 9768   Mean   :0.8909  
##  3rd Qu.:0.03008   3rd Qu.:16.00   3rd Qu.:13750   3rd Qu.:1.0000  
##  Max.   :1.00000   Max.   :17.00   Max.   :42500   Max.   :1.0000  
##       inlf            leis1          leis2          leis3           smsa       
##  Min.   :0.0000   Min.   :1745   Min.   :1677   Min.   :1677   Min.   :0.0000  
##  1st Qu.:1.0000   1st Qu.:4110   1st Qu.:3986   1st Qu.:3933   1st Qu.:0.0000  
##  Median :1.0000   Median :4620   Median :4519   Median :4469   Median :0.0000  
##  Mean   :0.7535   Mean   :4691   Mean   :4574   Mean   :4519   Mean   :0.3994  
##  3rd Qu.:1.0000   3rd Qu.:5204   3rd Qu.:5071   3rd Qu.:5028   3rd Qu.:1.0000  
##  Max.   :1.0000   Max.   :7417   Max.   :7297   Max.   :7282   Max.   :1.0000  
##    lhrwage             lothinc            male             marr       
##  Length:706         Min.   : 0.000   Min.   :0.0000   Min.   :0.0000  
##  Class :character   1st Qu.: 0.000   1st Qu.:0.0000   1st Qu.:1.0000  
##  Mode  :character   Median : 8.613   Median :1.0000   Median :1.0000  
##                     Mean   : 6.228   Mean   :0.5666   Mean   :0.8215  
##                     3rd Qu.: 9.328   3rd Qu.:1.0000   3rd Qu.:1.0000  
##                     Max.   :10.657   Max.   :1.0000   Max.   :1.0000  
##       prot            rlxall         selfe            sleep         slpnaps    
##  Min.   :0.0000   Min.   :1380   Min.   :0.0000   Min.   : 755   Min.   :1335  
##  1st Qu.:0.0000   1st Qu.:3150   1st Qu.:0.0000   1st Qu.:3015   1st Qu.:3106  
##  Median :1.0000   Median :3428   Median :0.0000   Median :3270   Median :3369  
##  Mean   :0.6629   Mean   :3438   Mean   :0.1317   Mean   :3266   Mean   :3383  
##  3rd Qu.:1.0000   3rd Qu.:3720   3rd Qu.:0.0000   3rd Qu.:3532   3rd Qu.:3655  
##  Max.   :1.0000   Max.   :6110   Max.   :1.0000   Max.   :4695   Max.   :6110  
##      south           spsepay         spwrk75           totwrk    
##  Min.   :0.0000   Min.   :    0   Min.   :0.0000   Min.   :   0  
##  1st Qu.:0.0000   1st Qu.:    0   1st Qu.:0.0000   1st Qu.:1554  
##  Median :0.0000   Median :    0   Median :0.0000   Median :2288  
##  Mean   :0.1841   Mean   : 5144   Mean   :0.4802   Mean   :2123  
##  3rd Qu.:0.0000   3rd Qu.: 8900   3rd Qu.:1.0000   3rd Qu.:2692  
##  Max.   :1.0000   Max.   :75000   Max.   :1.0000   Max.   :6415  
##      union           worknrm        workscnd           exper      
##  Min.   :0.0000   Min.   :   0   Min.   :   0.00   Min.   : 0.00  
##  1st Qu.:0.0000   1st Qu.:1538   1st Qu.:   0.00   1st Qu.:10.00  
##  Median :0.0000   Median :2275   Median :   0.00   Median :17.00  
##  Mean   :0.2181   Mean   :2093   Mean   :  29.67   Mean   :20.04  
##  3rd Qu.:0.0000   3rd Qu.:2636   3rd Qu.:   0.00   3rd Qu.:30.00  
##  Max.   :1.0000   Max.   :6415   Max.   :1337.00   Max.   :55.00  
##      yngkid          yrsmarr         hrwage              agesq     
##  Min.   :0.0000   Min.   : 0.00   Length:706         Min.   : 529  
##  1st Qu.:0.0000   1st Qu.: 0.00   Class :character   1st Qu.: 841  
##  Median :0.0000   Median : 9.00   Mode  :character   Median :1296  
##  Mean   :0.1289   Mean   :11.77                      Mean   :1635  
##  3rd Qu.:0.0000   3rd Qu.:20.00                      3rd Qu.:2304  
##  Max.   :1.0000   Max.   :43.00                      Max.   :4225

Actions taken to facilitate the work on the database

# Making sure that there is no empty values or duplicated
sum(is.na(sleep75))
## [1] 0
sum(duplicated(sleep75))
## [1] 0
# Removing identifier
sleep75 <- sleep75 %>%
  select(-case)

# Creating useful subsets
sleep75_no_chr <- sleep75 %>%
  select(-hrwage, -lhrwage)
sleep75_no_logical <- sleep75_no_chr%>%
  select(-black, -clerical, -construc, -gdhlth, -inlf, -smsa, -male, -marr, -selfe, -south, -spwrk75, -union, -yngkid)

Let’s take a look at the correlation plot to quickly find correlation between variables

We can observe over 10 strong correlation, but but in reality they are caused by dependence on other variables. They will be deleted to avoid multicollinearity.

This correlation plot shows correlations without problematic variables:

Sleep duration study

Correlation plot did not show any strong correlation, so let’s find out what may influence a sleep time.

Here we present a plot that illustrates the strongest correlation. Let’s see how sleep time is depends on the working time:

cor(totwrk, sleep)
## [1] -0.3213835

A negative correlation, but it’s not so strong

Because total working time has the biggest influence on the time of sleep, we may examine what effects the time of work.

Work duration study

On the correlation plot we can see what variables have a slight correlation with the total working time. Let’s take a closer look to that relationships.

At this point we should remove a serious outlier - one gentleman has been working for more than 6000 hours. We hope he had a great vacation.

sleep75_removed_man_outlier <- sleep75 %>%
  filter(totwrk < 6000)

Again, let’s take a look:

And correlation:

cor(sleep75_removed_man_outlier$male, sleep75_removed_man_outlier$totwrk)
## [1] 0.3765647

This correlation is also not so strong, but we can state, that in the 70s men were more likely to work longer than women.

We may try to create an linear model which describes how sex, time of sleep and spousal wage income (including interatcions between them) are influencing the time of work. Below model anylysis is presented.

summary(totwrk_lm)
## 
## Call:
## lm(formula = totwrk ~ male * sleep * spsepay)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2610.88  -493.00    61.12   530.51  2806.09 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         3.453e+03  4.252e+02   8.122 2.08e-15 ***
## male                1.270e+03  5.539e+02   2.293 0.022119 *  
## sleep              -4.954e-01  1.289e-01  -3.844 0.000132 ***
## spsepay             1.964e-02  3.589e-02   0.547 0.584441    
## male:sleep         -2.124e-01  1.682e-01  -1.263 0.206958    
## male:spsepay        1.956e-02  9.220e-02   0.212 0.832030    
## sleep:spsepay      -9.966e-06  1.094e-05  -0.911 0.362505    
## male:sleep:spsepay -6.750e-07  2.847e-05  -0.024 0.981090    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 825.8 on 698 degrees of freedom
## Multiple R-squared:  0.2479, Adjusted R-squared:  0.2403 
## F-statistic: 32.86 on 7 and 698 DF,  p-value: < 2.2e-16

As we can see: working time model is far from being perfect. Residuals vs Fitted and Normal Q-Q plot does not show any serious problem, but the other two does. Especially Residuals vs Leverage. Adjusted R-squared of 0.24 is also not a great result. Now let’s examine factors affecting earnings as it is somewhat related to working time.

Income study

Take a look at correlation plot:

Let’s dive into the analysis of the potential correlations. Plot below describes othinc’s score impact on total earnings in ’74

cor(lothinc, earns74)
## [1] -0.3209126

We can observe a slight negative correlation, that factor should be used while creating linear model of earnings in ’74.

Plot below shows relationship between Education score, othinc score, total earnings in ’74 and what is more - it is grouped by sex:

No further conclusion can be estimated, relationship is not so strong. But still, we can observe that 5 people with 0 othinc score has had the biggest income - and 4 of them are a man. It is worth noting that a higher education rate means statistically higher earnings. Othinc score seems to not have a much impact on education score.

Here we can see those relations on 2d plots:

Let’s check if spousal income is and important factor:

cor(spsepay, earns74)
## [1] 0.2433129

Correlation is only 0.24, but it is worth to include this factor into the model. But before that - let’s see if the stereotype is true:

cor(totwrk, earns74)
## [1] 0.1158009

This correlation is to low to state that if you work more you earn more. It’s not true based on this data base.

Constructing linear model of earnings - othincs score, sex, education score, smsa variable, spousal wage income, total work and interactions between them are included.

summary(earnings_lm)
## 
## Call:
## lm(formula = earns74 ~ lothinc * male * educ * smsa * spsepay * 
##     totwrk)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -19159.9  -4117.9   -836.6   3158.2  29125.7 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                 8.600e+03  7.506e+03   1.146
## lothinc                                    -6.827e+02  1.488e+03  -0.459
## maleWoman                                  -2.846e+04  1.151e+04  -2.474
## educ                                       -1.740e+01  6.794e+02  -0.026
## smsa                                       -1.765e+04  1.767e+04  -0.999
## spsepay                                     1.122e+01  9.994e+00   1.123
## totwrk                                     -1.631e+00  2.881e+00  -0.566
## lothinc:maleWoman                           3.150e+03  2.011e+03   1.566
## lothinc:educ                                3.735e+01  1.284e+02   0.291
## maleWoman:educ                              2.411e+03  9.949e+02   2.423
## lothinc:smsa                               -3.067e+02  3.394e+03  -0.090
## maleWoman:smsa                              4.719e+04  2.489e+04   1.896
## educ:smsa                                   1.979e+03  1.385e+03   1.429
## lothinc:spsepay                            -1.677e+00  1.177e+00  -1.425
## maleWoman:spsepay                          -1.305e+01  1.015e+01  -1.286
## educ:spsepay                               -6.796e-01  7.758e-01  -0.876
## smsa:spsepay                               -1.571e+01  1.028e+01  -1.528
## lothinc:totwrk                             -2.848e-01  5.955e-01  -0.478
## maleWoman:totwrk                            1.127e+01  5.259e+00   2.143
## educ:totwrk                                 3.017e-01  2.664e-01   1.132
## smsa:totwrk                                 6.621e+00  7.372e+00   0.898
## spsepay:totwrk                             -3.197e-03  3.412e-03  -0.937
## lothinc:maleWoman:educ                     -3.067e+02  1.699e+02  -1.805
## lothinc:maleWoman:smsa                     -2.969e+03  4.310e+03  -0.689
## lothinc:educ:smsa                          -5.712e+01  2.628e+02  -0.217
## maleWoman:educ:smsa                        -4.928e+03  2.044e+03  -2.411
## lothinc:maleWoman:spsepay                   1.839e+00  1.196e+00   1.538
## lothinc:educ:spsepay                        1.145e-01  9.124e-02   1.255
## maleWoman:educ:spsepay                      8.230e-01  7.834e-01   1.051
## lothinc:smsa:spsepay                        2.461e+00  1.284e+00   1.916
## maleWoman:smsa:spsepay                      1.963e+01  1.060e+01   1.851
## educ:smsa:spsepay                           1.094e+00  8.008e-01   1.366
## lothinc:maleWoman:totwrk                   -9.335e-01  9.155e-01  -1.020
## lothinc:educ:totwrk                         1.265e-03  5.095e-02   0.025
## maleWoman:educ:totwrk                      -1.188e+00  4.473e-01  -2.655
## lothinc:smsa:totwrk                        -4.598e-02  1.343e+00  -0.034
## maleWoman:smsa:totwrk                      -1.760e+01  1.178e+01  -1.494
## educ:smsa:totwrk                           -7.184e-01  5.731e-01  -1.254
## lothinc:spsepay:totwrk                      6.254e-04  4.104e-04   1.524
## maleWoman:spsepay:totwrk                    4.954e-03  3.522e-03   1.406
## educ:spsepay:totwrk                         2.169e-04  2.718e-04   0.798
## smsa:spsepay:totwrk                         6.156e-03  3.639e-03   1.692
## lothinc:maleWoman:educ:smsa                 4.141e+02  3.384e+02   1.224
## lothinc:maleWoman:educ:spsepay             -1.255e-01  9.223e-02  -1.361
## lothinc:maleWoman:smsa:spsepay             -2.964e+00  1.324e+00  -2.239
## lothinc:educ:smsa:spsepay                  -1.747e-01  9.858e-02  -1.773
## maleWoman:educ:smsa:spsepay                -1.345e+00  8.165e-01  -1.647
## lothinc:maleWoman:educ:totwrk               1.257e-01  7.593e-02   1.656
## lothinc:maleWoman:smsa:totwrk               1.184e+00  1.890e+00   0.626
## lothinc:educ:smsa:totwrk                    3.010e-02  1.039e-01   0.290
## maleWoman:educ:smsa:totwrk                  1.872e+00  9.848e-01   1.901
## lothinc:maleWoman:spsepay:totwrk           -8.113e-04  4.235e-04  -1.915
## lothinc:educ:spsepay:totwrk                -4.543e-05  3.258e-05  -1.395
## maleWoman:educ:spsepay:totwrk              -3.190e-04  2.773e-04  -1.150
## lothinc:smsa:spsepay:totwrk                -9.516e-04  4.689e-04  -2.029
## maleWoman:smsa:spsepay:totwrk              -9.702e-03  4.183e-03  -2.320
## educ:smsa:spsepay:totwrk                   -4.157e-04  2.871e-04  -1.448
## lothinc:maleWoman:educ:smsa:spsepay         2.068e-01  1.007e-01   2.054
## lothinc:maleWoman:educ:smsa:totwrk         -1.613e-01  1.509e-01  -1.069
## lothinc:maleWoman:educ:spsepay:totwrk       5.588e-05  3.326e-05   1.680
## lothinc:maleWoman:smsa:spsepay:totwrk       1.398e-03  5.246e-04   2.665
## lothinc:educ:smsa:spsepay:totwrk            6.688e-05  3.634e-05   1.841
## maleWoman:educ:smsa:spsepay:totwrk          6.859e-04  3.188e-04   2.152
## lothinc:maleWoman:educ:smsa:spsepay:totwrk -1.003e-04  3.962e-05  -2.531
##                                            Pr(>|t|)   
## (Intercept)                                 0.25235   
## lothinc                                     0.64644   
## maleWoman                                   0.01363 * 
## educ                                        0.97957   
## smsa                                        0.31812   
## spsepay                                     0.26186   
## totwrk                                      0.57147   
## lothinc:maleWoman                           0.11774   
## lothinc:educ                                0.77128   
## maleWoman:educ                              0.01567 * 
## lothinc:smsa                                0.92803   
## maleWoman:smsa                              0.05842 . 
## educ:smsa                                   0.15356   
## lothinc:spsepay                             0.15470   
## maleWoman:spsepay                           0.19897   
## educ:spsepay                                0.38141   
## smsa:spsepay                                0.12709   
## lothinc:totwrk                              0.63262   
## maleWoman:totwrk                            0.03251 * 
## educ:totwrk                                 0.25788   
## smsa:totwrk                                 0.36947   
## spsepay:totwrk                              0.34911   
## lothinc:maleWoman:educ                      0.07150 . 
## lothinc:maleWoman:smsa                      0.49120   
## lothinc:educ:smsa                           0.82799   
## maleWoman:educ:smsa                         0.01621 * 
## lothinc:maleWoman:spsepay                   0.12451   
## lothinc:educ:spsepay                        0.20979   
## maleWoman:educ:spsepay                      0.29384   
## lothinc:smsa:spsepay                        0.05580 . 
## maleWoman:smsa:spsepay                      0.06457 . 
## educ:smsa:spsepay                           0.17249   
## lothinc:maleWoman:totwrk                    0.30826   
## lothinc:educ:totwrk                         0.98020   
## maleWoman:educ:totwrk                       0.00812 **
## lothinc:smsa:totwrk                         0.97271   
## maleWoman:smsa:totwrk                       0.13567   
## educ:smsa:totwrk                            0.21048   
## lothinc:spsepay:totwrk                      0.12805   
## maleWoman:spsepay:totwrk                    0.16007   
## educ:spsepay:totwrk                         0.42510   
## smsa:spsepay:totwrk                         0.09119 . 
## lothinc:maleWoman:educ:smsa                 0.22153   
## lothinc:maleWoman:educ:spsepay              0.17404   
## lothinc:maleWoman:smsa:spsepay              0.02552 * 
## lothinc:educ:smsa:spsepay                   0.07676 . 
## maleWoman:educ:smsa:spsepay                 0.10010   
## lothinc:maleWoman:educ:totwrk               0.09829 . 
## lothinc:maleWoman:smsa:totwrk               0.53139   
## lothinc:educ:smsa:totwrk                    0.77206   
## maleWoman:educ:smsa:totwrk                  0.05775 . 
## lothinc:maleWoman:spsepay:totwrk            0.05588 . 
## lothinc:educ:spsepay:totwrk                 0.16362   
## maleWoman:educ:spsepay:totwrk               0.25037   
## lothinc:smsa:spsepay:totwrk                 0.04283 * 
## maleWoman:smsa:spsepay:totwrk               0.02067 * 
## educ:smsa:spsepay:totwrk                    0.14814   
## lothinc:maleWoman:educ:smsa:spsepay         0.04036 * 
## lothinc:maleWoman:educ:smsa:totwrk          0.28535   
## lothinc:maleWoman:educ:spsepay:totwrk       0.09346 . 
## lothinc:maleWoman:smsa:spsepay:totwrk       0.00790 **
## lothinc:educ:smsa:spsepay:totwrk            0.06614 . 
## maleWoman:educ:smsa:spsepay:totwrk          0.03178 * 
## lothinc:maleWoman:educ:smsa:spsepay:totwrk  0.01162 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7221 on 642 degrees of freedom
## Multiple R-squared:  0.4537, Adjusted R-squared:  0.4001 
## F-statistic: 8.465 on 63 and 642 DF,  p-value: < 2.2e-16

Adjusted R-squared is satisfactory - but still far from 1.00. Plot analysis shows how hard it is to present a good model of earnings, basically any of them is not great.

Other interesting correlations

Correlation between othinc score an marrige:

cor(lothinc, marr)
## [1] 0.3637086

More men have higher othinc score:

Sometimes only one person in marriage works:

cor(marr, spwrk75) 
## [1] 0.4405547

Constructing linear model of sleep time

Take a look at this plot visualizing the most important factors of linear model that is about to be created:

Do older people sleep longer? The answear is yes, they do:

Finally, a linear model:

summary(sleep_lm)
## 
## Call:
## lm(formula = sleep ~ totwrk * lothinc * spsepay * gdhlth * age)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2397.73  -240.68     7.23   260.09  1347.37 
## 
## Coefficients:
##                                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                        3.767e+03  6.520e+02   5.778 1.16e-08 ***
## totwrk                            -1.839e-01  3.163e-01  -0.581    0.561    
## lothinc                           -4.899e+01  1.215e+02  -0.403    0.687    
## spsepay                           -9.681e-01  6.553e-01  -1.477    0.140    
## gdhlth                            -5.528e+02  7.153e+02  -0.773    0.440    
## age                                2.081e+00  1.439e+01   0.145    0.885    
## totwrk:lothinc                     1.154e-02  5.356e-02   0.215    0.829    
## totwrk:spsepay                    -8.544e-05  4.276e-04  -0.200    0.842    
## lothinc:spsepay                    9.854e-02  7.321e-02   1.346    0.179    
## totwrk:gdhlth                      1.672e-01  3.409e-01   0.490    0.624    
## lothinc:gdhlth                     5.940e+01  1.295e+02   0.459    0.647    
## spsepay:gdhlth                     9.905e-01  6.561e-01   1.510    0.132    
## totwrk:age                         4.629e-04  6.884e-03   0.067    0.946    
## lothinc:age                        5.762e-01  2.443e+00   0.236    0.814    
## spsepay:age                        3.802e-02  2.691e-02   1.413    0.158    
## gdhlth:age                         5.805e+00  1.598e+01   0.363    0.717    
## totwrk:lothinc:spsepay             1.592e-05  4.763e-05   0.334    0.738    
## totwrk:lothinc:gdhlth             -1.884e-02  5.690e-02  -0.331    0.741    
## totwrk:spsepay:gdhlth              8.027e-05  4.278e-04   0.188    0.851    
## lothinc:spsepay:gdhlth            -9.785e-02  7.335e-02  -1.334    0.183    
## totwrk:lothinc:age                -9.366e-05  1.111e-03  -0.084    0.933    
## totwrk:spsepay:age                -5.135e-06  1.496e-05  -0.343    0.732    
## lothinc:spsepay:age               -4.123e-03  2.981e-03  -1.383    0.167    
## totwrk:gdhlth:age                 -3.708e-03  7.551e-03  -0.491    0.623    
## lothinc:gdhlth:age                -5.339e-01  2.661e+00  -0.201    0.841    
## spsepay:gdhlth:age                -3.863e-02  2.693e-02  -1.434    0.152    
## totwrk:lothinc:spsepay:gdhlth     -1.612e-05  4.767e-05  -0.338    0.735    
## totwrk:lothinc:spsepay:age         4.508e-07  1.633e-06   0.276    0.783    
## totwrk:lothinc:gdhlth:age          2.241e-04  1.204e-03   0.186    0.852    
## totwrk:spsepay:gdhlth:age          5.309e-06  1.496e-05   0.355    0.723    
## lothinc:spsepay:gdhlth:age         4.097e-03  2.984e-03   1.373    0.170    
## totwrk:lothinc:spsepay:gdhlth:age -4.479e-07  1.634e-06  -0.274    0.784    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 416.5 on 674 degrees of freedom
## Multiple R-squared:  0.1605, Adjusted R-squared:  0.1219 
## F-statistic: 4.156 on 31 and 674 DF,  p-value: 1.791e-12

R-squared is very low. Residuals vs Fitted looks great, Normal Q-Q is also fine, but troubles begin in the Scale-Location plot. Residuals vs Leverage shows that sleep time is hard to predict, even if that many factors are included.

Conclusion

Due to the low correlation coefficients, it is difficult to tell what influences sleep time. The only real factor affecting sleep time seems to be working time. It is therefore worth taking into account the factors affecting working time and other reports presented throughout the report. Thank you for your attention!