Using Linear Regression to Predict Weather Patterns

Robin Gane-McCalla
Posted on May 15, 2017

Weather is important for most aspects of human life.  Predicting weather is very useful.  Humans have attempted to make predictions about the weather, many early religions used gods to explain the weather.  Only relatively recently have humans developed reasonably accurate weather predictions.  I decided to collect weather data and measured the accuracy of predictions made using linear regression.

 

I collected data from www.wunderground.com.  I found many measurements every day for decades from several locations within the USA.  I collected the following observations:

  • Temperature - the measure of warmth or coldness
  • Humidity - the amount of moisture in the atmosphere
  • Precipitation - the amount of moisture (usually rain or snow) which falls on the ground
  • Wind Speed -  the speed at which air flows through the environment
  • Pressure - the force the atmosphere applies on the environment

I collected multiple readings of these observations for each day from 1986-2016 in the following locations: Alaska, Chicago, San Francisco, Miami, New York City, Washington, DC, and Los Angeles.  The data collection was complicated because the rows in tables weren't uniform, some measurements were missing or had units inconsistently and some values varied between numbers and strings.

 

After collecting the data, I created a Shiny Application to analyze patterns between weather observations.  It is available  https://robinganemccalla.shinyapps.io/robinsweatherproject/.  For any location and pair of weather observations (including time) the Application will automatically display a scatterplot of all the data with a regression line and a regression analysis of how well the first observation predicted the second observation.  In addition, the Application automatically displays a multi-variate regression for the y-axis, using every other observation to predict the observation on the y-axis.

 

After comparing all of the observation combinations, I did not find many strong patterns.  Most R-squared values for single variable linear equation were below 0.1 and many were even lower than that.  Some patterns existed in some locations but were reversed in others.  For example, in Los Angeles, New York City, Miami and Washington, DC temperatures rose as humidity rose.  But in Alaska, Chicago and San Francisco the opposite was true.

 

Even when all variables were used, the R-Squared values were seldom over 0.5.  And there was not consistency of weather patterns between location.  The two variables which were more consistently predicted were humidity and wind speed.  This could be because they are least effected by external weather and variables I did not collect.

 

Professional weather forecasters are not perfect, but their predictions are typically more accurate than those of this linear regression model.  This implies that weather is a non-linear system.  Additionally, my predictions were all based on data from one location as opposed to multiple locations that most forecasters use.  Though my model is imperfect, it does describe limitation of linear regression on predicting weather.

 

About Author

Robin Gane-McCalla

Robin Gane-McCalla

Robin Gane-McCalla graduated from Hamilton College with a degree in Mathematics and Computer Science. He's worked as a computer programmer, data analyst, researcher and web developer. After working for several companies (including a few start ups) he's decided...
View all posts by Robin Gane-McCalla >

Related Articles

Leave a Comment

Avatar
Janelle July 20, 2017
Thanks to the terrific manual
Avatar
Rocky July 17, 2017
I enjoy the article

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Classes Demo Day Demo Lesson Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet Lectures linear regression Live Chat Live Online Bootcamp Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Lectures Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking Realtime Interaction recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp