#delim cr version 6.0 /* Examples for the STB bulletin submission for bspline and frencurv */ /* Open log file */ log using example1.log,replace capture noisily{ /* Beginning of main capture block */ /* Use auto data set and define additional variables */ use auto,clear sort weight desc /* Create symbol variable for foreign cars */ gene str1 forsym="D" replace forsym="F" if(foreign) /* Demo of frencurv and bspline */ * frencurv with extended reference points (default) and cubic spline * frencurv,xvar(weight) refpts(1760(770)4840) gen(cs) power(3) describe cs* regress mpg cs*,noconst robust lincom cs3-cs5 predict mpghat3 grap mpg mpghat3 weight,s(o.) c(.L) xlab(1760(770)4840) ylab(0(5)45) t1(" ") l1("Mileage (mpg)") saving(fig3.gph,replace) * frencurv with cubic spline and unextended reference points * frencurv,xvar(weight) refpts(1760(513.33333)4840) noexr k(1760(770)4840) gen(sp) power(3) labfmt(%7.2f) describe sp* regress mpg sp*,noconst robust * bspline with the same model as frencurv * bspline,xvar(weight) knots(1760(770)4840) gen(bs) power(3) labf(%4.0f) describe bs* regress mpg bs*,noconst robust /* Convert Stata graphics to encapsulated PostScript (USING THE gphpen ROUTINE FOR WINDOWS, WHICH I HAVE BUT MOST Stata 6.0 USERS DO NOT HAVE) */ gphpen /n /deps /ofig3.eps fig3.gph /* End of main capture block */ } /* Close log file and exit */ log close exit