by toddwschneider

toddwschneider / agency-loan-level

Loan-level analysis of Fannie Mae and Freddie Mac data

207 Stars 66 Forks Last release: Not found 5 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Create a PostgreSQL database with loan-level data from Fannie Mae and Freddie Mac

Scripts used in support of this post: Mortgages Are About Math: Open-Source Loan-Level Analysis of Fannie and Freddie


  1. Make sure you have PostgreSQL installed locally. If you want to use R, install it too
  2. Download data from Fannie Mae and/or Freddie Mac and unzip all files into the
  3. ./
    creates a Postgres database called
    , creates some tables, and imports supporting data including FHFA home price data and Freddie Mac mortgage rate data
  4. ./
    import data for Fannie and Freddie, respectively. This might take a very long time (~2 days), so you could consider loading the data in chunks



folder has additional SQL and R scripts used to analyze the data, see more in the full post

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.