#------------ setwd
setwd("C:/Users/C00252837/Dropbox/StudentParentsData")

#------------Read in Data
data<-read.csv("sutdentparents_survey_weighted.csv", header = T)
data<-as_tibble(data)
names(data)
##  [1] "ï..Column1"                       "x1"                              
##  [3] "Ã.Column1"                        "x"                               
##  [5] "classification"                   "enrollment"                      
##  [7] "department"                       "q4"                              
##  [9] "finanacial_assistance"            "q24_8_text"                      
## [11] "q23"                              "q38"                             
## [13] "q5"                               "q43"                             
## [15] "employment_status"                "gender"                          
## [17] "gender2"                          "q10_5_text"                      
## [19] "age_original"                     "race"                            
## [21] "race2"                            "q46"                             
## [23] "q46_4_text"                       "q47"                             
## [25] "q47_11_text"                      "pregnancy"                       
## [27] "parenthood"                       "numb_children"                   
## [29] "age_children"                     "q35_13"                          
## [31] "q35_14"                           "q35_15"                          
## [33] "q62"                              "column226"                       
## [35] "res_aware_both_mean"              "res_aware_patuniq_mean"          
## [37] "res_use_both_mean"                "res_use_patuniq_mean"            
## [39] "socialsupport_both_mean"          "socialsupport_patuniq_mean"      
## [41] "positive_exp_both_mean"           "positive_exp_patuniq_mean"       
## [43] "negative_exp_gen_both_mean"       "negative_exp_gen_patuniq_mean"   
## [45] "academic_diffty_both_mean"        "academic_diffty_patuniq_mean"    
## [47] "financial_ins_both_mean"          "financial_ins_patuniq_mean"      
## [49] "housing_ins_both_mean"            "physical_health_both_mean"       
## [51] "psycsocemo_health_both_mean"      "psycsocemo_health_patuniq_mean"  
## [53] "expectations_both_mean"           "expectations_patuniq_mean"       
## [55] "pat_childcare_patuniq_mean"       "child_issues_patuniq_mean"       
## [57] "pregnancy_patuniq_mean"           "age_recoded"                     
## [59] "age_recoded_narm"                 "parenthood_age"                  
## [61] "parenthood_age_narm"              "res_aware_both_mean_recode"      
## [63] "res_use_both_mean_recode"         "socialsupport_both_mean_recode"  
## [65] "positive_exp_both_mean_recode"    "negative_exp_gen_both_mean_recod"
## [67] "academic_diffty_both_mean_recode" "financial_ins_both_mean_recode"  
## [69] "housing_ins_both_mean_recode"     "physical_health_both_mean_recode"
## [71] "psycsocemo_health_both_mean_reco" "nurs_or_not"                     
## [73] "age"                              "agegroup"                        
## [75] "binary_gender_original"           "binary_gender"                   
## [77] "race3"                            "graduate"                        
## [79] "agegroup_tot"                     "binary_gender_tot"               
## [81] "race3_tot"                        "graduate_tot"                    
## [83] "counter1"                         "sample_tot"                      
## [85] "baseweight"                       "finalweight"
data <- data%>%
  rename(
    ID = x)

Complex Survey Analysis

Differential respondent weighting (following https://rpubs.com/corey_sparks/53683)

#Total count of the sample
count(data)
## # A tibble: 1 x 1
##       n
##   <int>
## 1   738
#parenthood status
table(data$parenthood)
## 
##  No Yes 
## 571 167
prop.table(table(data$parenthood))
## 
##        No       Yes 
## 0.7737127 0.2262873
#graduate status
table(data$graduate)#0=undergraduate, 1=graduate
## 
##   0   1 
## 535 203
prop.table(table(data$graduate))
## 
##         0         1 
## 0.7249322 0.2750678
#parenthood by graduate status
table(data$parenthood, data$graduate)
##      
##         0   1
##   No  445 126
##   Yes  90  77
prop.table(table(data$parenthood, data$graduate), margin=2)
##      
##               0         1
##   No  0.8317757 0.6206897
##   Yes 0.1682243 0.3793103

Create a survey design object

Use functions in a new library, called survey

library(survey)
des<-svydesign(ids=~1, weights=~finalweight, data = data)

#re-do the analysis from above using sample weights
library(questionr)
wtd.table(data$parenthood,weights = data$finalweight)
##    No   Yes 
## 12521  2203
prop.table(wtd.table(data$parenthood,weights = data$finalweight))
##        No       Yes 
## 0.8503803 0.1496197
wtd.table(data$graduate, weights = data$finalweight)#0=undergraduate, 1=graduate
##     0     1 
## 12353  2371
prop.table(wtd.table(data$graduate, weights = data$finalweight))
##         0         1 
## 0.8389704 0.1610296
wtd.table(data$parenthood, data$graduate, weights = data$finalweight)
##         0     1
## No  10949  1572
## Yes  1404   799
prop.table(wtd.table(data$parenthood, data$graduate, weights = data$finalweight), margin=2)
##             0         1
## No  0.8863434 0.6630114
## Yes 0.1136566 0.3369886

Codes in the weighted data file

parenthood=Yes (parents),parenthood=No(non-parents)

agegroup=1(age<20), agegroup=2(age>=20 & age<22),agegroup=3 (age>=22 & age<25),agegroup=4 (age>=25 & age!=.)

binary_gender=1 (Female),binary_gender=2 (Male

race3=0(Other),race3=1(Asian),race3=2(Black or African American),race3=3(Hispanic or Latino or Spanish origin of any race),race3=4 (White or Caucasian)

graduate=0(undergraduate),graduate=1(graduate)

data$parenthood<-as.factor(data$parenthood)
data$agegroup<-as.factor(data$agegroup)
data$binary_gender<-as.factor(data$binary_gender)#1=female, 2=male
data$race3<-as.factor(data$race3)
data$graduate<-as.factor(data$graduate)

t-tests (comparing parents against non-parents)

Social Support

######################  Social Support #################################################################
#weighted
Hmisc::describe(data$socialsupport_both_mean, weights = data$finalweight)
## data$socialsupport_both_mean 
##        n  missing distinct     Info     Mean 
##    12375     2349        5    0.881    3.445 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency    148  1466  4679  4896  1186
## Proportion 0.012 0.118 0.378 0.396 0.096
t.test(socialsupport_both_mean~parenthood, data=data, weights = data$finalweight, var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  socialsupport_both_mean by parenthood
## t = -2.8398, df = 605, p-value = 0.004665
## alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
## 95 percent confidence interval:
##  -0.4107835 -0.0749049
## sample estimates:
##  mean in group No mean in group Yes 
##          3.440083          3.682927

Academic Difficulty

###################### academic_difficulty ##########################################################
#weighted
Hmisc::describe(data$academic_diffty_both_mean, weights = data$finalweight)
## data$academic_diffty_both_mean 
##        n  missing distinct     Info     Mean 
##    11049     3675        5    0.897    3.381 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency     70  1719  4545  3356  1359
## Proportion 0.006 0.156 0.411 0.304 0.123
t.test(academic_diffty_both_mean~parenthood, data=data, weights = data$finalweight, var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  academic_diffty_both_mean by parenthood
## t = 3.0432, df = 540, p-value = 0.002454
## alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
## 95 percent confidence interval:
##  0.1058207 0.4911664
## sample estimates:
##  mean in group No mean in group Yes 
##          3.381062          3.082569

Psychosocioemotional Health Issues

######################  psycsocemo_health_issues ##########################################################
#weighted
Hmisc::describe(data$psycsocemo_health_both_mean, weights = data$finalweight)
## data$psycsocemo_health_both_mean 
##        n  missing distinct     Info     Mean 
##    11361     3363        5    0.888    3.592 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency     42  1343  3469  4866  1641
## Proportion 0.004 0.118 0.305 0.428 0.144
t.test(psycsocemo_health_both_mean~parenthood, data=data, weights = data$finalweight, var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  psycsocemo_health_both_mean by parenthood
## t = 2.4613, df = 555, p-value = 0.01415
## alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
## 95 percent confidence interval:
##  0.04668813 0.41572232
## sample estimates:
##  mean in group No mean in group Yes 
##          3.621681          3.390476

Multiple Regression Analysisz

Predicting psychosocioemotional health issues

reg_psycsocemo_health_both<-lm(psycsocemo_health_both_mean~age + + binary_gender + race3 + graduate + parenthood + socialsupport_both_mean + financial_ins_both_mean + physical_health_both_mean+negative_exp_gen_both_mean+res_aware_both_mean+res_use_both_mean, data=data,weights = data$finalweight, var.equal=TRUE)

summary(reg_psycsocemo_health_both)
## 
## Call:
## lm(formula = psycsocemo_health_both_mean ~ age + +binary_gender + 
##     race3 + graduate + parenthood + socialsupport_both_mean + 
##     financial_ins_both_mean + physical_health_both_mean + negative_exp_gen_both_mean + 
##     res_aware_both_mean + res_use_both_mean, data = data, weights = data$finalweight, 
##     var.equal = TRUE)
## 
## Weighted Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.7646 -1.4429  0.1523  1.5828 10.8534 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.340462   0.305788   7.654 1.44e-13 ***
## age                         0.009717   0.004898   1.984 0.047956 *  
## binary_gender2             -0.031942   0.058456  -0.546 0.585069    
## race31                     -0.224753   0.194028  -1.158 0.247402    
## race32                     -0.312628   0.120877  -2.586 0.010048 *  
## race33                      0.110757   0.151485   0.731 0.465116    
## race34                     -0.177643   0.108040  -1.644 0.100904    
## graduate1                  -0.183319   0.089324  -2.052 0.040783 *  
## parenthoodYes              -0.153778   0.104915  -1.466 0.143496    
## socialsupport_both_mean    -0.194628   0.039873  -4.881 1.52e-06 ***
## financial_ins_both_mean     0.080372   0.040212   1.999 0.046309 *  
## physical_health_both_mean   0.113511   0.031607   3.591 0.000369 ***
## negative_exp_gen_both_mean  0.351640   0.037877   9.284  < 2e-16 ***
## res_aware_both_mean        -0.076619   0.034335  -2.232 0.026193 *  
## res_use_both_mean           0.078480   0.049987   1.570 0.117193    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.584 on 405 degrees of freedom
##   (318 observations deleted due to missingness)
## Multiple R-squared:  0.5598, Adjusted R-squared:  0.5446 
## F-statistic: 36.79 on 14 and 405 DF,  p-value: < 2.2e-16

Predicting academic difficulty

reg_academic_diffty_both_mean<-lm(academic_diffty_both_mean~age + binary_gender + race3 + graduate + parenthood + socialsupport_both_mean + financial_ins_both_mean + physical_health_both_mean + psycsocemo_health_both_mean +negative_exp_gen_both_mean+res_aware_both_mean+res_use_both_mean, data=data, weights = data$finalweight, var.equal=TRUE)

summary(reg_academic_diffty_both_mean)
## 
## Call:
## lm(formula = academic_diffty_both_mean ~ age + binary_gender + 
##     race3 + graduate + parenthood + socialsupport_both_mean + 
##     financial_ins_both_mean + physical_health_both_mean + psycsocemo_health_both_mean + 
##     negative_exp_gen_both_mean + res_aware_both_mean + res_use_both_mean, 
##     data = data, weights = data$finalweight, var.equal = TRUE)
## 
## Weighted Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.9572 -1.5377  0.0451  1.5860  8.3100 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  1.030413   0.337804   3.050 0.002445 ** 
## age                          0.003766   0.005134   0.734 0.463635    
## binary_gender2               0.188868   0.059949   3.150 0.001758 ** 
## race31                      -0.049806   0.197089  -0.253 0.800627    
## race32                      -0.244506   0.127229  -1.922 0.055374 .  
## race33                      -0.068956   0.160077  -0.431 0.666878    
## race34                      -0.347905   0.113466  -3.066 0.002322 ** 
## graduate1                   -0.191759   0.092668  -2.069 0.039186 *  
## parenthoodYes               -0.027261   0.106857  -0.255 0.798766    
## socialsupport_both_mean     -0.038395   0.042218  -0.909 0.363687    
## financial_ins_both_mean      0.277161   0.041316   6.708 7.07e-11 ***
## physical_health_both_mean   -0.002769   0.032802  -0.084 0.932770    
## psycsocemo_health_both_mean  0.179274   0.050813   3.528 0.000469 ***
## negative_exp_gen_both_mean   0.292907   0.042470   6.897 2.20e-11 ***
## res_aware_both_mean         -0.089898   0.035379  -2.541 0.011446 *  
## res_use_both_mean            0.102530   0.051325   1.998 0.046460 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.59 on 384 degrees of freedom
##   (338 observations deleted due to missingness)
## Multiple R-squared:  0.5927, Adjusted R-squared:  0.5768 
## F-statistic: 37.25 on 15 and 384 DF,  p-value: < 2.2e-16