26
Stata Technical Bulletin
STB-57
. regress mpg sp*,noconst robust
Regression with robust standard errors
Number of obs = 74
F( 7, 67) = 618.91
Prob > F = 0.0000
R-squared = 0.9792
Root MSE = 3.3469
I Robust
≡pg I |
Coef. |
Std. Err. |
t |
p>∣t∣ |
[957. Conf. |
Interval] |
spi I |
29.21133 |
1.761704 |
16.581 |
0.000 |
25.69495 |
— 32.72771 |
sp2 I |
25.89924 |
1.073405 |
24.128 |
0.000 |
23.75671 |
28.04177 |
sp3 I |
20.98226 |
.7479685 |
28.052 |
0.000 |
19.4893 |
22.47521 |
sp4 I |
19.4749 |
.610094 |
31.921 |
0.000 |
18.25715 |
20.69266 |
sp5 I |
15.97982 |
.5560974 |
28.736 |
0.000 |
14.86985 |
17.0898 |
sp6 I |
16.74691 |
1.934879 |
8.655 |
0.000 |
12.88487 |
20.60894 |
sp7 I |
10.60747 |
1.585487 |
6.690 |
0.000 |
7.442828 |
13.77212 |
Finally, for technical people, we can fit the same model yet again, using bspline instead of frencurv. Here, the splines
are В-splines rather than reference splines. The variable labels show the range of positive values of each В-spline, delimited
by knots, including the extra knots calculated by bspline. The parameters are expressed in miles per gallon but are not easy
for nonmathematicians to interpret.
. bspline,xvar(weight) knots(1760(770)4840) gen(bs) power(3) labf(%4.0f)
. describe bs*
27. bsl |
float |
7.8.4f |
B-spline |
on [-550,2530) | ||
28. b≡2 |
float |
7.8.4f |
B-spline |
on [220,3300) | ||
29. b≡3 |
float |
7.8.4f |
B-spline |
on [990,4070) | ||
30. b≡4 |
float |
7.8.4f |
B-spline |
on [1760,4840) | ||
31. bs5 |
float |
7.8.4f |
B-spline |
on [2530,5610) | ||
32. bs6 |
float |
7.8.4f |
B-spline |
on [3300,6380) | ||
33. b≡7 |
float |
7.8.4f |
B-spline |
on [4070,7150) | ||
. regress |
mpg bs*,noconst robust | |||||
Regression with robust |
standard errors |
Number of obs |
= 74 | |||
F( 7, 67) |
= 618.91 | |||||
Prob > F |
= 0.0000 | |||||
R-squared |
= 0.9792 | |||||
Root MSE |
= 3.3469 | |||||
— I |
I |
Robust |
— | |||
≡pg I |
I Coef. |
Std. Err. |
t |
p>∣t∣ |
[957. Conf. |
Interval] |
— | ||||||
bsl I |
I 8.530818 |
24.5484 |
0.348 |
0.729 |
-40.468 |
57.52964 |
bs2 I |
I 36.83022 |
5.330421 |
6.909 |
0.000 |
26.19066 |
47.46979 |
bs3 I |
I 19.41627 |
2.252816 |
8.619 |
0.000 |
14.91963 |
23.91291 |
bs4 I |
I 21.45246 |
1.708278 |
12.558 |
0.000 |
18.04272 |
24.8622 |
bs5 I |
I 11.62333 |
2.241923 |
5.185 |
0.000 |
7.148434 |
16.09823 |
bs6 I |
I 25.14979 |
7.910832 |
3.179 |
0.002 |
9.359707 |
40.93988 |
bs7 I |
I -48.57765 |
34.29427 |
-1.416 |
0.161 |
-117.0293 |
19.87399 |
Technical note
There are other programs in Stata to generate splines. mkspline (see [R] mkspline) generates a basis of linear splines to
be used in a design matrix, as does frencurv, power (1), but the basis is slightly different because the fitted parameters for
frencurv are reference values, whereas the fitted parameters for mkspline are the local slopes of the spline in the inter-knot
intervals. spline and spbase (Sasieni 1994) are used for fitting a natural cubic spline, which is constrained to be linear outside
the completeness region and parameterized using the truncated power basis. The splines fitted using bspline or frencurv,
on the other hand, are unconstrained (hence the extra degrees of freedom corresponding to the external reference points) and
parameterized using the В-spline or reference spline basis, respectively. frencurv and bspline are therefore complementary
to the existing programs and do not supersede them.