39 lines
880 B
R
39 lines
880 B
R
options(scipen = 999)
|
|
|
|
library(dplyr)
|
|
library(car)
|
|
library(lmtest)
|
|
library(stargazer)
|
|
library(sandwich)
|
|
library(lmtest)
|
|
|
|
setwd("C:/Users/irina/Documents/DND/EOHI/eohi1")
|
|
|
|
df <- read.csv("ehi1.csv")
|
|
|
|
data <- df %>%
|
|
select(eohiDGEN_mean, ehi_global_mean, demo_sex, demo_age_1) %>%
|
|
filter(demo_sex != "Prefer not to say")
|
|
|
|
str(data)
|
|
colSums(is.na(data))
|
|
sapply(data, class)
|
|
|
|
# Create dummy variable for sex (0 = Male, 1 = Female)
|
|
data$sex_dummy <- ifelse(data$demo_sex == "Female", 1, 0)
|
|
|
|
# Verify the dummy coding
|
|
print(table(data$demo_sex, data$sex_dummy))
|
|
|
|
#descriptives
|
|
|
|
# Descriptives for age
|
|
print(summary(data$demo_age_1))
|
|
sd(data$demo_age_1, na.rm = TRUE)
|
|
|
|
# Descriptives for sex (frequency table)
|
|
print(table(data$demo_sex))
|
|
print(prop.table(table(data$demo_sex)))
|
|
|
|
# Descriptives for sex dummy variable
|
|
print(table(data$sex_dummy)) |