animation

Mortgage rates hit a record low

This week the Freddie Mac Primary Mortgage Market Survey reported a record low for the U.S. weekly average 30-year mortgage rate. First some charts, then below I post R code. R code Load libraries library(fredr) library(tidyverse) library(patchwork) library(cowplot) library(gganimate) library(lubridate) # updated You’ll need a custom color scale (see below for code). R code to wrangle data data preparation code source(paste0(mydir,"len_color_scales.R")) #custom color scale code copied below fredr_set_key("YOURKEY") df <- fredr(series_id = "MORTGAGE30US", observation_start = as.

Updated Favorite Data Visualizations

I’ve decided to create a post where I can regularly update some favorite data visualizations. Where I’ve previously discussed the data or shared code I will provide a link. Often I’ll update the charts and post them on Twitter soon after the data is released. I won’t be updating these that quickly, but I’ll do my best to keep up. As I update some more charts I may add to the list.

US Labor Market Update

Today the U.S. Bureau of Labor Statistics released its monthly employment situation summary for March 2020. While many were expecting the U.S. labor market to show some weakness as the U.S. economy shuts down to battle COVID-19, the magnitude of the contraction surprised many. Because the reference week for the employment report was March 8th through March 14th, before the nationwide shutdown took full effect, many were expecting a relatively mild report.

30 sigma

Earlier today I tweeted out a chart of the U.S. Labor Department’s estimate of initial jobless claims Link to pdf report. weekly jobless claims, a 30σ event pic.twitter.com/LEO7s5TXsH — 📈 Len Kiefer 📊 (@lenkiefer) March 26, 2020 Below I share R code to generate a chart like the one above. We can get data from the St. Louis Fed’s Federal Reserve Economic Data (FRED). Then it’s easy to make an animation.

Visualizing consumer price inflation and mortgage rates

Today I tweeted something that turned out to be pretty popular: US consumer prices pic.twitter.com/LxIxvEnGFe — 📈 Len Kiefer 📊 (@lenkiefer) October 10, 2019 This was an update to a visualization we have talked about here. In this post I want to provide some updated R code to make this visualization taking advantage of the new gganimate api. I’ll also share some code for mortgage rate plots. The code for the inflation plot is pretty simple.

Mortgage rates and housing construction

The U.S. housing market stalled out a bit in 2018 and we aren’t building enough homes to match demand. See my recent speech for details on what’s going on. Abbreviated version: in 2018 mortgage interest rates slowed housing activity, but demographic forces support housing demand and should provide a lift in years to come. Together with a recent moderation in mortgage rates there’s reason to be optimistic about housing market activity in 2019.

Vulnerable Economy Plots

Last week I gave a speech in Cincinnati, Ohio at the UC/PNC Economic Outlook program. My speech was titled “Forecasting in a Vulnerable Economy”. You can find slides and detailed notes over on LinkedIn: https://www.linkedin.com/pulse/forecasting-vulnerable-economy-leonard-kiefer/. In this post I want to share R code for the first three plots on the Vulnerable Economy. We’ll get the data via the St Louis Fed’s FRED. We’re going to grab the Fed Funds rate FEDFUNDS, the Unemployment Rate UNRATE the Congressional Budget Office’s estimate of the long-run natural rate of unemployment NROU and the spread between the 10-year and 2-year U.

Animated Labor Force Participation Chart

Here’s some R code for an animated chart of the U.S. prime working age (25-54) labor force participation rate. I tweeted it out last Friday: Labor force participation rate #dataviz made with #rstats #gganimate pic.twitter.com/uSICoLjbIf — 📈 Len Kiefer 📊 (@lenkiefer) February 1, 2019 We can go to the U.S. Bureau of Labor Statistics (BLS) webpage (https://www.bls.gov/) and get these data. For more details see my post Charting Jobs Friday with R.

Go Go Animate!

At the start of the year, the R package gganimate hit CRAN. See this announcement blog post with some examples. In this space, I’ve shared several posts on animation see tags. But I haven’t been using gganimate. Instead, I took a more direct approach building the animations via loops and trying to tween directly if I wanted a smooth animation. This level of control is nice, but frankly the defaults in gganimate work better than many of my attempts to hand craft it.

Everything is spiraling out of control!

I saw this fun bit of R code in a tweet by user aschinchon. df <- data.frame(x=0, y=0) for (i in 2:500) { df[i,1] <- df[i-1,1]+((0.98)^i)*cos(i) df[i,2] <- df[i-1,2]+((0.98)^i)*sin(i) } ggplot2::ggplot(df, aes(x,y)) + geom_polygon()+ theme_void()#rstats pic.twitter.com/cgNjyk405f — Antonio Sánchez Chinchón (@aschinchon) August 16, 2018 Let’s remix it to make a fun animation. We’ll zoom in and out and have the colors shift. Click for R code

Global house price trends

In this post I want to share updated plots comparing house price trends around the world. Or at least part of the world. Our view will be somewhat limited, based on data, but will at least allow us to see how U.S. house prices compare to a few other countries. The details behind these plots are explained in more detail in this post, but some of the images were lost due to my blog transition.

House price gif that keeps on giffing

This tweet turned out to be popular: 👀house price trends👀 pic.twitter.com/JXB5P0H84A — 📈 Len Kiefer 📊 (@lenkiefer) August 1, 2018 It’s a remix of a chart we made here, though it uses a different index. In the earlier post, we used the FHFA house price index, but this one used the Case-Shiller Index, which was released today. Let me just post two gifs and then below will be the R code I used to create them.

Getting animated about new home sales

Indications are that U.S. housing market activity in the middle part of 2018 has moderated. Home sales estimates for both new home sales and existing home sales declined on a seasonally adjusted basis in June relative to May. House price growth has also moderated recently. Some folks have gotten animated about the recent trends. I’m more sanguine about the recent data. Certainly a slowdown in housing market activity would be cause for concern.

House price gifski

I saw today, via Ropensci a blog post about a new package for making animated gifs with R called gifski now available on CRAN. Let’s adapt the code we shared last week to use the gifski package. See that post for additional details. If we run the R code below we’ll generate this animated plot: This plot shows the evolution of house prices in two states, California (CA) and Texas (TX) versus the United States (USA).

U.S. housing starts are still super low

I try not to use too much jargon (jargon monoxide can be deadly) on this blog. But I’ve got a bit of a technical term I’ve been using the describe U.S. residential construction: super-low. To be sure, housing construction has been grinding higher, but it’s been taking a while for activity to get back close to historical averages. Once you account for the larger population, which all else equal needs more housing units, the level of construction is quite low.

Rate Cloud

TIME FOR A FUN NEW MORTGAGE RATE CHART. This one: We’ll use R to plot a new visualization of mortgage rates. Let’s make it. Data As we did with our majestic mortgage rate plot post we’ll plot mortgage rates using the Freddie Mac Primary Mortgage Market Survey. We’ll get the mortgage rates data via the Saint Louis Federal Reserve’s FRED database. If you followed my post from back in April of last year you know what we can do if we combine FRED with the quantmod package.

Pipe Tweenr

I LIKE TO MAKE ANIMATIONS WITH R. Sometimes folks ask me how they add to understanding. They don’t always, but often, particularly when you are working with time series, I find they help visualize trends and understand the evolution of variables. I’ve written several posts on animation, see particularly this recent post on making a simple line plot and this post about improving animations with tweenr. Tweenr is a handy package that lets you interpolate data and make smooth animations.

Recent House Price Trends: update through December 2017

LAST YEAR WE TOURED recent house price trends Post. Let’s update the data visualizations with data through December 2017. We are going to show house price trends using data from the publicly available Freddie Mac House Price Index. Animation: Here’s an updated animation showing trends in the top 20 metro areas, based on population. Below, I’ll plot stills for each of the 20 metro areas. Later I’ll follow up with some additional visualizations and some commentary.

Housing market dataviz: week of November 22, 2017

IT IS THANKSGIVING WEEK HERE IN THE UNITED STATES. I’m getting ready to go out for a nice casual drive down Interstate I-95. Should be fun. After I get back stuffed with turkey and whatnot, we’ll get back to data visualizations and analysis. But let me leave you a couple animated gifs showing recent housing and mortgage market trends. Mortgage rate trends First, let’s just look at a line plot of trends in the 30-year fixed mortgage rate:

Combining PowerPoint and R's tweenr for smooth animations

IN THIS POST I WANT SHARE A METHOD FOR MAKING SMOOTH POWERPOINT ANIMATIONS USING R. Also see other posts in this series: Crafting a PowerPoint Presentation with R LINK PURRRTY PowerPoint with R LINK PURRRtier PowerPoint with R LINK Motivation Why would you want to do this? We’ve covered how to make an animated gif with R and that works pretty well. But there are a couple advantages with this approach.

Time to animate with tibbletime

IN THIS POST I WANT TO SHARE SOME CODE TO CREATE AN ANIMATED CHART of housing starts. Per usual we’ll use R and we’ll also use the tibbletime package. Running the code below will generate: (see this post for more on animations with the R package tweenr) ##################################################################################### ## Load libraries ## ##################################################################################### library(tidyquant) library(tibbletime) library(tweenr) ##################################################################################### ## Get housing starts data ## ##################################################################################### df <- tq_get("HOUST1F",get="economic.data",from="1959-01-01") ##################################################################################### ## function for rolling windows ## ##################################################################################### mys <- function(win=12){ rolling_mean <- rollify(mean, window = win) #function creates rolling average based on win df %>%mutate(dy=rolling_mean(price), w=as.

Charting housing starts with R

IN THIS POST I WANT TO SHARE SOME R CODE to create charts of U.S. housing starts we studied last week. Get data We’ll use tidyquant (see e.g. this post for more) to go get our data from the St. Louis Federal Reserve Economic Database (FRED). We’ll also use cowplot to arrange multiple ggplot2 graphs on one page. Let’s load libraries and grab the data. ##################################################################################### ## Step 0: Load Libraries ## ##################################################################################### library(tidyquant) library(tidyverse) library(cowplot) library(lubridate) library(scales) library(ggridges) # replaces ggjoy ##################################################################################### ## Step 1: Prepare for data ## ##################################################################################### tickers=data.

Housing market update September 2017

THIS WEEK WAS BUSY, with a lot of data releases. Earlier this week we talked about housing starts, but there were a bunch of other key releases. Let’s review some of them here. We’ll just do a quick description of the data and then follow up with a static chart and an animated gif. Mortgage rates are still super low U.S. weekly average mortgage rates ticked up this week, but remain down from the start of the year.

Housing starts grinding higher or grinding to a halt?

ARE HOUSING STARTS GRINDING HIGHER, OR GRINDING TO A HALT? Today the U.S. Census Bureau joint with the U.S. Department of Housing and Urban Development published updated estimates of housing starts through August of 2017. Per the report privately-owned housing starts in August were at a seasonally adjusted annual rate of 1.18 million, down 0.8 percent from July’s revised estimate and up 1.4 percent from a year ago. Neither the month-over-month or year-over-year changes were significant.

Some animated gifs: Week of Oct 14, 2016

A couple of views of mortgage rates: Mortgage Rates in 2016 This chart shows the weekly average for the 30-year fixed rate morrtgage. Comparing mortgage rates by week This viz compares weekly mortgage rates (30-year fixed rate mortgage) by year. Each line represents a different year. The x-axis display the week of the year (from 1 to 52). Homeownership gif A homeownership rate viz. This shows the U.S. homeownership rate and breaks it out by the age of householder:

Data visualizations for the week of September 22, 2016

IT WAS A BUSY WEEK FOR ECONOMIC AND HOUSING DATA this week. Below are some data visaulizations I made tracking key trends in economic and housing market data. Homeowner equity increases to $12.7 Trillion in the second quarter of 2016 With house prices rising by nearly 6 percent on a year-over-year basis, homeowners are building back equity. According to the Federal Reserve’s Flow of Funds, owners' equity in real estate was $12.

Industry-specific Beveridge Curves

IN MY PREVIOUS POST we looked at the Job Openings and Labor Turnover Survey (JOLTS) data and plotted a Beveridge Curve. In this post I want to add some more code that allows us to plot Beveridge Curves by industry. For more on the analysis of industry-specific Beveridge Curves, see this paper published in the June 2012 Monthly Labor Review that decomposes shifts in the Beveridge Curve and looks at it by industry.

JOLTS! Job openings and labor turnover trends

IN THIS POST WE’LL LOOK AT recent job openings and hires data from the Bureau of Labor Statistics Job Openings and Labor Turnover Survey (JOLTS). R code for selected graphs posted below Job openings and labor turnover Total nonfarm trends Let’s start by looking at aggregate national trends for total nonfarm sector. The plot below compares hires, job openings and separations (the sum of quits, layoffs and discharges, and other separations) over time.

What we spend: Consumer Expenditures in 2015

EARLIER THIS WEEK THE U.S. BUREAU OF LABOR STATISTICS released data on consumer expenditures in 2015. In this post I want to examine these data and make a few visualizations. R code for graphs posted below One area I pay close attention to is housing. Housing is the largest single category of expenditure, averaging about 1/3 of total consumer expenditures. The BLS breaks the data out by tenure, so we can see how expenditures vary by owners versus renters.

Consumer Credit Trends Part 2: Data doesn't drive, it's lucky to be in the car

A FEW DAYS AGO I POSTED on trends in household debt using data from the the New York Federal Reserve Bank’s Consumer Credit Panel. The post got many responses, some observing that while student debt has grown a lot the absolute level of it is small relative to mortgage debt. I had made that point in my post, but the pictures caught the attention of many who didn’t read the post or catch the point.

Consumer Credit Trends

TODAY the NEW YORK FEDERAL RESERVE BANK released its Quarterly Report on Household Debt and Credit. These data come from the Center for Microeconomic Data based on credit records from Equifax. R code for the graphs are posted at bottom of page Trends in household debt balances One of the key statistics tracked in the report (full data can be found here) is household debt balances. They break debt balances out by loan type:

Let's make a dot plot

IN THIS POST WE’RE GOING to make an animated version of the famous Federal Reserve dot plot comparing the dots in March 2016 to June 2016. As far as celebrity charts go, the dot plot has to be up there. Check out how much “dot plot” has grown in search popularity since the Fed introduced their dot plot in 2012: Ultimately, it will look something like this: The dot plot is a special chart that shows the distribution of expectations of the Federal Open Market Committee (FOMC) for the federal funds rate.

Dataviz Remix: Housing Trilemma

A dataviz remix I came across some interesting analysis from Josh Lehner at the Oregon Office of Economic Analysis about the “Housing Trilemma”. The Housing Trilemma, captured in the chart below is based on the following claim: Every city wants to have a strong local economy, high quality of life and housing affordability for its residents. Unfortunately these three dimensions represent the Housing Trilemma. A city can achieve success on two but not all three at the same time.

Visualizing the U.S. housing stock

IN THIS POST I wanted to share a few data visualizations I made using the American Housing Survey (AHS). For this exercise I used the metro summary tableswhich you can download from American Fact Finder. Distribution by year unit built Distribution by units in stucture Distribution by bedrooms in unit Distribution by square footage of units {% include JB/setup

More tweenr animation examples

IN THIS POST I WANT TO PROVIDE some additional examples of using tweenr and gganimate to create nice smooth transitions in an animated GIF. In this post we’ll look at an animated waterfall chart. For this data I’m going to use the National Income and Products Accounts from the U.S. Bureau of Economic Analysis (BEA). Specifically we’ll be looking at the contributions to growth in Real Gross Domstic Product, which you can find here.

Improving R animated GIFs with tweenr

RECENTLY I HAVE MADE several animated GIFs, primarily using the animation package. These gifs usually work pretty well, coming out something like this (code here). Unfortunately, these gifs tend to come out rather choppy. I tried to get around that by using variable length sequences to alter the timing of each frame. My primitive approach involves loops and business like this: {% highlight r for (i in c(seq(1,365,6),seq(378,716,13),seq(1145,1574,26),seq(1587,2003,13),seq(2016,2185,6),2196) ) { {% endhighlight

Mortgage rates and the Fed Funds rate

YESTERDAY THE FEDERAL RESERVE RELEASED minutes from their last Federal Open Market Committee (FOMC) meeting in April. The big news was that the FOMC still considered a June rate hike a possibility. How much does Fed policy impact mortgage rates? I put together a few gifs comparing the history of the 30-year mortgage rate, the Fed Funds rate and the 10-year constant maturity Treasury. {% include JB/setup

Mortgage rates, some perspective

Another mortgage rates animated gif IN THE PAST I’ve told you how I made my mortgage rates gif. In this post I’m make an extension that uses stop motion techniques to reverse course. We’ll end up with this: For reference, here’s the standard gif I share each Thursday after mortgage rates come out: Stop motion animation While thinking about the week-to-week movements in rates it’s easy to lose longer-term perspective. Rates in the week of May 12, 2016 were the lowest in three years.

dot plots and distributions

We’re going to make this chart (and talk about it) Wait, what is this? Let’s pause the animation and look at the last frame: This plot shows the distribution of metro area unemployment. These data are available here. Each dot represents a metro area with its unemployment rate depicted on the x axis. The data are bucketed into 0.25 percentage point buckets and stacked when more than one metro falls within that range.

How I make my mortgage rates gif

{% include JB/setup Making a data viz SOMETIMES ANIMATION CAN BE USEFUL, though it is often misused. I’ve been tracking the week-to-week changes in mortgage rates, and animating with a GIF. Example animated gif with mortgage rates from 1/1/2013 to 3/10/2016 I build my gif using the R statistical package. Perhaps I’ll explain more of the details later, but the R code below uses the ggplot2, ggthemes and animation packages to create the plots, style them, and save the animation.