Health Metrics: Some Quick Data Runs

Sat, Feb 15, 2020 2-minute read 348 words

In my previous post, I talked about quick and easy way to track physical health. In this post, I share some ways to slice and analyze that data.

Using original (not detrended) data, I can eyeball for potential trends in my physical health. There seems to be some cyclical patterns so I definitely need to look into time series analysis.

tracking health

Probability of Getting Sick

If I define “sick” as any instance when my health score was 3 or less, I then can look at the probabilities of being sick across dayparts and days of the week:

# we define "sick" using original raw scores:
    mutate(sick=ifelse(Health <=3,1,0)) %>% 

# DATA probability of being sick by daypart and weekdays
sickDpWkd<-daypartdata %>% 
    select(daypart,wkday,sick) %>% 
    group_by(daypart,wkday) %>% 
    summarise_all(funs(mean)) %>% 
    ungroup() %>% 
    mutate(sick=round(100*sick,1)) %>% 
    mutate(daypart=factor(daypart,levels=c("AM","DA","EV"))) %>% 
    mutate(wkday=factor(wkday,levels=c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"))) 
    
# CHART probability of sickness by daypart and weekday
ggplot(sickDpWkd, 
       aes(x=wkday, 
           y=sick)) +
  geom_col(color="red", 
            fill="red",
            width=.1,
             size = 1) +
  labs (x = "Weekday",
        y = "",
        title = "Probability of Being Sick: Daypart x Day of the Week",
        subtitle = "") +
  theme_minimal() + 
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank())+
  ylim(0,50)+
  facet_wrap(~daypart,nrow=3)
ggsave("./IMAGES/HealthSickByDpWkd.png")    

The probability of me being sick seems to be higherst on Tuesdays and Fridays evenings:

tracking health

Symptoms and Ailments Breakdown

I can also look at the frequency of symptoms and their combinations:


library(UpSetR)
symptoms<-dailydata %>% 
    select(dmy,headache:eyes) %>% 
    mutate(combo=rowSums(.[,-1])) 
symptoms<-as.data.frame(symptoms)
upset(symptoms,
     sets=c("headache","cough","congestion","sorethroat","chills","bloating","backpain",
            "armpain","eyes","footpain","acidreflux"),
            order.by="freq",sets.bar.color = "red",matrix.color="red",show.numbers=FALSE)
ggsave("./IMAGES/HealthSymptoms.png")

tracking health

Quantifying Severity of Symptoms

By regressing the symptoms and ailments on the overall health score, I can estimate their “severity” in a sense of how much they affect my health:


library(broom)
# relationship between Health and Symptoms
SymptomsXHealth<-hourlydata %>% 
  select(health,headache:eyes) 

mod<-lm(health~.,data=SymptomsXHealth)

tidy(mod)
parameters <- tidy(mod) %>% 
  mutate(
    low = estimate - 1.96*std.error,
    high = estimate + 1.96*std.error
  ) %>% 
  rename(symptom=term,severity=estimate)

ggplot(parameters, aes(severity, symptom, xmin = low, xmax = high, height = 0)) +
  geom_point() +
  geom_errorbarh()+
  theme_minimal()
ggsave("./IMAGES/SymptomsSeverity.png")

It looks like back pain, dizziness, sore throat, headache, chills and allergy had the highest negative impact on my overall health:
tracking health

Coming next: predictive models of my health and symptoms, using sleep and weather data.