loading packages

library(tidyverse)
library(here)
library(anomalize)

loading data

d <- read_csv("prosodic-features-filtered-key-vars.csv")

Prepping the data - needs a date-time column

d <- d %>%
  select(frame_time_minutes_aligned, pcm_loudness_sma, F0_SMA) %>% 
  mutate(frame_time = lubridate::ms(frame_time_minutes_aligned * 60)) %>%
  mutate(frame_date_time = lubridate::as_datetime(frame_time))

running anomaly detection and plotting output for pcm_loudness

dd <- d %>%
  filter(!is.na(pcm_loudness_sma)) %>%  # needs no missing vals
  select(pcm_loudness_sma, date = frame_date_time)

dd_1 <- dd %>% 
  time_decompose(pcm_loudness_sma)

a_1 <- anomalize(dd_1, remainder)

a_1$date <- as.vector(as.numeric(a_1$date))

p <- a_1 %>%
  as_tibble() %>% 
  mutate(date = as.vector(as.numeric(date))) %>% 
  mutate(date = date/60/60) %>% 
  ggplot(aes(x = date, y = remainder, color = anomaly)) +
  geom_point() +
  xlab("time stamp (minutes)")

plotly::ggplotly(p)

running anomaly detection and plotting output for F0_SMA

dd <- d %>%
  filter(!is.na(F0_SMA)) %>% 
  select(F0_SMA, date = frame_date_time)

dd_2 <- dd %>% 
  time_decompose(F0_SMA)

a_2 <- anomalize(dd_2, remainder)

a_2$date <- as.vector(as.numeric(a_2$date))

p <- a_2 %>%
  as_tibble() %>% 
  mutate(date = as.vector(as.numeric(date))) %>% 
  mutate(date = date/60/60) %>% 
  ggplot(aes(x = date, y = remainder, color = anomaly)) +
  geom_point() +
  xlab("time stamp (minutes)")

plotly::ggplotly(p)