2022-11-07

Overview

That data set has weather data from 161 locations, throughout the war from 1940 to 1945.

head(select(weather, STA, Date, Precip, MaxTemp, MinTemp, MeanTemp))
## # A tibble: 6 × 6
##     STA Date     Precip MaxTemp MinTemp MeanTemp
##   <dbl> <chr>    <chr>    <dbl>   <dbl>    <dbl>
## 1 10001 1942-7-1 1.016     25.6    22.2     23.9
## 2 10001 1942-7-2 0         28.9    21.7     25.6
## 3 10001 1942-7-3 2.54      26.1    22.2     24.4
## 4 10001 1942-7-4 2.54      26.7    22.2     24.4
## 5 10001 1942-7-5 0         26.7    21.7     24.4
## 6 10001 1942-7-6 0         26.7    21.7     24.4

Map

Code from previous plot

world = map_data('world')

ggplot() +
  geom_map(
    data = world, map = world,
    aes(long, lat, map_id = region),
    color = "white", fill = "lightgray", size = 0.2
  )+ geom_point(data = locations, aes(Longitude, Latitude, color = STATE.COUNTRY.ID))+
  theme_void() +
  theme(legend.position = "none")

Collection Volume Through the War

ggplot(weather, aes(x = Date)) + geom_bar()

Relation Between Min and Max Temprature

Code from previous plot

x = weather$MaxTemp
y = weather$MinTemp

mod = lm(y~x)

xax = list(title = "Max Temp",
           titlefont = list(family="Modern Computer Roman"))

yax = list(title = "Min Temp",
           titlefont = list(family="Modern Computer Roman"))

plot_ly(x=x, y=y, type="scatter", mode="markers") %>%
  add_lines(x = x, y = fitted(mod))  %>%
  layout(xaxis = xax, yaxis = yax)

Modeling Min Vs Max Temprature

revlevent code from previous slide

y = subWeather$WindGustSpd
x = abs(subWeather$MinTemp - weather$MaxTemp)
mod = lm(y~x)

\(\displaystyle MSE = {SSE \over n-2} = {1\over n-2} \sum_{i=1}^n (y_i - \hat{y}_i)^2\)

MSE =

## [1] 15.86859

Modeling for Tropical Locations

If we only look at locations in tropical regions from the tropic of Cancer to Capricorn.

tropical =( locations %>%filter( abs(locations$Latitude) < 23.26)
            %>% select(WBAN) )
tropicalWeather = semi_join(weather, tropical, by = c("STA" = "WBAN") )
x = tropicalWeather$MaxTemp
y = tropicalWeather$MinTemp
mod2 = lm(y~x)

\(\displaystyle MSE = {SSE \over n-2} = {1\over n-2} \sum_{i=1}^n (y_i - \hat{y}_i)^2\) MSE =

## [1] 9.117239

Modeling only tropical locations with more contestant temperatures has less error then a more global data set.