/****************************************************************/ /* S A S S A M P L E L I B R A R Y */ /* */ /* NAME: TREGLS2 */ /* TITLE: Two Linear And Nonlinear Regression Functions */ /* PRODUCT: STAT */ /* SYSTEM: ALL */ /* KEYS: regression analysis, transformations */ /* PROCS: TRANSREG */ /* DATA: */ /* */ /* REF: PROC TRANSREG, LEAST SQUARES EXAMPLE 2 */ /* MISC: THE PARALLEL LINES/CURVES MAY NOT LOOK PARALLEL DUE */ /* TO THE LIMITED RESOLUTION IN PRINTER PLOTS. USE */ /* PROC GPLOT TO GET A BETTER GRAPHICAL DISPLAY. */ /* */ /* THIS EXAMPLE HAS BEEN MODIFIED SINCE IT APPEARED */ /* IN THE RELEASE 6.06 SAS/STAT USER'S GUIDE */ /* */ /****************************************************************/ data a; do x = -2 to 3 by 0.025; g = 1; x1 = x; x2 = 0; y = 8*(x*x + 2*cos(x*6)) + 15*normal(7654321); output; g = 2; x1 = 0; x2 = x; y = 4*(-x*x + 4*sin(x*4)) - 40 + 15*normal(7654321); output; end; run; proc transreg data=a dummy; title1 'parallel lines, separate intercepts'; model identity(y) = class(g) identity(x); output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a; title1 'parallel monotone curves, separate intercepts'; model identity(y) = class(g) mspline(x / knots=-1.5 to 2.5 by 0.5); output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a dummy; title1 'parallel curves, separate intercepts'; model identity(y) = class(g) spline(x / knots=-1.5 to 2.5 by 0.5); output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a dummy; title1 'separate slopes, same intercept'; model identity(y) = identity(x1-x2); id x; output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a; title1 'separate monotone curves, same intercept'; model identity(y) = mspline(x1-x2 / knots=-1.5 to 2.5 by 0.5); id x; output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a dummy; title1 'separate curves, same intercept'; model identity(y) = spline(x1-x2 / knots=-1.5 to 2.5 by 0.5); id x; output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a dummy; title1 'separate slopes, separate intercepts'; model identity(y) = class(g) identity(x1-x2); id x; output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a dummy; title1 'separate monotone curves, separate intercepts'; model identity(y) = class(g) spline(x1-x2 / knots=-1.5 to 2.5 by 0.5); id x; output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run; proc transreg data=a dummy; title1 'separate curves, separate intercepts'; model identity(y) = class(g) spline(x1-x2 / knots=-1.5 to 2.5 by 0.5); id x; output approximations; run; proc plot; plot ay*x='r' y*x='*' / box overlay href=0 vref=0; run;