Exploring the effect of gender, education and age on healthy lifestyles

Questions:

  1. Which gender is more likely to live a healthier lifestyle, males or females?
  2. Does educational attainment have an effect on an individual’s health?
  3. Does aging prompt someone to identify has healthy or not?

Dataset used for the Analysis

The dataset for this assignment was obtained from Kaggle. The link for the dataset is https://www.kaggle.com/miroslavsabo/young-people-survey/version/2.

The author of this dataset is Miroslav Sabo and was first published on kaggle seven months ago. The second version of the same dataset was released four months ago and changed separators in CSV files and is also the version that will be utilized for the analyses and regressions in this assignment. In 2013, students in a statistics class from a university in the United Kingdom were asked to call in friends to participate in a survey. The Survey titled “Young People Survey” aimed to inquire the preferences, interests, habits and perceptions of the participants on many topics such as different phobias, their interest in academic subjects such as Mathematics and English, and their outlook and views on life. For this assignment, we wil be observing individuals’ and whether they reported living a healthy lifestyle.

library(nlme)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:nlme':
## 
##     collapse
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(magrittr)
library(tidyr)
## 
## Attaching package: 'tidyr'
## The following object is masked from 'package:magrittr':
## 
##     extract
library(haven)
library(lmerTest)
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
## 
##     expand
## Loading required package: lme4
## 
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
## 
##     lmList
## 
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
## 
##     lmer
## The following object is masked from 'package:stats':
## 
##     step
library(ggplot2)
library(texreg)
## Version:  1.36.23
## Date:     2017-03-03
## Author:   Philip Leifeld (University of Glasgow)
## 
## Please cite the JSS article in your publications -- see citation("texreg").
## 
## Attaching package: 'texreg'
## The following object is masked from 'package:tidyr':
## 
##     extract
## The following object is masked from 'package:magrittr':
## 
##     extract
library(readr)

ygresp <- read_csv("C:/Users/faahmed/Desktop/YR.csv", col_names = TRUE)
## Parsed with column specification:
## cols(
##   .default = col_integer(),
##   Smoking = col_character(),
##   Alcohol = col_character(),
##   Punctuality = col_character(),
##   Lying = col_character(),
##   `Internet usage` = col_character(),
##   Gender = col_character(),
##   `Left - right handed` = col_character(),
##   Education = col_character(),
##   `Only child` = col_character(),
##   `Village - town` = col_character(),
##   `House - block of flats` = col_character()
## )
## See spec(...) for full column specifications.
head(ygresp)
## # A tibble: 6 × 151
##   Music `Slow songs or fast songs` Dance  Folk Country `Classical music`
##   <int>                      <int> <int> <int>   <int>             <int>
## 1     5                          3     2     1       2                 2
## 2     4                          4     2     1       1                 1
## 3     5                          5     2     2       3                 4
## 4     5                          3     2     1       1                 1
## 5     5                          3     4     3       2                 4
## 6     5                          3     2     3       2                 3
## # ... with 145 more variables: Musical <int>, Pop <int>, Rock <int>,
## #   `Metal or Hardrock` <int>, Punk <int>, `Hiphop, Rap` <int>, `Reggae,
## #   Ska` <int>, `Swing, Jazz` <int>, `Rock n roll` <int>,
## #   Alternative <int>, Latino <int>, `Techno, Trance` <int>, Opera <int>,
## #   Movies <int>, Horror <int>, Thriller <int>, Comedy <int>,
## #   Romantic <int>, `Sci-fi` <int>, War <int>, `Fantasy/Fairy
## #   tales` <int>, Animated <int>, Documentary <int>, Western <int>,
## #   Action <int>, History <int>, Psychology <int>, Politics <int>,
## #   Mathematics <int>, Physics <int>, Internet <int>, PC <int>, `Economy
## #   Management` <int>, Biology <int>, Chemistry <int>, Reading <int>,
## #   Geography <int>, `Foreign languages` <int>, Medicine <int>, Law <int>,
## #   Cars <int>, `Art exhibitions` <int>, Religion <int>, `Countryside,
## #   outdoors` <int>, Dancing <int>, `Musical instruments` <int>,
## #   Writing <int>, `Passive sport` <int>, `Active sport` <int>,
## #   Gardening <int>, Celebrities <int>, Shopping <int>, `Science and
## #   technology` <int>, Theatre <int>, `Fun with friends` <int>,
## #   `Adrenaline sports` <int>, Pets <int>, Flying <int>, Storm <int>,
## #   Darkness <int>, Heights <int>, Spiders <int>, Snakes <int>,
## #   Rats <int>, Ageing <int>, `Dangerous dogs` <int>, `Fear of public
## #   speaking` <int>, Smoking <chr>, Alcohol <chr>, healthlife <int>,
## #   `Daily events` <int>, `Prioritising workload` <int>, `Writing
## #   notes` <int>, Workaholism <int>, `Thinking ahead` <int>, `Final
## #   judgement` <int>, Reliability <int>, `Keeping promises` <int>, `Loss
## #   of interest` <int>, `Friends versus money` <int>, Funniness <int>,
## #   Fake <int>, `Criminal damage` <int>, `Decision making` <int>,
## #   Elections <int>, `Self-criticism` <int>, `Judgment calls` <int>,
## #   Hypochondria <int>, Empathy <int>, `Eating to survive` <int>,
## #   Giving <int>, `Compassion to animals` <int>, `Borrowed stuff` <int>,
## #   Loneliness <int>, `Cheating in school` <int>, Health <int>, `Changing
## #   the past` <int>, God <int>, Dreams <int>, Charity <int>, ...

The following step above loads the dataset into R. Although the step was sucessful, there is an issue with the data. All together, there are 1,010 observations in the table (ygresp). However, there are 336 rows (individuals) that contain missing data or N/As. Due to this finding, we will remove the N/As from our dataset and create a new dataset called newrp which has 674 observations. The dataset become smaller but due to omitting the rows with N/As, we are able to run analyses and regression without potential errors. The steps taken to remove the N/As from table (ygresp) can be observed from the three blocks of code below

str(ygresp)
## Classes 'tbl_df', 'tbl' and 'data.frame':    1010 obs. of  151 variables:
##  $ Music                         : int  5 4 5 5 5 5 5 5 5 5 ...
##  $ Slow songs or fast songs      : int  3 4 5 3 3 3 5 3 3 3 ...
##  $ Dance                         : int  2 2 2 2 4 2 5 3 3 2 ...
##  $ Folk                          : int  1 1 2 1 3 3 3 2 1 5 ...
##  $ Country                       : int  2 1 3 1 2 2 1 1 1 2 ...
##  $ Classical music               : int  2 1 4 1 4 3 2 2 2 2 ...
##  $ Musical                       : int  1 2 5 1 3 3 2 2 4 5 ...
##  $ Pop                           : int  5 3 3 2 5 2 5 4 3 3 ...
##  $ Rock                          : int  5 5 5 2 3 5 3 5 5 5 ...
##  $ Metal or Hardrock             : int  1 4 3 1 1 5 1 1 5 2 ...
##  $ Punk                          : int  1 4 4 4 2 3 1 2 1 3 ...
##  $ Hiphop, Rap                   : int  1 1 1 2 5 4 3 3 1 2 ...
##  $ Reggae, Ska                   : int  1 3 4 2 3 3 1 2 2 4 ...
##  $ Swing, Jazz                   : int  1 1 3 1 2 4 1 2 2 4 ...
##  $ Rock n roll                   : int  3 4 5 2 1 4 2 3 2 4 ...
##  $ Alternative                   : int  1 4 5 5 2 5 3 1 NA 4 ...
##  $ Latino                        : int  1 2 5 1 4 3 3 2 1 5 ...
##  $ Techno, Trance                : int  1 1 1 2 2 1 5 3 1 1 ...
##  $ Opera                         : int  1 1 3 1 2 3 2 2 1 2 ...
##  $ Movies                        : int  5 5 5 5 5 5 4 5 5 5 ...
##  $ Horror                        : int  4 2 3 4 4 5 2 4 1 2 ...
##  $ Thriller                      : int  2 2 4 4 4 5 1 4 5 1 ...
##  $ Comedy                        : int  5 4 4 3 5 5 5 5 5 5 ...
##  $ Romantic                      : int  4 3 2 3 2 2 3 2 4 5 ...
##  $ Sci-fi                        : int  4 4 4 4 3 3 1 3 4 1 ...
##  $ War                           : int  1 1 2 3 3 3 3 3 5 3 ...
##  $ Fantasy/Fairy tales           : int  5 3 5 1 4 4 5 4 4 4 ...
##  $ Animated                      : int  5 5 5 2 4 3 5 4 4 4 ...
##  $ Documentary                   : int  3 4 2 5 3 3 3 3 5 4 ...
##  $ Western                       : int  1 1 2 1 1 2 1 1 1 1 ...
##  $ Action                        : int  2 4 1 2 4 4 2 3 1 2 ...
##  $ History                       : int  1 1 1 4 3 5 3 5 3 3 ...
##  $ Psychology                    : int  5 3 2 4 2 3 3 2 2 2 ...
##  $ Politics                      : int  1 4 1 5 3 4 1 3 1 3 ...
##  $ Mathematics                   : int  3 5 5 4 2 2 1 1 1 3 ...
##  $ Physics                       : int  3 2 2 1 2 3 1 1 1 1 ...
##  $ Internet                      : int  5 4 4 3 2 4 2 5 1 5 ...
##  $ PC                            : int  3 4 2 1 2 4 1 4 1 1 ...
##  $ Economy Management            : int  5 5 4 2 2 1 3 1 1 4 ...
##  $ Biology                       : int  3 1 1 3 3 4 5 2 3 2 ...
##  $ Chemistry                     : int  3 1 1 3 3 4 5 2 1 1 ...
##  $ Reading                       : int  3 4 5 5 5 3 3 2 5 4 ...
##  $ Geography                     : int  3 4 2 4 2 3 3 3 1 4 ...
##  $ Foreign languages             : int  5 5 5 4 3 4 4 4 1 5 ...
##  $ Medicine                      : int  3 1 2 2 3 4 5 1 1 1 ...
##  $ Law                           : int  1 2 3 5 2 3 3 2 1 1 ...
##  $ Cars                          : int  1 2 1 1 3 5 4 1 1 1 ...
##  $ Art exhibitions               : int  1 2 5 5 1 2 1 1 1 4 ...
##  $ Religion                      : int  1 1 5 4 4 2 1 2 2 4 ...
##  $ Countryside, outdoors         : int  5 1 5 1 4 5 4 2 4 4 ...
##  $ Dancing                       : int  3 1 5 1 1 1 3 1 1 5 ...
##  $ Musical instruments           : int  3 1 5 1 3 5 2 1 2 3 ...
##  $ Writing                       : int  2 1 5 3 1 1 1 1 1 1 ...
##  $ Passive sport                 : int  1 1 5 1 3 5 5 4 4 4 ...
##  $ Active sport                  : int  5 1 2 1 1 4 3 5 1 4 ...
##  $ Gardening                     : int  5 1 1 1 4 2 3 1 1 1 ...
##  $ Celebrities                   : int  1 2 1 2 3 1 1 3 5 2 ...
##  $ Shopping                      : int  4 3 4 4 3 2 3 3 2 4 ...
##  $ Science and technology        : int  4 3 2 3 3 3 4 2 1 3 ...
##  $ Theatre                       : int  2 2 5 1 2 1 3 2 5 5 ...
##  $ Fun with friends              : int  5 4 5 2 4 3 5 4 4 5 ...
##  $ Adrenaline sports             : int  4 2 5 1 2 3 1 2 1 2 ...
##  $ Pets                          : int  4 5 5 1 1 2 5 5 1 2 ...
##  $ Flying                        : int  1 1 1 2 1 3 1 3 2 4 ...
##  $ Storm                         : int  1 1 1 1 2 2 3 2 3 5 ...
##  $ Darkness                      : int  1 1 1 1 1 2 2 4 1 4 ...
##  $ Heights                       : int  1 2 1 3 1 2 1 3 5 5 ...
##  $ Spiders                       : int  1 1 1 5 1 1 1 1 5 3 ...
##  $ Snakes                        : int  5 1 1 5 1 2 5 5 5 4 ...
##  $ Rats                          : int  3 1 1 5 2 2 1 3 2 4 ...
##  $ Ageing                        : int  1 3 1 4 2 1 4 1 2 3 ...
##  $ Dangerous dogs                : int  3 1 1 5 4 1 1 2 3 5 ...
##  $ Fear of public speaking       : int  2 4 2 5 3 3 1 4 4 3 ...
##  $ Smoking                       : chr  "never smoked" "never smoked" "tried smoking" "former smoker" ...
##  $ Alcohol                       : chr  "drink a lot" "drink a lot" "drink a lot" "drink a lot" ...
##  $ healthlife                    : int  4 3 3 3 4 2 4 2 1 3 ...
##  $ Daily events                  : int  2 3 1 4 3 2 3 3 1 4 ...
##  $ Prioritising workload         : int  2 2 2 4 1 2 5 1 2 2 ...
##  $ Writing notes                 : int  5 4 5 4 2 3 5 3 1 2 ...
##  $ Workaholism                   : int  4 5 3 5 3 3 5 2 4 3 ...
##  $ Thinking ahead                : int  2 4 5 3 5 3 3 4 2 3 ...
##  $ Final judgement               : int  5 1 3 1 5 1 3 3 5 5 ...
##  $ Reliability                   : int  4 4 4 3 5 3 4 3 5 4 ...
##  $ Keeping promises              : int  4 4 5 4 4 4 5 3 4 5 ...
##  $ Loss of interest              : int  1 3 1 5 2 3 3 1 1 3 ...
##  $ Friends versus money          : int  3 4 5 2 3 2 4 4 4 4 ...
##  $ Funniness                     : int  5 3 2 1 3 3 4 4 2 3 ...
##  $ Fake                          : int  1 2 4 1 2 1 1 2 2 1 ...
##  $ Criminal damage               : int  1 1 1 5 1 4 2 1 1 2 ...
##  $ Decision making               : int  3 2 3 5 3 2 2 3 4 5 ...
##  $ Elections                     : int  4 5 5 5 5 5 5 5 1 5 ...
##  $ Self-criticism                : int  1 4 4 5 5 4 3 3 3 4 ...
##  $ Judgment calls                : int  3 4 4 4 5 4 5 5 2 5 ...
##  $ Hypochondria                  : int  1 1 1 3 1 1 1 2 2 1 ...
##  $ Empathy                       : int  3 2 5 3 3 4 4 1 5 4 ...
##  $ Eating to survive             : int  1 1 5 1 1 2 1 2 1 1 ...
##  $ Giving                        : int  4 2 5 1 3 3 5 3 1 4 ...
##  $ Compassion to animals         : int  5 4 4 2 3 5 5 5 4 5 ...
##  $ Borrowed stuff                : int  4 3 2 5 4 5 5 2 5 4 ...
##   [list output truncated]
##  - attr(*, "spec")=List of 2
##   ..$ cols   :List of 151
##   .. ..$ Music                         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Slow songs or fast songs      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Dance                         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Folk                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Country                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Classical music               : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Musical                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Pop                           : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Rock                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Metal or Hardrock             : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Punk                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Hiphop, Rap                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Reggae, Ska                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Swing, Jazz                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Rock n roll                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Alternative                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Latino                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Techno, Trance                : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Opera                         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Movies                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Horror                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Thriller                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Comedy                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Romantic                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Sci-fi                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ War                           : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Fantasy/Fairy tales           : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Animated                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Documentary                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Western                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Action                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ History                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Psychology                    : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Politics                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Mathematics                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Physics                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Internet                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ PC                            : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Economy Management            : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Biology                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Chemistry                     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Reading                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Geography                     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Foreign languages             : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Medicine                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Law                           : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Cars                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Art exhibitions               : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Religion                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Countryside, outdoors         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Dancing                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Musical instruments           : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Writing                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Passive sport                 : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Active sport                  : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Gardening                     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Celebrities                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Shopping                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Science and technology        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Theatre                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Fun with friends              : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Adrenaline sports             : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Pets                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Flying                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Storm                         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Darkness                      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Heights                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Spiders                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Snakes                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Rats                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Ageing                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Dangerous dogs                : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Fear of public speaking       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Smoking                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Alcohol                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ healthlife                    : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Daily events                  : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Prioritising workload         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Writing notes                 : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Workaholism                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Thinking ahead                : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Final judgement               : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Reliability                   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Keeping promises              : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Loss of interest              : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Friends versus money          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Funniness                     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Fake                          : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Criminal damage               : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Decision making               : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Elections                     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Self-criticism                : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Judgment calls                : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Hypochondria                  : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Empathy                       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Eating to survive             : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Giving                        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Compassion to animals         : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Borrowed stuff                : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. .. [list output truncated]
##   ..$ default: list()
##   .. ..- attr(*, "class")= chr  "collector_guess" "collector"
##   ..- attr(*, "class")= chr "col_spec"
complete.cases(ygresp)
##    [1]  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##   [12]  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
##   [23] FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
##   [34]  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
##   [45]  TRUE FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
##   [56]  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##   [67]  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE
##   [78]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE FALSE
##   [89]  TRUE  TRUE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
##  [100]  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##  [111]  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
##  [122]  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
##  [133]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE FALSE  TRUE FALSE
##  [144] FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE
##  [155]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE FALSE
##  [166]  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE
##  [177] FALSE FALSE  TRUE  TRUE FALSE FALSE  TRUE FALSE  TRUE  TRUE FALSE
##  [188]  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE
##  [199]  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
##  [210] FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE
##  [221]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
##  [232] FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
##  [243] FALSE FALSE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE
##  [254]  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE  TRUE FALSE  TRUE
##  [265] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
##  [276]  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##  [287]  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##  [298]  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE
##  [309] FALSE  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE
##  [320]  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
##  [331] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##  [342]  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE
##  [353]  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE FALSE  TRUE FALSE
##  [364]  TRUE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE FALSE
##  [375]  TRUE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE FALSE
##  [386]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
##  [397] FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE
##  [408]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
##  [419]  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
##  [430] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##  [441]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
##  [452]  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
##  [463] FALSE  TRUE  TRUE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE
##  [474] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE
##  [485] FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
##  [496] FALSE  TRUE FALSE  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
##  [507]  TRUE  TRUE FALSE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE
##  [518] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
##  [529]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
##  [540]  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE
##  [551]  TRUE FALSE FALSE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE
##  [562]  TRUE FALSE FALSE  TRUE FALSE  TRUE FALSE  TRUE  TRUE FALSE FALSE
##  [573] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE
##  [584]  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
##  [595]  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE
##  [606]  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE
##  [617]  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE
##  [628] FALSE  TRUE FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE
##  [639] FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE
##  [650] FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE FALSE
##  [661] FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE  TRUE
##  [672]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
##  [683]  TRUE FALSE  TRUE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
##  [694] FALSE  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE
##  [705]  TRUE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
##  [716]  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE
##  [727] FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE FALSE  TRUE FALSE FALSE
##  [738]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE
##  [749] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE
##  [760] FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE
##  [771]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE  TRUE
##  [782]  TRUE  TRUE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE
##  [793]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
##  [804] FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE
##  [815] FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
##  [826] FALSE  TRUE  TRUE FALSE  TRUE FALSE FALSE FALSE  TRUE  TRUE  TRUE
##  [837]  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE FALSE  TRUE
##  [848] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
##  [859] FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE
##  [870]  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
##  [881]  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE
##  [892] FALSE  TRUE FALSE  TRUE FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE
##  [903] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE FALSE
##  [914]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE
##  [925]  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE
##  [936] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
##  [947] FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE  TRUE FALSE
##  [958]  TRUE FALSE  TRUE FALSE  TRUE  TRUE FALSE FALSE FALSE  TRUE  TRUE
##  [969] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
##  [980]  TRUE FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE  TRUE
##  [991]  TRUE  TRUE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE  TRUE
## [1002]  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE

The R function complete.cases() is a useful application that can help find and take out rows with N/As.

newrp <- ygresp[complete.cases(ygresp), ]
str(newrp)
## Classes 'tbl_df', 'tbl' and 'data.frame':    674 obs. of  151 variables:
##  $ Music                         : int  5 4 5 5 5 5 5 5 5 5 ...
##  $ Slow songs or fast songs      : int  3 4 5 3 3 5 3 3 3 3 ...
##  $ Dance                         : int  2 2 2 4 2 5 3 2 3 1 ...
##  $ Folk                          : int  1 1 2 3 3 3 2 5 2 1 ...
##  $ Country                       : int  2 1 3 2 2 1 1 2 1 1 ...
##  $ Classical music               : int  2 1 4 4 3 2 2 2 2 4 ...
##  $ Musical                       : int  1 2 5 3 3 2 2 5 3 1 ...
##  $ Pop                           : int  5 3 3 5 2 5 4 3 4 2 ...
##  $ Rock                          : int  5 5 5 3 5 3 5 5 3 5 ...
##  $ Metal or Hardrock             : int  1 4 3 1 5 1 1 2 2 1 ...
##  $ Punk                          : int  1 4 4 2 3 1 2 3 1 1 ...
##  $ Hiphop, Rap                   : int  1 1 1 5 4 3 3 2 3 1 ...
##  $ Reggae, Ska                   : int  1 3 4 3 3 1 2 4 2 1 ...
##  $ Swing, Jazz                   : int  1 1 3 2 4 1 2 4 2 2 ...
##  $ Rock n roll                   : int  3 4 5 1 4 2 3 4 3 2 ...
##  $ Alternative                   : int  1 4 5 2 5 3 1 4 3 5 ...
##  $ Latino                        : int  1 2 5 4 3 3 2 5 3 2 ...
##  $ Techno, Trance                : int  1 1 1 2 1 5 3 1 4 1 ...
##  $ Opera                         : int  1 1 3 2 3 2 2 2 2 2 ...
##  $ Movies                        : int  5 5 5 5 5 4 5 5 5 5 ...
##  $ Horror                        : int  4 2 3 4 5 2 4 2 5 3 ...
##  $ Thriller                      : int  2 2 4 4 5 1 4 1 4 4 ...
##  $ Comedy                        : int  5 4 4 5 5 5 5 5 5 4 ...
##  $ Romantic                      : int  4 3 2 2 2 3 2 5 3 3 ...
##  $ Sci-fi                        : int  4 4 4 3 3 1 3 1 3 2 ...
##  $ War                           : int  1 1 2 3 3 3 3 3 2 5 ...
##  $ Fantasy/Fairy tales           : int  5 3 5 4 4 5 4 4 5 5 ...
##  $ Animated                      : int  5 5 5 4 3 5 4 4 5 5 ...
##  $ Documentary                   : int  3 4 2 3 3 3 3 4 3 5 ...
##  $ Western                       : int  1 1 2 1 2 1 1 1 1 1 ...
##  $ Action                        : int  2 4 1 4 4 2 3 2 3 4 ...
##  $ History                       : int  1 1 1 3 5 3 5 3 3 2 ...
##  $ Psychology                    : int  5 3 2 2 3 3 2 2 3 2 ...
##  $ Politics                      : int  1 4 1 3 4 1 3 3 3 5 ...
##  $ Mathematics                   : int  3 5 5 2 2 1 1 3 2 1 ...
##  $ Physics                       : int  3 2 2 2 3 1 1 1 1 1 ...
##  $ Internet                      : int  5 4 4 2 4 2 5 5 4 5 ...
##  $ PC                            : int  3 4 2 2 4 1 4 1 5 4 ...
##  $ Economy Management            : int  5 5 4 2 1 3 1 4 3 1 ...
##  $ Biology                       : int  3 1 1 3 4 5 2 2 2 1 ...
##  $ Chemistry                     : int  3 1 1 3 4 5 2 1 1 1 ...
##  $ Reading                       : int  3 4 5 5 3 3 2 4 3 3 ...
##  $ Geography                     : int  3 4 2 2 3 3 3 4 3 5 ...
##  $ Foreign languages             : int  5 5 5 3 4 4 4 5 5 2 ...
##  $ Medicine                      : int  3 1 2 3 4 5 1 1 2 1 ...
##  $ Law                           : int  1 2 3 2 3 3 2 1 4 3 ...
##  $ Cars                          : int  1 2 1 3 5 4 1 1 2 1 ...
##  $ Art exhibitions               : int  1 2 5 1 2 1 1 4 2 5 ...
##  $ Religion                      : int  1 1 5 4 2 1 2 4 2 1 ...
##  $ Countryside, outdoors         : int  5 1 5 4 5 4 2 4 4 5 ...
##  $ Dancing                       : int  3 1 5 1 1 3 1 5 1 1 ...
##  $ Musical instruments           : int  3 1 5 3 5 2 1 3 1 1 ...
##  $ Writing                       : int  2 1 5 1 1 1 1 1 1 1 ...
##  $ Passive sport                 : int  1 1 5 3 5 5 4 4 5 5 ...
##  $ Active sport                  : int  5 1 2 1 4 3 5 4 1 3 ...
##  $ Gardening                     : int  5 1 1 4 2 3 1 1 3 1 ...
##  $ Celebrities                   : int  1 2 1 3 1 1 3 2 2 2 ...
##  $ Shopping                      : int  4 3 4 3 2 3 3 4 5 3 ...
##  $ Science and technology        : int  4 3 2 3 3 4 2 3 4 3 ...
##  $ Theatre                       : int  2 2 5 2 1 3 2 5 2 1 ...
##  $ Fun with friends              : int  5 4 5 4 3 5 4 5 4 3 ...
##  $ Adrenaline sports             : int  4 2 5 2 3 1 2 2 1 1 ...
##  $ Pets                          : int  4 5 5 1 2 5 5 2 5 1 ...
##  $ Flying                        : int  1 1 1 1 3 1 3 4 1 4 ...
##  $ Storm                         : int  1 1 1 2 2 3 2 5 1 1 ...
##  $ Darkness                      : int  1 1 1 1 2 2 4 4 2 1 ...
##  $ Heights                       : int  1 2 1 1 2 1 3 5 2 3 ...
##  $ Spiders                       : int  1 1 1 1 1 1 1 3 2 5 ...
##  $ Snakes                        : int  5 1 1 1 2 5 5 4 1 5 ...
##  $ Rats                          : int  3 1 1 2 2 1 3 4 1 5 ...
##  $ Ageing                        : int  1 3 1 2 1 4 1 3 1 5 ...
##  $ Dangerous dogs                : int  3 1 1 4 1 1 2 5 4 5 ...
##  $ Fear of public speaking       : int  2 4 2 3 3 1 4 3 2 5 ...
##  $ Smoking                       : chr  "never smoked" "never smoked" "tried smoking" "tried smoking" ...
##  $ Alcohol                       : chr  "drink a lot" "drink a lot" "drink a lot" "social drinker" ...
##  $ healthlife                    : int  4 3 3 4 2 4 2 3 3 3 ...
##  $ Daily events                  : int  2 3 1 3 2 3 3 4 3 3 ...
##  $ Prioritising workload         : int  2 2 2 1 2 5 1 2 2 1 ...
##  $ Writing notes                 : int  5 4 5 2 3 5 3 2 4 5 ...
##  $ Workaholism                   : int  4 5 3 3 3 5 2 3 2 3 ...
##  $ Thinking ahead                : int  2 4 5 5 3 3 4 3 3 1 ...
##  $ Final judgement               : int  5 1 3 5 1 3 3 5 3 1 ...
##  $ Reliability                   : int  4 4 4 5 3 4 3 4 4 3 ...
##  $ Keeping promises              : int  4 4 5 4 4 5 3 5 4 3 ...
##  $ Loss of interest              : int  1 3 1 2 3 3 1 3 1 3 ...
##  $ Friends versus money          : int  3 4 5 3 2 4 4 4 3 3 ...
##  $ Funniness                     : int  5 3 2 3 3 4 4 3 2 5 ...
##  $ Fake                          : int  1 2 4 2 1 1 2 1 1 3 ...
##  $ Criminal damage               : int  1 1 1 1 4 2 1 2 1 5 ...
##  $ Decision making               : int  3 2 3 3 2 2 3 5 5 3 ...
##  $ Elections                     : int  4 5 5 5 5 5 5 5 5 1 ...
##  $ Self-criticism                : int  1 4 4 5 4 3 3 4 4 5 ...
##  $ Judgment calls                : int  3 4 4 5 4 5 5 5 5 3 ...
##  $ Hypochondria                  : int  1 1 1 1 1 1 2 1 2 5 ...
##  $ Empathy                       : int  3 2 5 3 4 4 1 4 5 5 ...
##  $ Eating to survive             : int  1 1 5 1 2 1 2 1 2 1 ...
##  $ Giving                        : int  4 2 5 3 3 5 3 4 3 1 ...
##  $ Compassion to animals         : int  5 4 4 3 5 5 5 5 5 2 ...
##  $ Borrowed stuff                : int  4 3 2 4 5 5 2 4 4 2 ...
##   [list output truncated]

By using complete.case() we are able to observe which rows do not have any missing information and which rows have missing information. To eliminate the rows that contain missing data from our table (ygresp) we use the following block of code below. We create a new table called newrp and will put the original dataset with removed rows with N/As into the table (newrp).

newrp <- na.omit(ygresp)

The na.omit() command is another way to take out all the rows that contain NA values in our dataset.

Data Structure

As a result from eliminating the N/As from our original dataset, we have a new dateset called newrp which has 674 observations. In our new dataset, there are 674 respondents from six different education levels. For each respondent, the outcome of interest is self-rated health index (1-5). In our dataset, the response variable or dependent variable is healthlife which measures if a person identifies as living a healthy lifestyle on a scale from 1-5. The 1 represents strong disagreement of living a healthy lifestlye whereas 5 represents strongly agreeing to living a healthy lifestyle.

The independent variables in the study are gender which measures the respondents’ gender (0= Female, 1 = Male), Education, which measures the educational level of a participant and Age, the age in years of respondents, ranging from 15 to 30.

The respondents will be grouped by their education. Therefore, there are two levels, the individual level and educational level that will be examined to observe healthy lifestyles reported from the dataset. Individuals are intergrated within education and education is the amount of schooling completed by individuals.

data(newrp)
## Warning in data(newrp): data set 'newrp' not found
length(unique(newrp$Education))
## [1] 6
newrp %>% 
  group_by(Education) %>% 
  summarise(n_sch = n())
## # A tibble: 6 × 2
##                          Education n_sch
##                              <chr> <int>
## 1          college/bachelor degree   140
## 2 currently a primary school pupil     2
## 3                 doctorate degree     3
## 4                   masters degree    52
## 5                   primary school    53
## 6                 secondary school   424
respd <- newrp %>% 
  group_by(Education) %>% 
  summarise(mean_p = mean(healthlife, na.rm = TRUE), mean_s = mean(gennum, na.rm = TRUE))
head(respd)
## # A tibble: 6 × 3
##                          Education   mean_p    mean_s
##                              <chr>    <dbl>     <dbl>
## 1          college/bachelor degree 3.000000 0.4214286
## 2 currently a primary school pupil 3.000000 0.0000000
## 3                 doctorate degree 2.666667 1.0000000
## 4                   masters degree 3.153846 0.4038462
## 5                   primary school 2.811321 0.3018868
## 6                 secondary school 2.985849 0.4080189

In the following observation above, mean_s is the proportion of males of the education level. Interestingly, the proportion of males in education level of currerntly being a primary school pupil is 0. The reason why the proportion is 0 for this education level of males is possibly due to omitting 336 rows from the original dataset. The initial dataset (ygresp) may have included males that have education level of being a current primary school pupil. However, they were presumably removed after omitting the N/As. In other words, the observations that were male and had an education level of current primary school pupil may have had an N/A in their respected row and were elimiated from the new dataset causing the means to be 0 for this educational level for males.

ecoreg <- lm(mean_p ~ mean_s, data = respd)
summary(ecoreg)
## 
## Call:
## lm(formula = mean_p ~ mean_s, data = respd)
## 
## Residuals:
##        1        2        3        4        5        6 
##  0.06336 -0.07447 -0.08075  0.21146 -0.16442  0.04482 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.0745     0.1065  28.859 8.58e-06 ***
## mean_s       -0.3271     0.2064  -1.584    0.188    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1499 on 4 degrees of freedom
## Multiple R-squared:  0.3856, Adjusted R-squared:  0.232 
## F-statistic:  2.51 on 1 and 4 DF,  p-value: 0.1883

According to the ecological regression, male respondents are less likely (-0.33) to report healthier lifestlyes than females pertainin to their educational level. Furthermore, the results from the p-values (8.58e-0.6 and0.188) tell us that both the Intercept and mean_s are not statistically significant. Consequently, the results from this regression are not substantively meaningful.

cpooling <- gls(healthlife ~ gennum, data = newrp, method = "ML")
summary(cpooling)
## Generalized least squares fit by maximum likelihood
##   Model: healthlife ~ gennum 
##   Data: newrp 
##        AIC      BIC    logLik
##   1810.504 1824.044 -902.2519
## 
## Coefficients:
##                  Value  Std.Error  t-value p-value
## (Intercept)  3.0696517 0.04609614 66.59238  0.0000
## gennum      -0.2056812 0.07256214 -2.83455  0.0047
## 
##  Correlation: 
##        (Intr)
## gennum -0.635
## 
## Standardized residuals:
##        Min         Q1        Med         Q3        Max 
## -2.2426679 -0.0754744 -0.0754744  1.0081224  2.3145946 
## 
## Residual standard error: 0.9228525 
## Degrees of freedom: 674 total; 672 residual

The complete pooling model analyzes on an individual level and does take educational level into consideration. Compared to our ecological regression, the intercept and gennum coefficient are both statistically significant (P-values < 0.05). Strictly speaking, there is a meaningful sex difference between males and females in regards to living healthier lifestyles. Females are more likely to report healthier lifestyles than their male counterparts (-0.21).

dcoef <- newrp %>% 
    group_by(Education) %>% 
    do(mod = lm(healthlife ~ gennum, data = .))
coef <- dcoef %>% do(data.frame(intc = coef(.$mod)[1]))
ggplot(coef, aes(x = intc)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

dcoef <- newrp %>% 
    group_by(Education) %>% 
    do(mod = lm(healthlife ~ gennum, data = .))
coef <- dcoef %>% do(data.frame(sexc = coef(.$mod)[2]))
ggplot(coef, aes(x = sexc)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 2 rows containing non-finite values (stat_bin).

The slope and y-intercept for the regression line is too widespread. Therefore, we cannot use the no-pooling model. Additionally, we cannot aquire a normal distribution from either histogram.

m1_lme <- lme(healthlife ~ gennum, data = newrp, random = ~1|Education, method = "ML")
summary(m1_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: newrp 
##        AIC      BIC    logLik
##   1812.504 1830.557 -902.2519
## 
## Random effects:
##  Formula: ~1 | Education
##          (Intercept)  Residual
## StdDev: 2.473706e-05 0.9228525
## 
## Fixed effects: healthlife ~ gennum 
##                  Value  Std.Error  DF  t-value p-value
## (Intercept)  3.0696517 0.04609615 667 66.59237  0.0000
## gennum      -0.2056812 0.07256214 667 -2.83455  0.0047
##  Correlation: 
##        (Intr)
## gennum -0.635
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.2426679 -0.0754744 -0.0754744  1.0081224  2.3145946 
## 
## Number of Observations: 674
## Number of Groups: 6

The standard deviation of 2.47 is a measure of how much variability in the dependent measure there is due to education level (random effect). In the above random-intercept model, males are less likely to report healthier lifestyles (-0.21) relative to females (3.07). Both the intercept and gennum coefficent are statisitcally significant.

m2_lme <- lme(healthlife ~ gennum, data = newrp, random = ~ gennum|Education, method = "ML")
summary(m2_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: newrp 
##        AIC      BIC    logLik
##   1816.504 1843.583 -902.2519
## 
## Random effects:
##  Formula: ~gennum | Education
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev       Corr  
## (Intercept) 3.262499e-05 (Intr)
## gennum      3.462033e-06 0     
## Residual    9.228525e-01       
## 
## Fixed effects: healthlife ~ gennum 
##                  Value  Std.Error  DF  t-value p-value
## (Intercept)  3.0696517 0.04609615 667 66.59237  0.0000
## gennum      -0.2056812 0.07256214 667 -2.83455  0.0047
##  Correlation: 
##        (Intr)
## gennum -0.635
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.2426679 -0.0754744 -0.0754744  1.0081223  2.3145946 
## 
## Number of Observations: 674
## Number of Groups: 6

The model above is the random slope model. Similar to model 1, the coefficient gennum and intercept are statistically significant (P-Values < 0.05). The standard deviation of 3.262499e-05 is a measure of variability in the dependent measure that is due to educational level. Again, males are less likely to report (-0.21) healthier lifestyles than females.

anova(cpooling, m1_lme, m2_lme)
##          Model df      AIC      BIC    logLik   Test      L.Ratio p-value
## cpooling     1  3 1810.504 1824.043 -902.2519                            
## m1_lme       2  4 1812.504 1830.557 -902.2519 1 vs 2 3.240784e-07  0.9995
## m2_lme       3  6 1816.504 1843.583 -902.2519 2 vs 3 2.415127e-07  1.0000

Among the two models, the first model has lower AIC (1812.504) than the second model (1816.504) and is the better fit. However, neither model is statistically significant (Both have P-Values > 0.05). Even though the p-values did not turn out to be of significance, we now know that gender does not have a significant impact on self-reported health. Although, females were more likely to report better health in both models compared to males, gender and their educational levels are not drastically important factors for self-related health. Despite these findings, it was informative to know that healthy lifestyles may not necessarily be impacted be gender and level of educational attainment.

m3_lme <- lme(healthlife ~ gennum + Age, data = newrp, random = ~ gennum|Education, method = "ML")
summary(m3_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: newrp 
##        AIC      BIC    logLik
##   1815.823 1847.415 -900.9114
## 
## Random effects:
##  Formula: ~gennum | Education
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev       Corr  
## (Intercept) 3.029782e-05 (Intr)
## gennum      5.114462e-06 0     
## Residual    9.210188e-01       
## 
## Fixed effects: healthlife ~ gennum + Age 
##                  Value  Std.Error  DF   t-value p-value
## (Intercept)  2.6387870 0.26745676 666  9.866219  0.0000
## gennum      -0.2217010 0.07313094 666 -3.031562  0.0025
## Age          0.0214871 0.01313891 666  1.635380  0.1024
##  Correlation: 
##        (Intr) gennum
## gennum  0.024       
## Age    -0.985 -0.134
## 
## Standardized Within-Group Residuals:
##         Min          Q1         Med          Q3         Max 
## -2.43255194 -0.16772483 -0.02774651  0.86553741  2.40780419 
## 
## Number of Observations: 674
## Number of Groups: 6

In the model above, we add a covariate of age. Though this covariate is added, it does not have any meaningful impact on lifestyle as the p-value is greater than 0.05. Furthermore, males are less likely to report a healthy lifestyle (-0.22) relative to females. However, when age is factored in, self-related lifestyle increases by 0.02 but is insignificant as observed from the p-value.

m4_lme <- lme(healthlife ~ gennum*Age, data = newrp, random = ~ gennum|Education, method = "ML")
summary(m4_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: newrp 
##       AIC      BIC    logLik
##   1816.96 1853.066 -900.4799
## 
## Random effects:
##  Formula: ~gennum | Education
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev       Corr  
## (Intercept) 2.475415e-05 (Intr)
## gennum      3.080968e-06 0     
## Residual    9.204294e-01       
## 
## Fixed effects: healthlife ~ gennum * Age 
##                  Value Std.Error  DF   t-value p-value
## (Intercept)  2.4237934 0.3541064 665  6.844816  0.0000
## gennum       0.2808241 0.5472813 665  0.513126  0.6080
## Age          0.0322088 0.0175093 665  1.839527  0.0663
## gennum:Age  -0.0245468 0.0264932 665 -0.926532  0.3545
##  Correlation: 
##            (Intr) gennum Age   
## gennum     -0.647              
## Age        -0.992  0.642       
## gennum:Age  0.655 -0.991 -0.661
## 
## Standardized Within-Group Residuals:
##          Min           Q1          Med           Q3          Max 
## -2.526689823 -0.213817987 -0.003858648  0.793896729  2.352302363 
## 
## Number of Observations: 674
## Number of Groups: 6

In this model, the Age variable does not change the significant effect of the response variable. Although we have created a cross level interaction between gender and age, the p-value for age is above 0.05. Although, the results from the model show that males are more likely to report healthier lifestlyes (0.28) than females it is not meaningful as indicated by the p-value. Hence, this finding is not statistically significnant. Additionally, males are less likely to report healthier lifestlye (-0.02) than females. However, this finding is also not statistically significant (P-value = 0.35)

anova(cpooling, m1_lme, m2_lme, m3_lme, m4_lme)
##          Model df      AIC      BIC    logLik   Test   L.Ratio p-value
## cpooling     1  3 1810.504 1824.043 -902.2519                         
## m1_lme       2  4 1812.504 1830.557 -902.2519 1 vs 2 0.0000003  0.9995
## m2_lme       3  6 1816.504 1843.583 -902.2519 2 vs 3 0.0000002  1.0000
## m3_lme       4  7 1815.823 1847.415 -900.9114 3 vs 4 2.6810872  0.1015
## m4_lme       5  8 1816.960 1853.065 -900.4799 4 vs 5 0.8630340  0.3529

gender level does not greatly affect healthy lifestyle

newrp %<>% mutate(cAge = Age - mean(Age))
m4a_lme <- lme(healthlife ~ gennum*cAge, data = newrp, random = ~ gennum|Education, method = "ML")
summary(m4a_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: newrp 
##       AIC      BIC    logLik
##   1816.96 1853.066 -900.4799
## 
## Random effects:
##  Formula: ~gennum | Education
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev       Corr  
## (Intercept) 2.567686e-05 (Intr)
## gennum      3.255692e-06 0     
## Residual    9.204294e-01       
## 
## Fixed effects: healthlife ~ gennum * cAge 
##                  Value  Std.Error  DF  t-value p-value
## (Intercept)  3.0793426 0.04634408 665 66.44522  0.0000
## gennum      -0.2187792 0.07320661 665 -2.98852  0.0029
## cAge         0.0322088 0.01750928 665  1.83953  0.0663
## gennum:cAge -0.0245468 0.02649317 665 -0.92653  0.3545
##  Correlation: 
##             (Intr) gennum cAge  
## gennum      -0.633              
## cAge         0.114 -0.072       
## gennum:cAge -0.075 -0.043 -0.661
## 
## Standardized Within-Group Residuals:
##          Min           Q1          Med           Q3          Max 
## -2.526689823 -0.213817987 -0.003858648  0.793896729  2.352302363 
## 
## Number of Observations: 674
## Number of Groups: 6
screenreg(list(m4_lme, m4a_lme))
## 
## ========================================
##                 Model 1      Model 2    
## ----------------------------------------
## (Intercept)        2.42 ***     3.08 ***
##                   (0.35)       (0.05)   
## gennum             0.28        -0.22 ** 
##                   (0.55)       (0.07)   
## Age                0.03                 
##                   (0.02)                
## gennum:Age        -0.02                 
##                   (0.03)                
## cAge                            0.03    
##                                (0.02)   
## gennum:cAge                    -0.02    
##                                (0.03)   
## ----------------------------------------
## AIC             1816.96      1816.96    
## BIC             1853.07      1853.07    
## Log Likelihood  -900.48      -900.48    
## Num. obs.        674          674       
## Num. groups        6            6       
## ========================================
## *** p < 0.001, ** p < 0.01, * p < 0.05
m0_lme <- lme(healthlife ~ 1, random = ~ 1|Education, data = newrp, method = "ML")
summary(m0_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: newrp 
##        AIC      BIC    logLik
##   1818.515 1832.054 -906.2573
## 
## Random effects:
##  Formula: ~1 | Education
##          (Intercept)  Residual
## StdDev: 2.412972e-05 0.9283531
## 
## Fixed effects: healthlife ~ 1 
##                Value  Std.Error  DF  t-value p-value
## (Intercept) 2.986647 0.03578539 668 83.45996       0
## 
## Standardized Within-Group Residuals:
##         Min          Q1         Med          Q3         Max 
## -2.13996901  0.01438365  0.01438366  1.09155999  2.16873633 
## 
## Number of Observations: 674
## Number of Groups: 6
intervals(m0_lme)
## Approximate 95% confidence intervals
## 
##  Fixed effects:
##                lower     est.   upper
## (Intercept) 2.916434 2.986647 3.05686
## attr(,"label")
## [1] "Fixed effects:"
## 
##  Random Effects:
##   Level: Education 
##                        lower         est.        upper
## sd((Intercept)) 1.068334e-71 2.412972e-05 5.450014e+61
## 
##  Within-group standard error:
##     lower      est.     upper 
## 0.8801041 0.9283531 0.9792472