--- title: "Reliability of SAM threat and challenge and COPE" output: html_notebook --- ```{r libraries, message=FALSE, warning=FALSE, include=FALSE, cache=FALSE} library(conflicted) library(here) library(tidyverse) library(magrittr) library(lavaan) library(kableExtra) conflicts_prefer( readr::col_factor, purrr::discard, dplyr::filter, dplyr::lag, purrr::set_names, tidyr::extract, kableExtra::group_rows ) ``` ```{r style, include=FALSE, cache=FALSE} styler::style_file( here("statistical_analysis", "scale_reliability.Rmd"), scope = "tokens", indent_by = 4L ) ``` The data were preprocessed and cleaned using [expl_esm_labels.py](../exploration/expl_esm_labels.py) script and read as csv here. ```{r read_data} COL_TYPES <- cols( .default = col_double(), participant_id = col_factor(), username = col_factor(), device_id = col_factor(), esm_trigger = col_factor(), esm_instructions = col_factor(), double_esm_user_answer_timestamp = col_double(), datetime_lj = col_datetime(format = ""), date_lj = col_date(format = ""), time = col_factor(), esm_user_answer = col_factor() ) df_SAM <- read_csv(here("data", "raw", "df_esm_SAM_threat_challenge.csv"), col_types = COL_TYPES) df_COPE <- read_csv(here("data", "raw", "df_esm_COPE.csv"), col_types = COL_TYPES) ``` Demonstrate factor analysis for a single participant. ```{r} df_COPE %>% group_by(question_id, questionnaire_id) %>% count() ```