#delim ; version 6.0; * Create Figures 1 and 2 for B-spline insert *; * Open log file *;log using fig1_2.log,replace; capture noisily{ * Beginning of main capture block *; * Figure 1. B-splines *; clear; * Maximum of X-axis *; local xmax=4; * Number of positive points and total points on graph *; local nposi=512;local npoint=`nposi'+1; * Create X-variate *; set obs `npoint'; gene int seqnum=_n-1;gene double x=`xmax'*(seqnum/_N); label variable x "X"; * Create B-splines for Figure 1 *; bspline,x(x) gene(bs0_) knot(0(1)`xmax') noexk type(double) pow(0); bspline,x(x) gene(bs1_) knot(0(1)`xmax') noexk type(double) pow(1); bspline,x(x) gene(bs2_) knot(0(1)`xmax') noexk type(double) pow(2); bspline,x(x) gene(bs3_) knot(0(1)`xmax') noexk type(double) pow(3); format bs* %4.2f; * Plot B-splines *; grap bs0_1 x,c(.) s(.) l1title("Constant B-spline on [0,1)") b2title(" ") xlab(0(1)`xmax') ylab(0(0.25)1) saving(fig1a.gph,replace); grap bs1_1 x,c(.) s(.) l1title("Linear B-spline on [0,2)") b2title(" ") xlab(0(1)`xmax') ylab(0(0.25)1) saving(fig1b.gph,replace); grap bs2_1 x,c(.) s(.) l1title("Quadratic B-spline on [0,3)") b2title(" ") xlab(0(1)`xmax') ylab(0(0.25)1) saving(fig1c.gph,replace); grap bs3_1 x,c(.) s(.) l1title("Cubic B-spline on [0,4)") b2title(" ") xlab(0(1)`xmax') ylab(0(0.25)1) saving(fig1d.gph,replace); * Combine B-splines to get Figure 1 *; grap using fig1a fig1b fig1c fig1d, saving(fig1.gph,replace); * Figure 2. Reference splines *; clear; * Maximum of X-axis *; local xmax=8; * Number of positive points and total points on graph *; local nposi=1024;local npoint=`nposi'+1; * Create X-variate *; set obs `npoint'; gene int seqnum=_n-1;gene double x=`xmax'*(seqnum/_N); label variable x "X"; * Create reference splines for Figure 2 *; frencurv,x(x) gene(sp0_) ref(0(1)`xmax') type(double) pow(0); frencurv,x(x) gene(sp1_) ref(0(1)`xmax') type(double) pow(1); frencurv,x(x) gene(sp2_) ref(0(1)`xmax') type(double) pow(2); frencurv,x(x) gene(sp3_) ref(0(1)`xmax') type(double) pow(3); format sp* %5.2f; * Plot B-splines *; grap sp0_5 x,c(.) s(.) l1title("Constant spline at 4") b2title(" ") xlab(0(1)`xmax') ylab(-0.25(0.25)1) saving(fig2a.gph,replace); grap sp1_5 x,c(.) s(.) l1title("Linear spline at 4") b2title(" ") xlab(0(1)`xmax') ylab(-0.25(0.25)1) saving(fig2b.gph,replace); grap sp2_6 x,c(.) s(.) l1title("Quadratic spline at 4") b2title(" ") xlab(0(1)`xmax') ylab(-0.25(0.25)1) saving(fig2c.gph,replace); grap sp3_6 x,c(.) s(.) l1title("Cubic spline at 4") b2title(" ") xlab(0(1)`xmax') ylab(-0.25(0.25)1) saving(fig2d.gph,replace); * Combine reference splines to get Figure 2 *; grap using fig2a fig2b fig2c fig2d, saving(fig2.gph,replace); * Convert Figures to PostScript (USING THE gphpen ROUTINES KINDLY PROVIDED BY ALAN RILEY WHICH I HAVE BUT MOST Stata 6.0 USERS DO NOT HAVE) *; gphpen /n /deps /ofig1.eps fig1.gph; gphpen /n /deps /ofig2.eps fig2.gph; * End of main capture block *; }; * Close log file and exit *;log close;exit;