A Stata Do-File for Cubic Spline Interpolation

As a follow up to our post on using cubic spline interpolation in Matlab, we’ve posted a Stata do file explaining how to divide quarterly data into monthly estimates. The do-file is here. For our original post explaining the data and methodology, see here.


(Note: once you generate the “yy” variable, be sure to save your Stata file before running this do file, as otherwise Stata returns an error.)

2 Responses to A Stata Do-File for Cubic Spline Interpolation

  1. Rowena Macfarlane says:

    Hello! Just wanted to say this is a really helpful blog post, and really easy to understand quite a difficult concept!

    Just one question – how do you create the yy variable in stata which allows your to view the interpolated monthly data? I keep getting an error message on teh last line of the do file!

    Thank you

  2. Andrew says:

    Hi Rowena,

    Glad you’ve found this useful.

    To create the yy variable, just use the command gen yy = “” in 1/n, where n is the number of observations in the xx variable you’re using as the basis for the spline interpolation.

    Then, SAVE THE FILE to your local hard drive. If you haven’t saved at this point and try to run the spline commands, it will give you an (r4) error.

    Once you’ve done that, try running the do file again.

    Good luck!

%d bloggers like this: