Skip to content

Commit

Permalink
add plot
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Dec 5, 2024
1 parent 6276b8a commit 3962f21
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/R/badWeather/regressionAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,8 @@ optParams

#calc adjustedNoRides = noRides - alpha * (1 - exp(-trend / beta)) with optimized alpha and beta
result_data <- result_data %>%
mutate(adjustedNoRides = noRides - as.integer(optParams$par[1] * (1 - exp(-trend / optParams$par[2]))))
mutate(adjustedNoRides = noRides - as.integer(optParams$par[1] * (1 - exp(-trend / optParams$par[2]))),
trend_est = as.integer(optParams$par[1] * (1 - exp(-trend / optParams$par[2]))))

result_data %>% ungroup() %>%
dplyr::select(-noRides,-description ,-date,-season,-wday,-wday_char, -weather_impact, -isHoliday, -adjustedNoRides) %>%
Expand All @@ -796,14 +797,24 @@ result_data %>% ungroup() %>%
test_model <- lm(adjustedNoRides ~ prcp+isSchoolHoliday,data = result_data)
summary(test_model)

adjustedNoRides_time <- ggplot(result_data) +
noRides_time_trend_est <- ggplot(result_data) +
geom_point(mapping=aes(x = date,y = noRides))+
geom_line(mapping = aes(x=date, y = trend_est), color="red") +
theme_light() +
xlab("Date") +
theme(text = element_text(size = 12)) +
ggtitle("noRides over time + estimated trend (red)")
noRides_time_trend_est

adjustedNoRides_time_2 <- ggplot(result_data) +
geom_point(mapping=aes(x = date,y = adjustedNoRides))+
# geom_line(mapping=aes(x = date,y = snow-50), color="red")+
geom_line(mapping=aes(x = date,y = snow-50), color="red")+
# geom_line(mapping = aes(x=date, y = trend_est), color="red") +
theme_light() +
xlab("Date") +
theme(text = element_text(size = 12)) +
ggtitle("adjusted nor rides over time")
adjustedNoRides_time
adjustedNoRides_time_2



Expand Down

0 comments on commit 3962f21

Please sign in to comment.