Chapter 1: Introduction

1.1 Background

Bellabeat is a high-tech manufacturer of health-focused products for women, founded by Sršen and Sando Mur in 2013. This company has experienced rapid growth since its inception, with multiple products available through online retailers and Bellabeat’s own e-commerce channel. Bellabeat invests heavily in digital marketing, with a strong focus on Google Search, Facebook and Instagram pages, Twitter engagement, and video ads on Youtube and display ads on the Google Display Network. The company is in need of a new marketing plan and the best way to achieve this, is to conduct it according to customers prefrences and needs. By analyzing non-bellabeat smart device usage data, we will gain insights about how customers are currently using these kind of products and identify trends that can inform marketing strategy.

1.2 Products

  • Bellabeat app The Bellabeat app provides users with health data related to their activity, sleep, stress, menstrual cycle, and mindfulness habits.The Bellabeat app connects to their line of smart wellness products.
  • Leaf: Bellabeat’s classic wellness tracker can be worn as a bracelet, necklace, or clip, and track activity, sleep, and stress.
  • Time: This wellness watch connect to the app and track user activity, sleep, and stress.
  • Spring: This is a water bottle that tracks daily water intake using smart technology to ensure that you are appropriately hydrated throughout the day.
  • Bellabeat membership: Bellabeat offers a subscription-based membership whuich gives users 24/7 access to fully personalized guidance on nutrition, activity, sleep, health and beauty, and mindfulness based on their lifestyle and goals.

Chapter 2: Data Analysis

2.1 Ask

First, we demonstrate what we are looking for in this process, and also we establish our business plan and metrics. By doing so, the analysis will be more straightforward.

2.1.1 Business plan

Analyse the data from non-bellabeat smart devices to gain insights about the trends in activities and sleep patterns and apply it for a new marketing strategy.

2.1.2 Questions and hypotheses

  • What are the trends in people’s activity?

  • Which kind of activity is better for burning more calories?

  • which one is more important, running distance or time?

  • How can we conduct a new marketing startegy with this data?

2.1.3 Stakeholders

  • Urška Sršen- Cofounder & Chief Creative Officer, has a background in artistry which aids her in creating informative and elegantly designed technology to improve the lives of women.

  • Sando Mur- Cofounder & Mathematician; an important figure of the Bellabeat executive team.

  • Bellabeat Marketing Analytics Team: A team of data analysts responsible for collecting, analyzing, and reporting data that helps guide Bellabeat’s marketing strategy.

2.2 Prepare

2.2.1 Data

The Fitbit Fitness Tracker Data dataset was used for this case study. Möbius uploaded the dataset on Kaggle where it was then downloaded.

2.2.2 Limtations of the data

  • This data is collected in 2016, which might be outdated for finding the current patterns.
  • Number of tracked devices is small.
  • Demographics, including age, gender, height, weight, and living location are not provided.
  • The data is collected during a 31-day period.
  • There aren’t any guidelines provided for the tracked customers, so the data may be corrupted by many things.

2.2.3 Preparing packages and datasets

We used these three packages for the study. First we load them.

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## âś” dplyr     1.1.4     âś” readr     2.1.4
## âś” forcats   1.0.0     âś” stringr   1.5.1
## âś” ggplot2   3.4.4     âś” tibble    3.2.1
## âś” lubridate 1.9.3     âś” tidyr     1.3.0
## âś” purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## âś– dplyr::filter() masks stats::filter()
## âś– dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(ggpubr)

Next, we import our datasets.

daily_activity <- read.csv("daily_activity.csv")
daily_sleep <- read.csv("sleep_day.csv")
hourly_activity <- read.csv("hourly_activity.csv")
hourly_intensity <- read.csv("hourly_intensity.csv")
hourly_steps <- read.csv("hourly_steps.csv")

Finally, we can take a look at each dataset to find out about them. We chose two daily and three hourly tracked datasets. “daily_activity” dataframe is more comprehensive and contain data about differnt types of activity, travelled distance, number of steps and also burned calories.

head(daily_activity)
##           Id ActivityDate TotalSteps TotalDistance TrackerDistance
## 1 1503960366    4/12/2016      13162          8.50            8.50
## 2 1503960366    4/13/2016      10735          6.97            6.97
## 3 1503960366    4/14/2016      10460          6.74            6.74
## 4 1503960366    4/15/2016       9762          6.28            6.28
## 5 1503960366    4/16/2016      12669          8.16            8.16
## 6 1503960366    4/17/2016       9705          6.48            6.48
##   LoggedActivitiesDistance VeryActiveDistance ModeratelyActiveDistance
## 1                        0               1.88                     0.55
## 2                        0               1.57                     0.69
## 3                        0               2.44                     0.40
## 4                        0               2.14                     1.26
## 5                        0               2.71                     0.41
## 6                        0               3.19                     0.78
##   LightActiveDistance SedentaryActiveDistance VeryActiveMinutes
## 1                6.06                       0                25
## 2                4.71                       0                21
## 3                3.91                       0                30
## 4                2.83                       0                29
## 5                5.04                       0                36
## 6                2.51                       0                38
##   FairlyActiveMinutes LightlyActiveMinutes SedentaryMinutes Calories
## 1                  13                  328              728     1985
## 2                  19                  217              776     1797
## 3                  11                  181             1218     1776
## 4                  34                  209              726     1745
## 5                  10                  221              773     1863
## 6                  20                  164              539     1728
head(daily_sleep)
##           Id              SleepDay TotalSleepRecords TotalMinutesAsleep
## 1 1503960366 4/12/2016 12:00:00 AM                 1                327
## 2 1503960366 4/13/2016 12:00:00 AM                 2                384
## 3 1503960366 4/15/2016 12:00:00 AM                 1                412
## 4 1503960366 4/16/2016 12:00:00 AM                 2                340
## 5 1503960366 4/17/2016 12:00:00 AM                 1                700
## 6 1503960366 4/19/2016 12:00:00 AM                 1                304
##   TotalTimeInBed
## 1            346
## 2            407
## 3            442
## 4            367
## 5            712
## 6            320
head(hourly_activity)
##           Id          ActivityHour Calories
## 1 1503960366 4/12/2016 12:00:00 AM       81
## 2 1503960366  4/12/2016 1:00:00 AM       61
## 3 1503960366  4/12/2016 2:00:00 AM       59
## 4 1503960366  4/12/2016 3:00:00 AM       47
## 5 1503960366  4/12/2016 4:00:00 AM       48
## 6 1503960366  4/12/2016 5:00:00 AM       48
head(hourly_intensity)
##           Id          ActivityHour TotalIntensity AverageIntensity
## 1 1503960366 4/12/2016 12:00:00 AM             20         0.333333
## 2 1503960366  4/12/2016 1:00:00 AM              8         0.133333
## 3 1503960366  4/12/2016 2:00:00 AM              7         0.116667
## 4 1503960366  4/12/2016 3:00:00 AM              0         0.000000
## 5 1503960366  4/12/2016 4:00:00 AM              0         0.000000
## 6 1503960366  4/12/2016 5:00:00 AM              0         0.000000
head(hourly_steps)
##           Id          ActivityHour StepTotal
## 1 1503960366 4/12/2016 12:00:00 AM       373
## 2 1503960366  4/12/2016 1:00:00 AM       160
## 3 1503960366  4/12/2016 2:00:00 AM       151
## 4 1503960366  4/12/2016 3:00:00 AM         0
## 5 1503960366  4/12/2016 4:00:00 AM         0
## 6 1503960366  4/12/2016 5:00:00 AM         0

2.3 Process

In this part of data analysis, we need to clean the data to be sure about the analysis results.

2.3.1 Checking and removing duplicates

By running these lines, we find about duplicate entities in the dataframes.

sum(duplicated(daily_activity))
## [1] 0
sum(duplicated(daily_sleep))
## [1] 3
sum(duplicated(hourly_activity))
## [1] 0
sum(duplicated(hourly_intensity))
## [1] 0
sum(duplicated(hourly_steps))
## [1] 0

As you can see, the “daily_sleep” dataframe has 3 duplicates, which we’ll remove it with the next line of code.

daily_sleep <- distinct(daily_sleep)
sum(duplicated(daily_sleep))
## [1] 0

There are no more duplicates in this dataframe.

2.3.2 Checking Null values

Same as duplicates, the N/A values should be replaced with the correct value if present.

sum(is.na(daily_activity))
## [1] 0
sum(is.na(daily_sleep))
## [1] 0
sum(is.na(hourly_activity))
## [1] 0
sum(is.na(hourly_intensity))
## [1] 0
sum(is.na(hourly_steps))
## [1] 0

Fortunately, none was found.

2.3.3 Formatting the data

In this part, we do the following to clean the data:

  • Removing unnecessary or duplicate columns.
  • Format the name of the columns; this can be easily done with “clean_names” function from janitor package.
  • Rename columns to a shorter and more practical format.
  • Format the dates as Y/M/D.
clean_daily_act <- daily_activity %>% 
  select (-c(TrackerDistance, LoggedActivitiesDistance, 
           SedentaryActiveDistance)) %>% 
  clean_names() %>% 
  rename(date = activity_date, total_dist = total_distance,
         vig_dist = very_active_distance, mod_dist = moderately_active_distance,
         light_dist = light_active_distance, vig_min= very_active_minutes,
         mod_min = fairly_active_minutes, light_min = lightly_active_minutes, 
         sed_min = sedentary_minutes) %>% 
  mutate(date = mdy(date), total_min = vig_min + mod_min + light_min)

As shown, the mentioned formatting was done on the first dataframe. We also do this for the rest of them.

clean_sleep <- daily_sleep %>% 
  mutate(time_to_sleep = TotalTimeInBed - TotalMinutesAsleep) %>% 
  select(-c(TotalSleepRecords, TotalTimeInBed)) %>% 
  clean_names() %>% 
  rename(date = sleep_day, asleep_min = total_minutes_asleep) %>% 
  mutate(date = as_date(mdy_hms(date)))
  
clean_hourly_act <- hourly_activity %>% 
  clean_names() %>% 
  rename(hour = activity_hour) %>% 
  mutate(hour = mdy_hms(hour))

clean_hourly_int <- hourly_intensity %>% 
  clean_names() %>% 
  rename(hour = activity_hour) %>% 
  mutate(hour = mdy_hms(hour))

clean_hourly_steps <- hourly_steps %>% 
  clean_names() %>% 
  rename(hour = activity_hour) %>% 
  mutate(hour = mdy_hms(hour))

2.4 Analysis

2.4.1 Number of distinct values

First, find the number of observations in each dataframe.

n_distinct(clean_daily_act)
## [1] 940
n_distinct(clean_sleep)
## [1] 410
n_distinct(clean_hourly_act)
## [1] 22099
n_distinct(clean_hourly_int)
## [1] 22099
n_distinct(clean_hourly_steps)
## [1] 22099

2.4.2 Aggregation of dataframes

As mentioned before, there are two daily dataframes and three hourly dataframes. For ease of analysis, merge the dataframes by attributes which are consistent in each of them. In case of hourly data, this process will be done in two steps.

clean_daily_data <- merge(clean_daily_act, clean_sleep, by = c("id", "date"))
hourly <- merge(clean_hourly_act, clean_hourly_int, by = c("id", "hour"))
clean_hourly_data <- merge(hourly, clean_hourly_steps, by = c("id", "hour"))

2.4.3 Formatting wide data to long data

Also, we decided to make long versions of daily data. These new dataframes are used later for visualizing the data.

longer_dist <- clean_daily_data %>%
  select(id, date, vig_dist, mod_dist, light_dist, calories) %>% 
  pivot_longer(vig_dist:light_dist, names_to = "types_dist",
               values_to = "distances") %>% 
  mutate(types_dist = str_replace_all(types_dist, "vig_dist", "Vigorous")) %>%
  mutate(types_dist = str_replace_all(types_dist, "mod_dist", "Moderate")) %>% 
  mutate(types_dist = str_replace_all(types_dist, "light_dist", "Light"))

head(longer_dist)
## # A tibble: 6 Ă— 5
##           id date       calories types_dist distances
##        <dbl> <date>        <int> <chr>          <dbl>
## 1 1503960366 2016-04-12     1985 Vigorous       1.88 
## 2 1503960366 2016-04-12     1985 Moderate       0.550
## 3 1503960366 2016-04-12     1985 Light          6.06 
## 4 1503960366 2016-04-13     1797 Vigorous       1.57 
## 5 1503960366 2016-04-13     1797 Moderate       0.690
## 6 1503960366 2016-04-13     1797 Light          4.71
longer_min <- clean_daily_data %>%
  select(id, date, vig_min, mod_min, light_min, sed_min, asleep_min, calories) %>% 
  pivot_longer(vig_min:sed_min, names_to = "types_min",
               values_to = "minutes") %>% 
  mutate(types_min = str_replace_all(types_min, "vig_min", "Vigorous")) %>%
  mutate(types_min = str_replace_all(types_min, "mod_min", "Moderate")) %>% 
  mutate(types_min = str_replace_all(types_min, "light_min", "Light")) %>% 
  mutate(types_min = str_replace_all(types_min, "sed_min", "Sedentary"))

head(longer_min)
## # A tibble: 6 Ă— 6
##           id date       asleep_min calories types_min minutes
##        <dbl> <date>          <int>    <int> <chr>       <int>
## 1 1503960366 2016-04-12        327     1985 Vigorous       25
## 2 1503960366 2016-04-12        327     1985 Moderate       13
## 3 1503960366 2016-04-12        327     1985 Light         328
## 4 1503960366 2016-04-12        327     1985 Sedentary     728
## 5 1503960366 2016-04-13        384     1797 Vigorous       21
## 6 1503960366 2016-04-13        384     1797 Moderate       19

2.4.4 Summary of the data

Next, a descriptive analysis was done on the daily data which includes minimum, maximum, mean, median, and quartiles of the selected attributes.

clean_daily_data %>%                    
  select(total_steps, total_dist, total_min, vig_dist, mod_dist, light_dist, 
         vig_min, mod_min, light_min, sed_min, calories, asleep_min,
         time_to_sleep) %>% 
  summary()
##   total_steps      total_dist       total_min        vig_dist     
##  Min.   :   17   Min.   : 0.010   Min.   :  2.0   Min.   : 0.000  
##  1st Qu.: 5189   1st Qu.: 3.592   1st Qu.:206.5   1st Qu.: 0.000  
##  Median : 8913   Median : 6.270   Median :263.5   Median : 0.570  
##  Mean   : 8515   Mean   : 6.012   Mean   :259.5   Mean   : 1.446  
##  3rd Qu.:11370   3rd Qu.: 8.005   3rd Qu.:315.5   3rd Qu.: 2.360  
##  Max.   :22770   Max.   :17.540   Max.   :540.0   Max.   :12.540  
##     mod_dist        light_dist       vig_min          mod_min      
##  Min.   :0.0000   Min.   :0.010   Min.   :  0.00   Min.   :  0.00  
##  1st Qu.:0.0000   1st Qu.:2.540   1st Qu.:  0.00   1st Qu.:  0.00  
##  Median :0.4200   Median :3.665   Median :  9.00   Median : 11.00  
##  Mean   :0.7439   Mean   :3.791   Mean   : 25.05   Mean   : 17.92  
##  3rd Qu.:1.0375   3rd Qu.:4.918   3rd Qu.: 38.00   3rd Qu.: 26.75  
##  Max.   :6.4800   Max.   :9.480   Max.   :210.00   Max.   :143.00  
##    light_min        sed_min          calories      asleep_min   
##  Min.   :  2.0   Min.   :   0.0   Min.   : 257   Min.   : 58.0  
##  1st Qu.:158.0   1st Qu.: 631.2   1st Qu.:1841   1st Qu.:361.0  
##  Median :208.0   Median : 717.0   Median :2207   Median :432.5  
##  Mean   :216.5   Mean   : 712.1   Mean   :2389   Mean   :419.2  
##  3rd Qu.:263.0   3rd Qu.: 782.8   3rd Qu.:2920   3rd Qu.:490.0  
##  Max.   :518.0   Max.   :1265.0   Max.   :4900   Max.   :796.0  
##  time_to_sleep   
##  Min.   :  0.00  
##  1st Qu.: 17.00  
##  Median : 25.50  
##  Mean   : 39.31  
##  3rd Qu.: 40.00  
##  Max.   :371.00

The same process was done also on hourly data. However, before summarizing this dataframe, the datetime variable has been separated into two. By doing so, “00:00:00” was recognized as N/A, which we changed it to the correct value again.

clean_hourly_data <- clean_hourly_data %>% 
  separate(hour, into = c("date", "hour"), sep = " ") %>% 
  mutate(hour = replace_na(hour, "00:00:00"))

Now, we group them by hour and do a summary.

summarized_hourly_date <-  clean_hourly_data %>%
  group_by(hour) %>% 
    summarize(avg_cal=mean(calories),
              avg_intensity = mean(total_intensity),
              avg_steps = mean(step_total))
head(summarized_hourly_date)
## # A tibble: 6 Ă— 4
##   hour     avg_cal avg_intensity avg_steps
##   <chr>      <dbl>         <dbl>     <dbl>
## 1 00:00:00    71.8         2.13      42.2 
## 2 01:00:00    70.2         1.42      23.1 
## 3 02:00:00    69.2         1.04      17.1 
## 4 03:00:00    67.5         0.444      6.43
## 5 04:00:00    68.3         0.633     12.7 
## 6 05:00:00    81.7         4.95      43.9

2.4.5 Correlation tests

Testing the association between these pair of continuous variables was done with Pearson R correlation coefficient. P-values of less than 0.001 were considered significant. In case of significant association, R coefficient comes to help for determining how strong this association is. It can range from -1 to 1, which negative values show negative association between the variables. The strength of association was indicated using the following guideline:

  • 0.0 - 0.19 = Very weak
  • 0.2 - 0.39 = Weak
  • 0.4 - 0.59 = Moderate
  • 0.6 - 0.79 = Strong
  • 0.8 - 1.00 = Very strong

As an example, we did the correlation test for three of the main variables against burnt calories. Later on, these tests will be provided with a their respective plot.

cor.test(clean_daily_data$total_dist, clean_daily_data$calories, 
         method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  clean_daily_data$total_dist and clean_daily_data$calories
## t = 12.336, df = 408, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.4469291 0.5883638
## sample estimates:
##       cor 
## 0.5212162
cor.test(clean_daily_data$total_min, clean_daily_data$calories, 
         method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  clean_daily_data$total_min and clean_daily_data$calories
## t = 8.5546, df = 408, p-value = 2.417e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.3046418 0.4691127
## sample estimates:
##       cor 
## 0.3899832
cor.test(clean_daily_data$total_steps, clean_daily_data$calories, 
         method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  clean_daily_data$total_steps and clean_daily_data$calories
## t = 8.9816, df = 408, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.3221289 0.4840991
## sample estimates:
##       cor 
## 0.4063007

By testing these variables against burnt calories, we can conclude that there is a significant correlation with all three. However, the correlation between burnt calories and the distance in an activity is bigger in size.

2.4.6 Linear regression

Linear regression is a regression model that uses a straight line to describe the relationship between variables. Linear regression can be used to predict the value of a variable based on another one.

If the p-value shows significant correlation, we can make a linear regression model that predicts the dependent variable.

summary(lm(total_dist ~ calories , data = clean_daily_data))
## 
## Call:
## lm(formula = total_dist ~ calories, data = clean_daily_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.9766 -2.0377 -0.0575  1.7352  8.7412 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.0142759  0.4250321   2.386   0.0175 *  
## calories    0.0020919  0.0001696  12.336   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.601 on 408 degrees of freedom
## Multiple R-squared:  0.2717, Adjusted R-squared:  0.2699 
## F-statistic: 152.2 on 1 and 408 DF,  p-value: < 2.2e-16
summary(lm(total_min ~ calories , data = clean_daily_data))
## 
## Call:
## lm(formula = total_min ~ calories, data = clean_daily_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -216.218  -51.912   -4.233   61.107  259.695 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 146.27149   13.88675  10.533  < 2e-16 ***
## calories      0.04739    0.00554   8.555 2.42e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 84.98 on 408 degrees of freedom
## Multiple R-squared:  0.1521, Adjusted R-squared:   0.15 
## F-statistic: 73.18 on 1 and 408 DF,  p-value: 2.417e-16
summary(lm(total_steps ~ calories , data = clean_daily_data))
## 
## Call:
## lm(formula = total_steps ~ calories, data = clean_daily_data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -8007  -2995   -133   2662  11250 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 3193.604    621.529   5.138 4.31e-07 ***
## calories       2.227      0.248   8.982  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3803 on 408 degrees of freedom
## Multiple R-squared:  0.1651, Adjusted R-squared:  0.163 
## F-statistic: 80.67 on 1 and 408 DF,  p-value: < 2.2e-16

The most practical part for modeling, is the estimates in the coefficient section. If “a” is the estimated effect of the variable and “b” is the intercept, the model would be y = ax + b.

Later, you can see linear regression models on the plots. Thus, we intentionally avoid doing the previous code chunk between all of our variables.

2.5 Share

2.5.1 Which one is more important? distance, duration or step count

One of the main questions of this study is to find out which type of activity affects the burnt calories. Previously we mentioned the correlation that exists between some of these factors and burnt calories. In this section, we discuss it further by visualizing the data and modeling them using linear regression.

The next three graphs shows the association of burnt calories with three different factors in an activity:

  • Distance
  • Duration
  • Steps
clean_daily_data %>% 
  ggplot(mapping = aes(x = total_dist, y = calories, color = vig_dist,
                       size = vig_dist)) +
  geom_point()+
  geom_smooth(method = "lm", color = "#B90E0A", fill = "#999999",
              show.legend = FALSE) +
  stat_regline_equation(label.x = 10.5, label.y = 900) +
  scale_color_gradient(low = "#000000", high = "#2EB62C") +
  guides(color = guide_legend("Vigorous activity (kms)"),
         size = guide_legend("Vigorous activity (kms)")) +
  labs(x = "Total distance (km)", y = "Burnt calories (kcal)",
       title = "Distance vs. Calories") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 10.5, label.y = 500)

As mentioned before, distance has the biggest impact on calories. Furthermore, the points are designed to look bigger and brighter if the intensity of the activity was more vigorous.

clean_daily_data %>% 
  ggplot(mapping = aes(x = total_min, y = calories, color = vig_min,
                       size = vig_min)) +
  geom_point()+
  geom_smooth(method = "lm", color = "#B90E0A", fill = "#999999",
              show.legend = FALSE) +
  stat_regline_equation(label.x = 230, label.y = 900) +
  scale_color_gradient(low = "#000000", high = "#2EB62C") +
  guides(color = guide_legend("Vigorous activity (minutes)"),
         size = guide_legend("Vigorous activity (minutes)")) +
  labs(x = "Activity time (minutes)", y = "Burnt calories (kcal)",
       title = "Duration of activity vs. Calories") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 230, label.y = 500) 

Although duration has a lower impact compared to distance, we can visually see that longer periods of time doing vigorous activities are more correlated to calorie burn than longer distances of vigorous activity. We will test this hypothesis later.

clean_daily_data %>% 
  ggplot(mapping = aes(x = total_steps, y = calories,)) +
  geom_point(col = "darkgreen")+
  geom_smooth(method = "lm", color = "#B90E0A", fill = "#999999",
              show.legend = FALSE) +
  stat_regline_equation(label.x = 10300, label.y = 900) +
  labs(x = "Number of steps", y = "Burnt calories (kcal)",
       title = "Total Steps vs. Calories") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 10300, label.y = 500)

We can conclude that number of steps is less effective in burning calories than the total distance. So increasing the number of steps or taking shorter steps is not beneficial in calorie count.

2.5.2 Impact of intensity on burnt calories

Another question that comes to mind is that what kind of activity is the best. Are more intense activities really better in burning more calories?

In this section, some plots are provided for you to better understand the association between intensity of an activity and burnt calories.

Here is the categorization of activities based on intensity:

  • Sedentary: Uses 1.5 or fewer METs. Examples are sitting and reclining.
  • Light: Uses 1.6-3.0 METs. Examples are walking at a leisurely pace or standing in line.
  • Moderate: Uses 3.0-6.0 METs. Examples are walking briskly, vacuuming or raking leaves.
  • Vigorous: Uses more than 6.0 METs. Examples are walking very quickly, running, taking an aerobic class, or shoveling snow.
longer_dist %>% 
  ggplot(mapping = aes(x = distances, y = calories, color = types_dist)) +
  geom_point()+
  geom_smooth(method = "lm", color= "#3a3b3c")+
  facet_grid(~types_dist) +
  labs(x ="Distance (km)", y = "Calories (kcal)",
       color = "Types of activity (km)", title = "Intensity vs. Activity",
       subtitle = "Total distance with that intensity") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 2, label.y = 70) +
  stat_regline_equation(label.x = 2, label.y = 470)

longer_min %>% 
  ggplot(mapping = aes(x = minutes, y = calories, color = types_min)) +
  geom_point()+
  geom_smooth(method = "lm", color= "#3a3b3c")+
  facet_grid(~types_min) +
  labs(x="Activity time (minutes))", y= "Calories (kcal)", 
       color="Types of activity (minutes)", title = "Intensity vs. Activity",
       subtitle = "Total minutes with that intensity") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
             label.x = 0, label.y = -400) +
  stat_regline_equation(label.x = 0, label.y = 0)

These two plots illustrate that:

  1. Sedentary and moderate activities do not have a significant impact on burnt calories. Although increasing the duration of moderate activities has a low impact.

  2. More distances of light intensity workout helps with burning calories, example is walking in a leisurely pace. However, light activities with no moving have no significant effect.

  3. Activities with vigorous intensity tend to have the most significant effect on burnt calories. Surprisingly, the effectiveness is greater if the person do them in a more extensive time. In fact, it’s the only strong correlation that we found in the study.

  4. Moderate activities ineffectiveness could be due to the fact that after doing a lot of this type of intensity workout, your body can’t handle doing vigorous workout which are the most effective in calorie count.

2.5.3 Effect of activity on sleep

Does activity really change the pattern of sleep?

The data only provided the duration of each participants sleep, and the time they were in bed. Thus, we only have two variables for test: Duration of sleep, and sleep latency, which is the time before falling asleep.

clean_daily_data %>% 
  ggplot(mapping = aes(x = total_min, y = asleep_min, color = vig_min,
         size = vig_min)) +
  geom_point() +
  geom_smooth(method = "lm", color = "#ff6d1e", fill = "#999999", 
              show.legend = FALSE) +
  stat_regline_equation(label.x = 405, label.y = 750) +
  scale_color_gradient(low = "#000000", high = "#89CFF0") +
  guides(color = guide_legend("Vigorous activity (minutes)"),
         size = guide_legend("Vigorous activity (minutes)")) +
  labs(x = "Activity time (minutes)", y = "Daily sleep (minutes)",
       title = "Effect of activity on quantity of sleep") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 405, label.y = 680)

clean_daily_data %>% 
  ggplot(mapping = aes(x = total_min, y = time_to_sleep)) +
  geom_point(color = "#2e69b4") +
  geom_smooth(method = "lm", color = "#ff6d1e") +
  stat_regline_equation(label.x = 350, label.y = 350) +
  labs(x = "Activity time (minutes)",
       y = "Sleep latency (minutes)",
       title = "ŮŹEffect of daily activity on sleep latency ") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 350, label.y = 300)

As seen in the plots, activity don’t have an significant effect on sleep. However it might affect the quality of sleep. More data would be needed for this assessment.

2.5.5 Sedentary activities cause decreased daily sleep

clean_daily_data %>% 
  ggplot(mapping = aes(x = sed_min, y = asleep_min)) +
  geom_point(color = "purple") +
  geom_smooth(method = "lm", color = "yellow") +
  stat_regline_equation(label.x = 125, label.y = 160) +
  labs (x = "Sedentary activity (mins)", y = "Daily sleep (minutes)",
        title = "Sedentary activities decrease daily sleep") +
  stat_cor(method = "pearson", r.accuracy = 0.01, p.accuracy = 0.001,
           label.x = 125, label.y = 100)

This plot shows that sedentary activities have an strong negative correlation with daily sleep. The regression model shows that every minute of having no movement decrease your sleep by approximately 26 seconds.

2.5.5 Hourly data of activity

Next plots shows the distribution of burned calories, stepcounts, and intensity in a 24 hour time frame.

summarized_hourly_date %>% 
  ggplot(mapping = aes(x = hour, y = avg_steps)) +
  geom_col(fill = "#ee9a1e")+
  theme(axis.text.x = element_text(angle = 90)) +
  labs(x = "Hour", y = "Average steps",
       title = "Stepcounts in a daily timeframe")

summarized_hourly_date %>% 
  ggplot(mapping = aes(x = hour, y = avg_intensity)) +
  geom_col(fill = "#B90E0A")+
  theme(axis.text.x = element_text(angle = 90)) +
  labs(x = "Hour", y = "Average Instensity",
       title = "Activity intensity in a daily timeframe")

summarized_hourly_date %>% 
  ggplot(mapping = aes(x = hour, y = avg_cal)) +
  geom_col(fill = "#2EB62C")+
  theme(axis.text.x = element_text(angle = 90)) +
  labs(x = "Hour", y = "Average Calories",
       title = "Burnt calories in a daily timeframe")

We can conclude that 6 p.m is the most active time of day, after that all plots gradually decrease until they reach the trough in 3 a.m.

Chapter 3: Conclusions

Here are some conclusion from this study:

  1. Vigorous activities have the most impact on burnt calories.

  2. Extending the duration od vigorous activities is the best method for more calorie count.

  3. Walking and all of the light activities that promote movement are beneficial.

  4. Being stationary reduces daily sleep but being more active doesn’t necessarily increase it.

  5. Smart device users tend to be more active in 6 p.m

Chapter 4: Suggestions