Stata Technical Bulletin
25
between the values of the spline at different reference points. Here, we estimate the difference between expected mileage at
weights of 2,530 and 4,070 pounds:
. Iincom cs3-c≡5
( 1) c≡3 - c≡5 = 0.0
—
mpg I Coef. Std. Err. t P>∣t∣ [957. Conf. Interval]
---------+--------------------------------------------------------------------
(1) I 7.142029 1.058829 6.745 0.000 5.028598 9.25546
We see that cars weighing 2,530 pounds are expected to travel 5.03 to 9.26 more miles per gallon than cars weighing 4,070
pounds.
We can, instead, choose an alternative set of reference points, using noexref and specifying our own knots. The initial
knots are the same initial knots as in the previous model (where they were also reference points), namely 5 equally spaced
values from the minimum to the maximum of weight. However, the new reference points are 7(= 5 + 2) equally spaced values
covering the same range. The knots and the reference points are therefore out of synchrony, but the reference points are now all
in the completeness region of the spline because they are in the range spanned by the initial knots. (Remember that by default,
bspline and frencurv add new knots on the left and right to make the spline complete over the range of the original knots.)
The model is exactly the same model as before (because a spline model is defined by the knots), but the parameters are now
all sensible within-range mpg values, which nontechnical people can understand. Note that we have used Iabfmt to handle the
noninteger values of the reference points in the variable labels.
. frencurv,xvar(weight) refpts(1760(513.33333)4840) noexr k(1760(770)4840) gen(sp)
> power(3) Iabfmt(%7.2f)
. describe sp*
20. |
spl |
float |
7.8.4f |
Spline at 1760.00 |
21. |
sp2 |
float |
7.8.4f |
Spline at 2273.33 |
22. |
sp3 |
float |
7.8.4f |
Spline at 2786.67 |
23. |
sp4 |
float |
7.8.4f |
Spline at 3300.00 |
24. |
sp5 |
float |
7.8.4f |
Spline at 3813.33 |
25. |
sp6 |
float |
7.8.4f |
Spline at 4326.67 |
26. |
sp7 |
float |
7.8.4f |
Spline at 4840.00 |
(Continued on next page)