# 2 Main Variables: Descriptive Statistics

## 2.1 Main Varibles Descriptions

**Reading**: reading duration in minutes**Meditation**: meditation duration in minutes**Phone_pickups**: number of times I picked up my phone**Screen_time**: duration of spent time on my phone in minutes**Rise_time**: the variation in minutes from the intended rise time- 0: Woke up on time
- -n: Woke up n minutes earlier than intended
- +n: Woke up n minutes later than intended

**Drink**: Whether or not I drank the day before (Boolean)**Work_finished**: Finished_tasks / Total_tasks**Multiple**: Subjective grade given each day- Considered factors: Mentality, Satisfaction, Productivity, Social interaction, and Tech consumption

**Total**: The sum of the percentages calculated of above variables

## 2.2 Main Variables Correlations

To find the relationships between these variables and how they affect my lifestyle, we will first observe the relationships within variables

- Use
**pairs.panels function**in psych module**The diagonal histograms**demonstrates the distribution of each variable**The bottom left triangle**represents a scatter plot with the best fit line**The top right triangle**represents a correlation coefficient for each pair, which ranges from -1 to 1- If the coefficient is close to 1, it means that the pair holds a positive relationship and a negative relationship for -1.

- Correlation Coefficient Formula: \[r = \dfrac{\sum(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum(x_i-\bar{x})^2\sum(y_i-\bar{y})^2}}\]

```
correlation_plot <- all_dat %>%
select(c(Screen_time, Meditation, Multiple, Rise_time,
Reading,Phone_pickups, work_finished, Total))
pairs.panels(correlation_plot, lm = TRUE)
```

## 2.3 School Variable

```
ggplot(data = filter(all_dat, School != FALSE), aes(x = work_finished,
color = School))+
geom_density()+
labs(title = "Density Plot of Work Finished% for different School periods",
x = "Work Finished (%)")+
theme(plot.title = element_text(face = "bold")) +
scale_color_discrete(name = "School Qtrs")
```

## 2.4 Weekday Variable

```
all_dat$Weekdays <- factor(all_dat$Weekdays,levels = c("Monday", "Tuesday", "Wednesday", "Thursday","Friday","Saturday","Sunday"))
ggplot(data = all_dat)+
geom_boxplot(aes(x = Weekdays,
y = work_finished, color = Weekdays))+
theme(legend.position = "None")+
labs(title = "Work finished % by week days",
subtitle = "Data: all_dat (500+ observations)",
x = "", y = "Work Finished (%)")+
theme(plot.title = element_text(face = "bold"))
```

## 2.5 Time Trend (Total %)

```
all_dat_month <- all_dat %>%
filter(!is.na(Rise_time)) %>%
group_by(year, month) %>%
dplyr::summarise(Total = mean(Total),
Rise_time = mean(Rise_time)) %>%
mutate(Date = make_date(year, month)) %>%
arrange(Date)
ggplot(all_dat_month)+
geom_line(aes(x=Date, y=Total))+
labs(title = "Trend of Total%",
subtitle = "Grouped by Month Average")+
theme(plot.title = element_text(face = "bold")) +
scale_x_continuous(breaks = ymd("2020-09-01", "2021-01-01","2021-04-01", "2021-07-01", "2021-10-01","2022-01-01", "2022-04-01"),
labels=c("09/20", "01/21", "04/21", "07/21",
"10/21", "01/22","04/22"))
```

## 2.6 Time Trend (Total % - Rise time)

```
ggplot(all_dat_month)+
geom_line(aes(x=Date, y=Total-Rise_time))+
labs(title = "Trend of Total% - Rise time",
subtitle = "Larger positive differnce indicates higher productivity")+
theme(plot.title = element_text(face = "bold")) +
scale_x_continuous(breaks = ymd("2020-09-01", "2021-01-01", "2021-06-01",
"2022-01-01"))
```

- Note for Rise time:
- 0: Woke up on intended time
- Positive value: Later than intended
- Negative value: Earlier than intended