Blog 3: Bivariate,Multivariate Analysis

Maliat

12/12/2021

Bivariate Analysis –

This type of analysis involves two different variables. The analysis of this type of data deals with causes and relationships and the analysis is done to find out the relationship among the two variables.

. Multivariate Analysis–

When the analysis involves three or more variables, it is categorized under multivariate.

Assortative mating indicates a tendency where both men and women choose a partner who shares similar social characteristics. Unarguably education is a very prominent social characteristic. Assortative mating designs the characteristics of families and reproduction of the population. The objective of this blog is to describe the pattern of assortative mating. Moreover, this blog will also unravel if there is any relationship between educational assortative mating and self-rated health. To understand the pattern the data from the Wisconsin Longitudinal Study will be analyzed. The Wisconsin Longitudinal Study examines the life course of its participants. The WLS confers the opportunity to understand the intergenerational transfers, relationships, family functioning, characteristics, physical and mental health and well-being, and morbidity and mortality of its participants from 1957 to 2011. To attain the goal for this blog the respondents’ and their spouses’ education proportion will be measured using multi and bivariate analysis.

Relationship among assortative mating,education and WLS partcipant’s health:

WLS_educ <- read_dta("C:/Users/malia/OneDrive/Desktop/WLS_educ.dta")
WLS_health <- read_dta("C:/Users/malia/OneDrive/Desktop/WLS_health.dta")
glimpse(WLS_educ)
## Rows: 4,641
## Columns: 7
## $ idpub      <dbl> 900034, 900042, 900069, 900078, 900079, 900096, 900106, 900~
## $ brdxdy     <dbl+lbl> 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39,~
## $ sexrsp     <dbl+lbl> 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1~
## $ edfa57q    <dbl+lbl>  7, 16, 13, 12, 13, 16, 12, 10, 10, 13, 16,  7, 10,  7,~
## $ edmo57q    <dbl+lbl>  7,  7, 14, 13, 12, 12, 12, 10, 10, -1, 16, 12, 10,  7,~
## $ spouse_edu <dbl> 12, 12, 12, 12, 12, 18, 12, 12, 12, 12, 12, 12, 12, 10, 14,~
## $ resp_edu   <dbl> 12, 12, 19, 12, 12, 18, 18, 12, 16, 12, 16, 12, 12, 16, 12,~
glimpse(WLS_health)
## Rows: 4,641
## Columns: 2
## $ idpub  <dbl> 900034, 900042, 900069, 900078, 900079, 900096, 900106, 900117,~
## $ health <dbl+lbl> 1, 3, 3, 4, 2, 4, 4, 4, 3, 1, 4, 3, 2, 3, 3, 3, 2, 4, 4, 2,~
WLS<- cbind(WLS_educ,WLS_health)%>%
  select(brdxdy,sexrsp,spouse_edu,resp_edu,health)
glimpse(WLS)
## Rows: 4,641
## Columns: 5
## $ brdxdy     <dbl+lbl> 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39,~
## $ sexrsp     <dbl+lbl> 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1~
## $ spouse_edu <dbl> 12, 12, 12, 12, 12, 18, 12, 12, 12, 12, 12, 12, 12, 10, 14,~
## $ resp_edu   <dbl> 12, 12, 19, 12, 12, 18, 18, 12, 16, 12, 16, 12, 12, 16, 12,~
## $ health     <dbl+lbl> 1, 3, 3, 4, 2, 4, 4, 4, 3, 1, 4, 3, 2, 3, 3, 3, 2, 4, 4~

###part 1 educational observational mating

WLS <- WLS %>%
  mutate (
    r_edu = case_when(
      resp_edu ==12 ~ "1 HS or Less",
      resp_edu >= 13 & resp_edu <16 ~ "2 Some College",
      resp_edu >=16 & resp_edu ~ "3 BA or more"),
    sp_edu = case_when (
      spouse_edu == 12 ~ "1 HS or Less",
      spouse_edu >=13 & spouse_edu < 16 ~ "2 Some College",
      spouse_edu >=16 ~ "3 BA or more"))

#crosstabulation

table(WLS$r_edu, WLS$sp_edu) #basic cross tabulation of frequencies
##                 
##                  1 HS or Less 2 Some College 3 BA or more
##   1 HS or Less           1853            329          299
##   2 Some College          319            109          187
##   3 BA or more            274            237          668
prop.table(table(WLS$r_edu, WLS$sp_edu), 1)
##                 
##                  1 HS or Less 2 Some College 3 BA or more
##   1 HS or Less      0.7468763      0.1326078    0.1205159
##   2 Some College    0.5186992      0.1772358    0.3040650
##   3 BA or more      0.2324003      0.2010178    0.5665818
chisq.test(WLS$r_edu, WLS$sp_edu)
## 
##  Pearson's Chi-squared test
## 
## data:  WLS$r_edu and WLS$sp_edu
## X-squared = 990.89, df = 4, p-value < 2.2e-16
crosstab(WLS$r_edu, WLS$sp_edu, prop.r = T, chisq = T, dnn=c("Respondent's education", "Spouse's education"))

##    Cell Contents 
## |-------------------------|
## |                   Count | 
## |             Row Percent | 
## |-------------------------|
## 
## ==============================================================================
##                           Spouse's education
## Respondent's education    1 HS or Less   2 Some College   3 BA or more   Total
## ------------------------------------------------------------------------------
## 1 HS or Less                     1853              329            299    2481 
##                                  74.7%            13.3%          12.1%   58.0%
## ------------------------------------------------------------------------------
## 2 Some College                    319              109            187     615 
##                                  51.9%            17.7%          30.4%   14.4%
## ------------------------------------------------------------------------------
## 3 BA or more                      274              237            668    1179 
##                                  23.2%            20.1%          56.7%   27.6%
## ------------------------------------------------------------------------------
## Total                            2446              675           1154    4275 
## ==============================================================================
## 
## Statistics for All Table Factors
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 = 990.8927      d.f. = 4      p <2e-16 
## 
##         Minimum expected frequency: 97.10526
WLS <- WLS %>% 
  mutate(
    homogamous = ifelse(r_edu == sp_edu, 1, 0 ),
    hypergamous = ifelse(sexrsp == 1 & r_edu > sp_edu | sexrsp == 2 & r_edu < sp_edu, 1, 0),
    hypogamous = ifelse(sexrsp == 2 & r_edu > sp_edu | sexrsp == 1 & r_edu < sp_edu, 1, 0),
    marriage_type = case_when(
    homogamous==1 ~ "1 Homogamous",
    hypergamous==1 ~ "2 Hypergamous",
    hypogamous==1 ~ "3 Hypogamous"
  ))

#freq(WLS$homogamous)
#freq(WLS$hypergamous)
#freq(WLS$hypogamous)
freq(WLS$marriage_type)

## WLS$marriage_type 
##               Frequency Percent Valid Percent
## 1 Homogamous       2630  56.669         61.52
## 2 Hypergamous      1192  25.684         27.88
## 3 Hypogamous        453   9.761         10.60
## NA's                366   7.886              
## Total              4641 100.000        100.00
#table(WLS$marriage_type, WLS$homogamous)
#table(WLS$marriage_type, WLS$hypergamous)
#table(WLS$marriage_type, WLS$hypogamous)

##part2Assessing the relationship between educational assortative mating and self-rated health.

WLS <- WLS %>%
  mutate(
    r_edu = case_when(
      resp_edu ==12 ~ "1 HS or Less",
      resp_edu >= 13 & resp_edu <16 ~ "2 Some College",
      resp_edu >=16 & resp_edu ~ "3 BA or more"),
    health.1 = case_when(
      health == 1 ~ "1 Fair/Worse",
      health == 2 ~ "2 Good",
      health == 3 ~ "3 Very Good",
      health == 4 ~ "4 Excellent"))
crosstab(WLS$r_edu, WLS$health.1, prop.r = T, chisq = T, dnn=c("Education level", "Self-rated health"))

##    Cell Contents 
## |-------------------------|
## |                   Count | 
## |             Row Percent | 
## |-------------------------|
## 
## ============================================================================
##                    Self-rated health
## Education level    1 Fair/Worse   2 Good   3 Very Good   4 Excellent   Total
## ----------------------------------------------------------------------------
## 1 HS or Less               388      969          1061           387    2805 
##                           13.8%    34.5%         37.8%         13.8%   60.4%
## ----------------------------------------------------------------------------
## 2 Some College              62      170           250           152     634 
##                            9.8%    26.8%         39.4%         24.0%   13.7%
## ----------------------------------------------------------------------------
## 3 BA or more                85      249           493           375    1202 
##                            7.1%    20.7%         41.0%         31.2%   25.9%
## ----------------------------------------------------------------------------
## Total                      535     1388          1804           914    4641 
## ============================================================================
## 
## Statistics for All Table Factors
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 = 229.9411      d.f. = 6      p <2e-16 
## 
##         Minimum expected frequency: 73.08554
WLS <- WLS %>% 
  mutate(
    homogamous = ifelse(r_edu == sp_edu, 1, 0 ),
    hypergamous = ifelse(sexrsp == 1 & r_edu > sp_edu | sexrsp == 2 & r_edu < sp_edu, 1, 0),
    hypogamous = ifelse(sexrsp == 2 & r_edu > sp_edu | sexrsp == 1 & r_edu < sp_edu, 1, 0),
    marriage_type = case_when(
    homogamous==1 ~ "1 Homogamous",
    hypergamous==1 ~ "2 Hypergamous",
    hypogamous==1 ~ "3 Hypogamous"),
    health.1 = case_when(
      health == 1 ~ "1 Fair/Worse",
      health == 2 ~ "2 Good",
      health == 3 ~ "3 Very Good",
      health == 4 ~ "4 Excellent"))
crosstab(WLS$marriage_type, WLS$health.1, prop.r = T, chisq = T, dnn=c("Marriage Type", "Self-rated health"))

##    Cell Contents 
## |-------------------------|
## |                   Count | 
## |             Row Percent | 
## |-------------------------|
## 
## ==========================================================================
##                  Self-rated health
## Marriage Type    1 Fair/Worse   2 Good   3 Very Good   4 Excellent   Total
## --------------------------------------------------------------------------
## 1 Homogamous             311      828          1000           491    2630 
##                         11.8%    31.5%         38.0%         18.7%   61.5%
## --------------------------------------------------------------------------
## 2 Hypergamous            120      300           492           280    1192 
##                         10.1%    25.2%         41.3%         23.5%   27.9%
## --------------------------------------------------------------------------
## 3 Hypogamous              49      122           188            94     453 
##                         10.8%    26.9%         41.5%         20.8%   10.6%
## --------------------------------------------------------------------------
## Total                    480     1250          1680           865    4275 
## ==========================================================================
## 
## Statistics for All Table Factors
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 = 26.76577      d.f. = 6      p = 0.00016 
## 
##         Minimum expected frequency: 50.86316

After analyzing the WLS data it can be concluded that assortative mating based on education is very frequent. Moreover, education positively impacts the respondents’ health. However, after analyzing the relationship between the self-rated health and types of marriage it can be stated that the category of the marriage does not statistically impact the respondents’ self-rated health.