Bayes Rule with Forecasting
STAT340: Data Science Modelling II
Taught by Prof. Brian Powers
Overview
This project demonstrates the application of Bayes' Rule combined with forecasting techniques using R programming. It focuses on a practical example involving weather prediction accuracy for Madison, Wisconsin, specifically how often a local channel's weather forecast aligns with actual weather events over the course of a year.
Project Description
This R implementation explores Bayesian forecasting by analyzing the probability of weather forecasts being correct based on historical accuracy data. The project answers specific probabilistic questions about daily weather forecasting accuracy, using Channel 3000's forecasts as a case study.
Situation
In Madison, Wisconsin, the annual precipitation is approximately 115 days. Channel 3000 has a forecast accuracy of:
- • 93% on days with precipitation.
- • 87% on days without precipitation.
Question:
How many days will Channel 3000 correctly forecast in a non-leap year (365 days)
Answer:
- Correct Precipitation Prediction:
(OddsCorrectforPrecipitation) * (DaysthereisPrecipiation) = 107 (106.95) - Correct No Precipitation Prediction:
(OddsCorrectforNon-Precipitation) * (DaysthereisPrecipiation) = 218 (217.5) - Correct Prediction:
(CorrectPrecipitationPrediction) + (CorrectNoPrecipitationPrediction) - Correct Prediction =
107 + 218 = 325 Days
Question:
If Channel 3000 predicts precipitation in Madison, what is the likelihood that there is actually precipitation?
Answer:
P(Rain | ForecastRain) = (P(ForecastRain | Rain) * P(Rain)) / (P(ForecastRain))- P(ForecastRain | Rain): The probability of the Channel 3000 forecast to predict it rain, and be correct
- 93% = 0.93
- P(Rain): The probability of it to rain
- 31.51% = 0.31506
Question:
Let's assume that the Channel 3000 forecast was correct yesterday. This increases the likelihood of Channel 3000's forecast for today. Specifically, if the forecast was correct yesterday, then the probability of Channel 3000 accurately predicts if there is precipitation 93% of the time, and 87% of the time when there is no precipitation. If the forecast was correct on January 29th, what is the probability it was correct on January 28th? Assume that the forecast was incorrect on the 27th.
Answer:
- A: Probability of Channel 3000's forecast being correct on January 28th
- B: Probability of Channel 3000's forecast being correct on January 29th
P(A|B) = (P(B|A) * P(A)) / (P(B))- P(B|A): Probability of Channel 3000's forecast being correct on January 29th given that Channel 3000's forecast on January 28th was correct
- 93.89% = 0.9389
- P(A): Probability of Channel 3000's forecast being correct on January 28th
- 88.89% = 0.8889
- P(B): Probability of Channel 3000's forecast being correct on January 29th
- 93.33% = 0.9333
Key Questions Addressed
- Annual Forecast Accuracy:
- How many days can we expect Channel 3000 to correctly forecast weather in a non-leap year (365 days)?
- Calculation for correct predictions:
- Precipitation days correct: 107 days
- Non-precipitation days correct: 218 days
- Total: 325 correct forecasts
- Probability of Actual Precipitation Given a Forecast:
- What is the probability that it actually precipitates when Channel 3000 predicts precipitation?
- The computed probability that it will rain given a forecast of rain is 76.69%.
- Sequential Day Forecast Accuracy:
- If the forecast was correct on the previous day, how does this influence the accuracy of the next day's forecast?
- The model explores the likelihood of consecutive correct forecasts, incorporating dependencies between subsequent days.
Usage
- Download the file:
Bayes-Rule.rmd
License
Distributed under the MIT License. SeeLICENSE.txt for more information.
