/**********************************************************************/ /* Atkinson, Donev, and Tobias, "Optimum Experimental Designs" */ /* */ /* NAME: Program 6.2 */ /* TITLE: Computations for Figures 6.3 & 6.4 - Standardized */ /* variances for simple regression */ /* KEYS: */ /* DATA: Designs in Table 6.1 */ /* */ /* Author: Randy Tobias */ /* History: */ /* Created...............................................27Jun2007 */ /**********************************************************************/ title1 "Computations for Figures 6.3 & 6.4"; title2 "Standardized variances for simple regression"; /* / Create a single data set containing all six designs. /---------------------------------------------------------------------*/ data Table6_1; input Design nTrial @@; do i=1 to nTrial; input x @@; output; end; cards; 6.1 3 -1 0 1 6.2 6 -1 -1 0 0 1 1 6.3 8 -1 -1 -1 -1 -1 -1 1 1 6.4 5 -1 -0.5 0 0.5 1 6.5 7 -1 -1 -0.9 -0.85 -0.8 -0.75 1 6.6 2 -1 1 6.7 4 -1 -1 0 1 6.8 4 -1 0 0 1 ; proc iml; use Table6_1; read all var {Design x}; /* / Create the horizontal variable for the plots, and the corresponding / coefficients of the simple linear model. /---------------------------------------------------------------------*/ xx = 2*(0:100)`/100 - 1; xx = j(nrow(xx),1) || xx; /* / For each design ... /---------------------------------------------------------------------*/ free e; do i = 1 to 6; l = loc(design(Design)[,i]); /* / ... create its variance matrix V ... /---------------------------------------------------------------------*/ F = j(ncol(l),1) || x[l,]; V = inv(F`*F); /* / ... and take the standardized variances from the diagonal of the / variance-covariance matrix over the entire horizontal variable. / Note that this is succinct but inefficient: it allocates memory for / and computes ~nXX**2/2 values when only nXX are required. /---------------------------------------------------------------------*/ d = vecdiag(ncol(l)*xx*V*xx`); e = e || d; end; /* / Put the standardized variances in a data set and print it. /---------------------------------------------------------------------*/ create StdVar var ("xx"||("dChi1":"dChi6")); e = xx[,2] || e; append from e; proc print data=StdVar; run; title2; title1;