--- title: "Stressful event detection" output: html_notebook --- ```{r chunk_options, include=FALSE} knitr::opts_chunk$set( comment = "#>", echo = FALSE, fig.width = 6 ) ``` ```{r libraries, include=FALSE} library(knitr) library(kableExtra) library(RColorBrewer) library(magrittr) library(tidyverse) ``` ```{r fig_setup, include=FALSE} accent <- RColorBrewer::brewer.pal(7, "Accent") ``` ```{r read_data, include=FALSE} podatki <- read_csv("E:/STRAWresults/stressfulness_event_with_target_0_ver2/input_appraisal_stressfulness_event_mean.csv") podatki %<>% mutate(pid = as_factor(pid)) ``` # Event descriptions Participants were asked "Was there a particular event that created tension in you?" with the following options: - 0 - No - 1 - Yes, slightly - 2 - Yes, moderately - 3 - Yes, considerably - 4 - Yes, extremely If they answered anything but "No", they were also asked about the event's perceived threat (e.g. "Did this event make you feel anxious?") and challenge (e.g. "How eager are you to tackle this event?"). We only consider general "stressfulness" in this presentation. Most of the time, nothing stressful happened: ```{r target_table} kable(table(podatki$target), col.names = c("stressfulness", "frequency")) %>% kable_styling(full_width = FALSE) ``` Most participants had somewhere between 0 and 10 stressful events. ```{r target_distribution} podatki %>% group_by(pid) %>% summarise(no_of_events = sum(target > 0)) %>% ggplot(aes(no_of_events)) + geom_histogram(binwidth = 1, fill = accent[1]) + coord_cartesian(expand = FALSE) + labs(x = "Number of events per participant") + theme_classic() ``` When a stressful event occurred, participants mostly perceived it as slightly to moderately stressful on average. ```{r mean_stressfulness_distribution} podatki %>% filter(target > 0) %>% group_by(pid) %>% summarise(mean_stressfulness = mean(target)) %>% ggplot(aes(mean_stressfulness)) + geom_histogram(binwidth = 0.1, fill = accent[1]) + coord_cartesian(expand = FALSE) + labs(x = "Mean stressfulness per participant") + theme_classic() ``` # Problem description We are trying to predict whether a stressful event occurred, i.e. stressfulness > 0, or not (stressfulness == 0). First