notes splines interpolation

notes splines interpolation - Eco 572: Research methods in...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Eco 572: Research methods in Demography Interpolation Splines can also be used for interpolation. Here we reproduce the results in the article by Mc Neil, Trussell and Turner listed in the readings. The Data The data represent cumulative fertility at ages 20(5)50, which we can just type into Stata. . clear . input age F age F 1. 15 0 2. 20 .080 3. 25 .593 4. 30 1.297 5. 35 1.840 6. 40 2.171 7. 45 2.296 8. 50 2.306 9. end Polynomial Interpolation With 8 data points we can get an exact fit using a 7-th degree polynomial. Let us reproduce Figure 1 in the article, showing that polynomials don't work very well in this case. We need age^2 to age^7: . forvalues p=2/7 { 2. gen age`p' = age^`p' 3. } . quietly regress F age* Because the fit is exact the residual sum of squares is 0 and the standard errors are undefined, so we wont print the results. To do the interpolation we create a new data set with age in single years and just predict . How that for easy? We'll go from 13 to 51 to the extremes. . drop _all . set obs 39 obs was 0, now 39 . gen age = 12 + _n . forvalues p=2/7 { 2. gen age`p' = age^`p' 3. } . predict Fit (option xb assumed; fitted values) . line Fit age, xlabel(15(5)50) name(Fp) Now that we have cumulative fertility at ages 13 to 51 we can compute differences to obtain age-specific fertility rates centered at the midpoints and plot them . gen fit = Fit - Fit[_n-1] http://data.princeton.edu/eco572/interpolation.html (1 of 5) [2/12/2008 10:28:16 AM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Eco 572: Research methods in Demography (1 missing value generated) . gen agem = (age + age[_n-1])/2 (1 missing value generated) . line fit agem, xtitle(age) xlabel(15(5)50) name(fp) . graph combine Fp fp, xsize(6) ysize(3) title(Polynomial Fit) . graph export iasfrp.png, replace (file iasfrp.png written in PNG format) You can see that the polynomial is not very well behaved at the extremes. This is not unusual with polynomials. (An alternative way to do the plots is to use Stata's
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/12/2008 for the course ECON 572 taught by Professor Rodriguez during the Spring '06 term at Princeton.

Page1 / 5

notes splines interpolation - Eco 572: Research methods in...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online