Using Linear Regression to Predict Weather Patterns

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 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

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

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans 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 boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI