ben-domingue / irw

Code related to data for the Item Response Warehouse
https://datapages.github.io/irw/
7 stars 9 forks source link

Replication Data for: Psychometric Properties of the CES-D Scale in Older Filipinos #507

Closed ben-domingue closed 3 weeks ago

ben-domingue commented 1 month ago

https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/UT9RVL

KingArthur0205 commented 3 weeks ago

CESDS_df: 11 items, scale from 1 to 3. Total 5209 participants.

KingArthur0205 commented 3 weeks ago

Data: RD_PPCSEDSOF_Afable_2023.csv

Code:

# Paper: 
# Data: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/UT9RVL
library(haven)
library(dplyr)
library(tidyr)
library(readxl)

remove_na <- function(df) {
  df <- df[!(rowSums(is.na(df[, -which(names(df) %in% c("id"))])) == (ncol(df) - 1)), ]
  return(df)
}

CESDS_df <- read_dta("Replication Data Set - CES-D Scale in Older Filipinos.dta")

CESDS_df[] <- lapply(CESDS_df, function(col) { # Remove column labels for each column
  attr(col, "label") <- NULL
  return(col)
})

CESDS_df <- CESDS_df |>
  select(starts_with("P1SD1"))
CESDS_df = remove_na(CESDS_df)

CESDS_df <- CESDS_df %>%
  mutate(id = row_number() )

CESDS_df <- pivot_longer(CESDS_df, 
                                cols = -id, 
                                names_to = "item", 
                                values_to = "resp")

save(CESDS_df, file="RD_PPCSEDSOF_Afable_2023.Rdata")
write.csv(CESDS_df, "RD_PPCSEDSOF_Afable_2023.csv", row.names=FALSE)
ben-domingue commented 3 weeks ago

gotta love an easy one.

KingArthur0205 commented 3 weeks ago

PR for this issue: https://github.com/ben-domingue/irw/pull/586