2024-02-19

MEAN AND MEDIAN WITH AND WITHOUT OUTLIERS

  • HIGH TEMPERATURES IN THE MONTH OF JULY
  • IDENTIFY OUTLIERS
  • AVERAGE AND MEDIAN TEMPS WITHOUT OUTLIERS - Notice the difference in slopes showing the mean increases without outliers.

Plotly plot showing outliers with means and median

## [1] 96 90
##    Days Temperature
## 1     2         115
## 2     3         116
## 3     4         113
## 4     5          96
## 5     6         115
## 6     7         112
## 7     8         113
## 8     9         112
## 9    10         110
## 10   11         111
## 11   12         111
## 12   13         114
## 13   14         116
## 14   15         118
## 15   16         114
## 16   17         116
## 17   18         118
## 18   19         119
## 19   20         119
## 20   21         117
## 21   22         118
## 22   23         114
## 23   24         116
## 24   25         119
## 25   26         118
## 26   27         115
## 27   28          90
## 28   29         115
## 29   30         112
## 30   31         108

ggplot of BOXplot without outliers

Line of Best Fit Without Outliers

## `geom_smooth()` using formula = 'y ~ x'

Line of Best Fit With Outliers

## `geom_smooth()` using formula = 'y ~ x'

Latex slide 1

 \( \frac{1}{Days} \sum_{i=i}^{Days} Temperature_{i} \) 

Latex slide 2

iqr = IQR(data1$Temperature)
up = quantile(data1$Temperature, 0.75) + 1.5*iqr
low = quantile(data1$Temperature, 0.25) - 1.5*iqr

R code shows plot with outliers

ggplot(data = data1, mapping = aes(x = Temperature, y = Days)) + geom_point(color = ‘blue’)+ geom_smooth(method = ‘lm’, se = FALSE) + theme_classic()

Median stays the same but the mean increases about 1.5 degrees without outliers.

mean1 = mean(data1$Temperature)
print(mean1)
## [1] 113.3333
median1 = median(data1$Temperature)
print(median1)
## [1] 115

Cont.

mean2 = mean(data2$Temperature)
print(mean2)
## [1] 114.7857
median2 = median(data2$Temperature)
print(median2)
## [1] 115
#median stays the same but the mean changes by about 1.5 degrees.