-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShell-File.Rmd
More file actions
80 lines (45 loc) · 2.42 KB
/
Copy pathShell-File.Rmd
File metadata and controls
80 lines (45 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "Shell File: CAnD3 Data Activity"
author: "Tyler Bruefach"
date: "9/22/2021"
output: html_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = F)
```
***
## Reproducing the Analyses
### Cleaning Data
First, run the script named **"Cleaning Data.R"** to complete the following tasks:
1. Load required packages for analyses.
2. Converting data from the GSS into a tibble.
3. Cleaning and coding variables to be used in the analyses.
4. Dropping all variables but the ones used in analyses.
5. Labeling those variables.
```{r, code=xfun::read_utf8('Cleaning Data.R'), include = FALSE}
```
***
### Handling Missing Data
Next, you should run the script **"Handing Missing Data.R"**. This script completes the following tasks to handle missing data using listwise deletion:
1. Recodes missing values of self-rated health and self-rated mental health (other measures were assigned missing values during the cleaning phase).
2. Creates an index called "sampmiss" that is a count of how many variables that each respondent has missing values.
3. Creates a dataset called "sample" that only contains cases with no missing values.
```{r, code=xfun::read_utf8('Handling Missing Data.R'), include = FALSE}
```
***
### Producing the Descriptive Table (Table 1)
The sample is now ready for producing descriptive and inferential statistics. Run **"Table 1.R"** to create a descriptive table. This table provides descriptive statistics across respondents' sex.
***
```{r, code=xfun::read_utf8('Table 1.R')}
tbl_1 %>% as_gt()
```
***
We find that there are some slight differences in the distribution of mental health and education across people identifying as male and female. Male and female respondents had nearly identical distributions of self-rated health. Although a greater proportion of female respondents had more than a secondary
degree than male respondents, they also had lower household income.
***
### Producing the Regression Table (Table 2)
Finally, you should run **"Table 2.R"** to create a table featuring two multivariable regressions. This table provides descriptive statistics across respondents' sex. Findings suggest that education is associated with better health, but that female respondents gain a greater health-benefit from earning a postsecondary degree than male respondents:
***
```{r, code=xfun::read_utf8('Table 2.R')}
tbl_2 %>% as_gt()
```