|
|
|
||||
|
|
|||||
Please note that the "early_int" data file (which is used in Chapter 3) is not included among the data files. This was done at the request of the researcher who contributed this data file to ensure the privacy of the participants in the study. Although the web page shows how to obtain the results with this data file, we regret that visitors do not have access to this file to replicate the results for themselves.
Table 3.1, page 48
proc print data="c:\alda\earlyint_pp"; where (id=68 or id=70 or id=71 or id=72 or id=902 or id=904 or id=906 or id=908); var id age cog program; run;
Obs ID AGE COG PROGRAM 1 68 1.0 103 1 2 68 1.5 119 1 3 68 2.0 96 1 4 70 1.0 106 1 5 70 1.5 107 1 6 70 2.0 96 1 7 71 1.0 112 1 8 71 1.5 86 1 9 71 2.0 73 1 10 72 1.0 100 1 11 72 1.5 93 1 12 72 2.0 87 1 175 902 1.0 119 0 176 902 1.5 93 0 177 902 2.0 99 0 178 904 1.0 112 0 179 904 1.5 98 0 180 904 2.0 79 0 181 906 1.0 89 0 182 906 1.5 66 0 183 906 2.0 81 0 184 908 1.0 117 0 185 908 1.5 90 0 186 908 2.0 76 0
Figure 3.1, page 50
proc greplay igout = work.gseg nofs;
delete _all_;
run;
goptions reset=all noborder ftext=titalic htext=3 hby=0;
proc gplot data="c:\alda\earlyint_pp" uniform ;
where (id=68 or id=70 or id=71 or id=72 or id=902 or id=904 or id=906 or id=908);
by id;
note justify=center 'ID #byval(ID)';
symbol color=black interpol=reg value=dot height=2 ;
axis1 label=("AGE") order=(1 to 2 by .5) offset=(5) minor=none ;
axis2 label=("COG") order=(50 to 150 by 25) minor=none;
plot cog*age/nolegend haxis=axis1 vaxis=axis2 noframe;
run;
goptions reset=all noborder hby=3 rotate=portrait hsize= 7in ;
proc greplay igout=work.gseg tc=sashelp.templt
template=h4 nofs;
treplay 1:1 2:2 3:3 4:4;
treplay 1:5 2:6 3:7 4:8;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:template 2:templat1;
run;
quit;
Figure 3.3, page 57
proc means data="c:\alda\earlyint_pp" nway noprint;
class age;
var cog;
output out=earlyint_mean mean=COG ;
run;
data earlyint_mean;
set earlyint_mean;
ID = 9999;
drop _freq_ _type_;
run;
data earlyint;
set "c:\alda\earlyint_pp" earlyint_mean;
run;
proc sort data=earlyint;
by id;
run;
* Creating graph at top of figure 3.3;
goptions reset=global gunit=pct noborder cback=white ftext=titalic htext=3;
proc gplot data=earlyint;
axis1 label=("AGE") order=(1 to 2 by .5) offset=(2 cm) minor=none color=black;
axis2 label=("COG") order=(50 to 150 by 25) minor=none color=black;
symbol1 color=black interpol=rl value=none height=2 repeat=103;
symbol2 color=red interpol=rl value=none width=20 repeat=1;
plot cog*age=id / nolegend haxis=axis1 vaxis=axis2 noframe;
run;
Figure 3.3 stem and leaf plots , page 57
data earlyint2; set "c:\alda\earlyint_pp"; time = age-1; run; proc reg data=earlyint2 outest=ols rsquare noprint; model cog=time; by id; run; data ols; set ols; InitialStatus=Intercept; RateOfChange=Time; ResidualVariance=_rmse_**2; keep id initialstatus rateofchange residualvariance; run; * making step and leaf plots for bottom part of figure 3.3 ; proc univariate data=ols plot; var initialstatus rateofchange residualvariance; run;
The UNIVARIATE Procedure
Variable: InitialStatus
Stem Leaf # Boxplot
14 0 1 |
13 5568 4 |
13 00134 5 |
12 5556778999 10 |
12 02233344 8 +-----+
11 55667777888889 14 | |
11 000111112222233334444 21 *--+--*
10 55666688999 11 | |
10 0012222244 10 +-----+
9 6666677799 10 |
9 344 3 |
8 89 2 |
8 34 2 |
7 7 1 |
7
6
6
5 7 1 0
----+----+----+----+-
Multiply Stem.Leaf by 10**+1
The UNIVARIATE Procedure
Variable: RateOfChange
Stem Leaf # Boxplot
2 0 1 0
1
1 0 1 |
0 79 2 |
0 134 3 |
-0 4444332 7 |
-0 99998888777765 14 +-----+
-1 4333322211000 13 | |
-1 99888877666655 14 *--+--*
-2 44322211110000 14 | |
-2 9999877776655 13 +-----+
-3 443322100000 12 |
-3 987 3 |
-4 443111 6 |
----+----+----+----+
Multiply Stem.Leaf by 10**+1
The UNIVARIATE Procedure
Variable: ResidualVariance
Stem Leaf # Boxplot
46 8 1 *
44
42
40 00 2 *
38
36 8 1 *
34
32 3 1 0
30
28 4 1 0
26 7 1 0
24 1444 4 0
22 8 1 |
20 |
18 3 1 |
16 00011 5 |
14 |
12 21 2 |
10 44433 5 |
8 1118886666 10 +-----+
6 77744 5 | + |
4 333844 6 | |
2 04444888833338888888 20 *-----*
0 0000111122233334444444466668111114447 37 +-----+
----+----+----+----+----+----+----+--
Multiply Stem.Leaf by 10**+1
Figure 3.4, page 59
proc means data="c:\alda\earlyint_pp" nway noprint; class age program; var cog; output out=earlyint_mean0 mean=COG ; run;
data earlyint_mean0; set earlyint_mean0; ID = 9999; drop _freq_ _type_; run;
data earlyint0; set "c:\alda\earlyint_pp" earlyint_mean0; run;
proc sort data=earlyint0; by program id; run;
proc greplay igout = fig34 nofs;
delete _all_;
run;
goptions reset=all noborder ftext=titalic htext=3;
axis1 label=("AGE") order=(1 to 2 by .5) offset=(2 cm) minor=none color=black;
axis2 label=("COG") order=(50 to 150 by 25) minor=none color=black;
symbol1 color=black interpol=rl value=none height=2 repeat=45;
symbol2 color=red interpol=rl value=none width=10 repeat=1;
proc gplot data=earlyint0 gout=fig34;
plot cog*age=id / nolegend haxis=axis1 vaxis=axis2 noframe;
where program = 0;
run;
symbol1 color=black interpol=rl value=none height=2 repeat=58;
symbol2 color=red interpol=rl value=none width=10 repeat=1;
proc gplot data=earlyint0 gout=fig34;
plot cog*age=id / nolegend haxis=axis1 vaxis=axis2 noframe;
where program = 1;
run;
quit;
* Showing both graphs in figure 3.4, but showing them top/bottom instead of side by side; goptions reset=all noborder hby=3 rotate=portrait hsize= 7in ; proc greplay igout=fig34 tc=sashelp.templt template=h2 nofs ; treplay 1:1 2:2; run; quit;
Table 3.3, page 69. Notice that in the proc mixed below, we made use of parms statement. This is because of the problem of non-positive definite G matrix when we didn't have the initial values for variance-covariance matrix. The parms statement allows us to specify the lower and upper bound for each of the variance-covariance parameter and tell SAS to search for the optimal values on the grid defined by the number lists.
* Table 3.3: Results of fitting a multilevel model for
change to the early intervention data (n=103);
proc mixed data=earlyint2 method=ml noclprint noinfo covtest ;
title1 "Table 3.3: Early intervention data
-- Basic multilevel model for change";
title2 "Full ML";
class id;
model cog=time program time*program/solution notest ;
random intercept time/type=un sub=id;
parms (120 to 126 by .5) (-37 to -35 by .5)
(11 to 19 by 1) (72 to 74 by .5) / noiter noprofile;
run;
Table 3.3: Early intervention data -- Basic multilevel model for change
Full ML
The Mixed Procedure
Covariance Parameter Estimates
Standard Z Cov Parm Subject Estimate Error Value Pr Z UN(1,1) ID 125.75 27.9642 4.50 <.0001 UN(2,1) ID -36.7181 23.3376 -1.57 0.1156 UN(2,2) ID 11.0657 31.2760 0.35 0.3617 Residual 74.4421 10.3768 7.17 <.0001
Asymptotic Covariance Matrix of Estimates
Row Cov Parm CovP1 CovP2 CovP3 CovP4 1 UN(1,1) 782.00 -516.95 443.38 -93.0949 2 UN(2,1) -516.95 544.64 -592.66 111.71 3 UN(2,2) 443.38 -592.66 978.19 -221.43 4 Residual -93.0949 111.71 -221.43 107.68
Fit Statistics
-2 Log Likelihood 2370.0 AIC (smaller is better) 2378.0 AICC (smaller is better) 2378.1 BIC (smaller is better) 2388.5
Solution for Fixed Effects
Standard Effect Estimate Error DF t Value Pr > |t|
Intercept 107.84 2.0428 101 52.79 <.0001 TIME -21.1333 1.8853 101 -11.21 <.0001 PROGRAM 6.8547 2.7222 103 2.52 0.0133 TIME*PROGRAM 5.2713 2.5124 103 2.10 0.0383
Figure 3.5 on page 71.
proc mixed data=earlyint2 method=ml noclprint noinfo covtest ;
class id;
model cog=time program time*program/ outpm=fig3_5 solution notest ;
random intercept time/type=un sub=id;
parms (120 to 126 by .5) (-37 to -35 by .5)
(11 to 19 by 1) (72 to 74 by .5) / noiter noprofile;
run;
goptions reset = all hsize = 4in vsize = 3in device = gif570 htext = 1 ftext = titalic;;
axis1 order = (1 to 2 by .5) minor = none label = ('AGE');
axis2 order = (50 to 150 by 25) minor = none label = ('COG');
symbol i = join ;
legend label=none value=(h=1 font=swiss 'Non-participants' 'Program participants')
position=(bottom right inside) mode=share ;
proc gplot data = fig3_5; plot pred*age = program /haxis = axis1 vaxis = axis2 noframe legend=legend1; run; quit;
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services