setwd("/storage01/users/nsn769/projectadol/0920/")
library(haven)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
library(table1)
##
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
#library(gtsummary)
df<-read_dta("paa_nhr2.dta")
df<-filter(df, !is.na(df$imm3))
dim(df)
## [1] 9205 3105
df<-filter(df, !is.na(df$h1eng_speak) & !is.na(df$stay_us) & !is.na(df$h1prej))
nrow(df)
## [1] 9010
#9010
### "i.incr ib5.h1rmeduc ib3.h1mworkstat"
df<-filter(df, !is.na(df$incr) & !is.na(df$h1rmeduc) & !is.na(df$h1pworkstat))
nrow(df)
## [1] 9010
## 9010
df<-filter(df, !is.na(df$w1age) & !is.na(df$h1sex) & !is.na(df$aregion) &
!is.na(df$aurban) & !is.na(df$sibl) & !is.na(df$family) & !is.na(df$h1eng_speak) &
!is.na(df$stay_us) & !is.na(df$h1prej) & !is.na(df$incr) & !is.na(df$h1rmeduc) &
!is.na(df$h1pworkstat) & !is.na(df$family_attach) & !is.na(df$close_par) & !is.na(df$par_chi_conf) &
!is.na(df$h1religion) & !is.na(df$s_support1) & !is.na(df$h1nhood))
nrow(df)
## [1] 8767
### 8767
df$w1dpr20<-as.factor(df$w1dpr20)
df$h1sex<-as.factor(df$h1sex)
df$aregion<-as.factor(df$aregion)
df$aurban<-as.factor(df$aurban)
df$family<-as.factor(df$family)
df$h1eng_speak<-as.factor(df$h1eng_speak)
df$incr<-as.factor(df$incr)
df$h1prej<-as.factor(df$h1prej)
df$h1rmeduc<-as.factor(df$h1rmeduc)
df$h1pworkstat<-as.factor(df$h1pworkstat)
df$par_chi_conf<-as.factor(df$par_chi_conf)
### Labels
label(df$w1age)<-"Age"
label(df$h1sex)<-"Gender"
label(df$h1phh)<-"Resident parents"
label(df$family)<-"Family structure"
label(df$h1eng_speak)<-"Speaks english"
label(df$stay_us)<-"Years in USA"
label(df$h1pworkstat)<-"Parent work status"
### Recodes
df<-df%>%
mutate(#imm3=Recode(imm3,recodes="1='NH White US born';2='Mexican immigrants';3='Chinese immigrants';else=NA"),
h1sex=Recode(h1sex,recodes="0='Male';1='Female';else=NA"),
family=Recode(family,recodes="1='Two biological parents';2='Steparent';3='Single parent';4='Other family form';else=NA"),
h1pworkstat=Recode(h1pworkstat,recodes="0='Does not work full time';1='Works full time';else=NA")
)
table1(~ dprx1 + w1dpr20 + w1age + h1sex + aregion + aurban + sibl + family+
h1eng_speak + stay_us + h1prej+
incr + h1rmeduc + h1pworkstat+
family_attach + close_par + par_chi_conf + h1religion + s_support1 + h1nhood |imm3,data=df)
## Warning in table1.formula(~dprx1 + w1dpr20 + w1age + h1sex + aregion + aurban
## + : Terms to the right of '|' in formula 'x' define table columns and are
## expected to be factors with meaningful labels.
| 1 (N=7737) |
2 (N=861) |
3 (N=169) |
Overall (N=8767) |
|
|---|---|---|---|---|
| dprx1 | ||||
| Mean (SD) | 12.7 (6.94) | 15.6 (7.12) | 14.1 (6.39) | 13.0 (7.00) |
| Median [Min, Max] | 11.0 [3.00, 54.0] | 15.0 [3.00, 47.0] | 13.0 [3.00, 36.0] | 12.0 [3.00, 54.0] |
| w1dpr20 | ||||
| 0 | 5582 (72.1%) | 454 (52.7%) | 104 (61.5%) | 6140 (70.0%) |
| 1 | 2155 (27.9%) | 407 (47.3%) | 65 (38.5%) | 2627 (30.0%) |
| Age | ||||
| Mean (SD) | 16.0 (1.67) | 16.6 (1.67) | 16.4 (1.61) | 16.1 (1.68) |
| Median [Min, Max] | 16.0 [11.6, 21.3] | 16.7 [11.9, 20.9] | 16.4 [12.6, 20.4] | 16.2 [11.6, 21.3] |
| h1sex | ||||
| Female | 3812 (49.3%) | 443 (51.5%) | 75 (44.4%) | 4330 (49.4%) |
| Male | 3925 (50.7%) | 418 (48.5%) | 94 (55.6%) | 4437 (50.6%) |
| aregion | ||||
| 1 | 1354 (17.5%) | 574 (66.7%) | 41 (24.3%) | 1969 (22.5%) |
| 2 | 2565 (33.2%) | 25 (2.9%) | 71 (42.0%) | 2661 (30.4%) |
| 3 | 2610 (33.7%) | 234 (27.2%) | 22 (13.0%) | 2866 (32.7%) |
| 4 | 1208 (15.6%) | 28 (3.3%) | 35 (20.7%) | 1271 (14.5%) |
| aurban | ||||
| 1 | 1760 (22.7%) | 404 (46.9%) | 89 (52.7%) | 2253 (25.7%) |
| 2 | 4176 (54.0%) | 433 (50.3%) | 76 (45.0%) | 4685 (53.4%) |
| 3 | 1801 (23.3%) | 24 (2.8%) | 4 (2.4%) | 1829 (20.9%) |
| see notes | ||||
| Mean (SD) | 1.36 (1.09) | 2.36 (1.42) | 1.31 (0.964) | 1.46 (1.16) |
| Median [Min, Max] | 1.00 [0, 10.0] | 2.00 [0, 10.0] | 1.00 [0, 5.00] | 1.00 [0, 10.0] |
| family | ||||
| Other family form | 442 (5.7%) | 46 (5.3%) | 6 (3.6%) | 494 (5.6%) |
| Single parent | 2136 (27.6%) | 157 (18.2%) | 14 (8.3%) | 2307 (26.3%) |
| Steparent | 1212 (15.7%) | 77 (8.9%) | 7 (4.1%) | 1296 (14.8%) |
| Two biological parents | 3947 (51.0%) | 581 (67.5%) | 142 (84.0%) | 4670 (53.3%) |
| Speaks english | ||||
| 0 | 7715 (99.7%) | 240 (27.9%) | 57 (33.7%) | 8012 (91.4%) |
| 1 | 22 (0.3%) | 621 (72.1%) | 112 (66.3%) | 755 (8.6%) |
| Years in USA | ||||
| Mean (SD) | 16.0 (1.67) | 13.8 (4.95) | 12.0 (5.31) | 15.7 (2.47) |
| Median [Min, Max] | 16.0 [11.6, 21.3] | 15.8 [0.750, 20.5] | 14.3 [0.663, 18.8] | 16.0 [0.663, 21.3] |
| h1prej | ||||
| 0 | 3874 (50.1%) | 527 (61.2%) | 115 (68.0%) | 4516 (51.5%) |
| 1 | 3863 (49.9%) | 334 (38.8%) | 54 (32.0%) | 4251 (48.5%) |
| incr | ||||
| 1 | 744 (9.6%) | 144 (16.7%) | 11 (6.5%) | 899 (10.3%) |
| 2 | 1473 (19.0%) | 231 (26.8%) | 17 (10.1%) | 1721 (19.6%) |
| 3 | 2152 (27.8%) | 96 (11.1%) | 29 (17.2%) | 2277 (26.0%) |
| 4 | 1440 (18.6%) | 357 (41.5%) | 91 (53.8%) | 1888 (21.5%) |
| 5 | 1928 (24.9%) | 33 (3.8%) | 21 (12.4%) | 1982 (22.6%) |
| h1rmeduc | ||||
| 1 | 864 (11.2%) | 541 (62.8%) | 47 (27.8%) | 1452 (16.6%) |
| 2 | 2362 (30.5%) | 113 (13.1%) | 30 (17.8%) | 2505 (28.6%) |
| 3 | 1946 (25.2%) | 58 (6.7%) | 15 (8.9%) | 2019 (23.0%) |
| 4 | 605 (7.8%) | 117 (13.6%) | 18 (10.7%) | 740 (8.4%) |
| 5 | 1960 (25.3%) | 32 (3.7%) | 59 (34.9%) | 2051 (23.4%) |
| h1pworkstat | ||||
| Does not work full time | 1185 (15.3%) | 165 (19.2%) | 15 (8.9%) | 1365 (15.6%) |
| Works full time | 6552 (84.7%) | 696 (80.8%) | 154 (91.1%) | 7402 (84.4%) |
| family_attach | ||||
| Mean (SD) | 2.35 (0.733) | 2.50 (0.734) | 2.06 (0.937) | 2.36 (0.740) |
| Median [Min, Max] | 2.00 [0, 3.00] | 3.00 [0, 3.00] | 2.00 [0, 3.00] | 3.00 [0, 3.00] |
| closeness with parents | ||||
| Mean (SD) | 4.22 (0.703) | 4.04 (0.737) | 4.08 (0.688) | 4.20 (0.708) |
| Median [Min, Max] | 4.25 [1.00, 5.00] | 4.25 [1.00, 5.00] | 4.25 [2.25, 5.00] | 4.25 [1.00, 5.00] |
| par_chi_conf | ||||
| 0 | 2005 (25.9%) | 160 (18.6%) | 38 (22.5%) | 2203 (25.1%) |
| 1 | 5732 (74.1%) | 701 (81.4%) | 131 (77.5%) | 6564 (74.9%) |
| h1religion | ||||
| Mean (SD) | 2.32 (1.06) | 1.91 (0.863) | 2.83 (1.26) | 2.29 (1.05) |
| Median [Min, Max] | 2.00 [1.00, 4.00] | 1.67 [1.00, 4.00] | 3.33 [1.00, 4.00] | 2.00 [1.00, 4.00] |
| s_support1 | ||||
| Mean (SD) | 31.9 (4.67) | 31.8 (5.05) | 31.4 (4.44) | 31.8 (4.70) |
| Median [Min, Max] | 32.0 [0, 40.0] | 32.0 [12.0, 40.0] | 32.0 [14.0, 40.0] | 32.0 [0, 40.0] |
| h1nhood | ||||
| Mean (SD) | 0.786 (0.260) | 0.711 (0.296) | 0.599 (0.290) | 0.775 (0.267) |
| Median [Min, Max] | 1.00 [0, 1.00] | 0.750 [0, 1.00] | 0.500 [0, 1.00] | 0.750 [0, 1.00] |