{ This program will not run unless you load the data file: READING.STA
Program written, modified, or edited at StatSoft, Inc.}
randomaccess;
{ Dimension arrays}
Dim se(2,2); {within (error) SS}
Dim sh0(2,2); {hypothesis + error SS, overall mean}
Dim sh1(2,2); {hypothesis + error SS, Method}
Dim sh2(2,2); {hypothesis + error SS, Grade}
Dim sh12(2,2); {hypothesis + error SS, Grade x Method}
Dim x(60,8); {Design matrix}
Dim mat(8,8); {crossproduct matrix}
Dim work1(8,8); {scratch space}
Dim Table(4,6); {table for Scrollsheet}
Dim xdata(3,2); {for plot of means}
Dim ydata(3,2); {for plot of means}
{Code design matrix}
for i:=1 to NCases do begin
{overall mean}
x(i,1):=1;
{main effect METHOD}
if (data(i,1)=1) then x(i,2):=1 else x(i,2):=-1;
{main effect GRADES}
x(i,3):=0;x(i,4):=0;
if (data(i,2)=1) then begin x(i,3):=1; x(i,4):=1;end;
if (data(i,2)=2) then begin x(i,3):=-1;x(i,4):=0;end;
if (data(i,2)=3) then begin x(i,3):=0; x(i,4):=-1;end;
{interactions}
x(i,5):=x(i,2)*x(i,3);
x(i,6):=x(i,2)*x(i,4);
{dependent variables}
x(i,7):=data(i,3);
x(i,8):=data(i,4);
end;
{display design matrix}
NewScrollsheet (NCases, 8, x, 'Design Matrix', '',
'Mean|Method|Grades(1)|Grades(2)|MxG(1)|MxG(2)|'+VarName(3)+'|'+VarName(4));
{compute crossproduct matrix}
MatrixCrossProductOfDev (x, 0, mat);
{compute residual (error) SS}
MatrixSweep (mat, 1, 6, 1);
MatrixCopy (mat, 7, 7, 2, 2, se, 1, 1);
MatrixDet (se, de);
{compute sh+se for overall mean}
MatrixCopy (mat,1,1,8,8,work1,1,1);
MatrixSweep (work1, 1, 1, -1);
MatrixCopy (work1, 7, 7, 2, 2, sh0, 1, 1);
MatrixDet (sh0, d0);
{compute sh+se for METHOD main effect}
MatrixCopy (mat,1,1,8,8,work1,1,1);
MatrixSweep (work1, 2, 2, -1);
MatrixCopy (work1, 7, 7, 2, 2, sh1, 1, 1);
MatrixDet (sh1, d1);
{compute sh+se for GRADE main effect}
MatrixCopy (mat,1,1,8,8,work1,1,1);
MatrixSweep (work1, 3, 4, -1);
MatrixCopy (work1, 7, 7, 2, 2, sh2, 1, 1);
MatrixDet (sh2, d2);
{compute sh+se for METHOD * GRADE main effect}
MatrixCopy (mat,1,1,8,8,work1,1,1);
MatrixSweep (work1, 5, 6, -1);
MatrixCopy (work1, 7, 7, 2, 2, sh12, 1, 1);
MatrixDet (sh12, d12);
{Results; see also Lindeman, Merenda, Gold (1980), page 234}
line01$:='MANOVA Results';
rowname$:='Method|Grade|M x G';
colname$:='Wilks l|Rao R|df 1|df 2| p|';
ne:=NCases-6;
table(1,1):=de/d1;
table(1,2):=(1-table(1,1))/table(1,1)*(ne+1-2)/2;
table(1,3):=2;
table(1,4):=ne+1-2;
table(1,5):=1-IFDistr (table(1,2), table(1,3), table(1,4));
table(2,1):=de/d2;
table(2,2):=(1-sqrt(table(2,1)))/sqrt(table(2,1))*(ne+2-2-1)/2;
table(2,3):=4;
table(2,4):=2*(ne+2-2-1);
table(2,5):=1-IFDistr (table(2,2), table(2,3), table(2,4));
table(3,1):=de/d12;
table(3,2):=(1-sqrt(table(3,1)))/sqrt(table(3,1))*(ne+2-2-1)/2;
table(3,3):=4;
table(3,4):=2*(ne+2-2-1);
table(3,5):=1-IFDistr (table(3,2), table(3,3), table(3,4));
handl:=NewScrollsheet (3, 5, table, line01$, rowname$, colname$);
ScrollsheetSetColumnFormat (handl, 3, SCF_INTEGER, 8);
ScrollsheetSetColumnFormat (handl, 4, SCF_INTEGER, 8);
{highlight significant effects (p<.05)}
for i:=1 to 3 do begin
if table(i,5)<.05 then begin
for j:=1 to 5 do ScrollsheetSetHilite (handl, i, j, 1);
end;
end;
{Compute Scrollsheet of means (provisional means algorithm)}
rownam$:=GetText(METHOD, 1)+'|'+GetText(METHOD, 2);
colname$:=GetText(GRADES, 1)+'|'+GetText(GRADES, 2)+'|'+GetText(GRADES, 3);
for ivar:=3 to 4 do begin
MatrixSetToZero (table);
MatrixSetToZero (work1);
for i:=1 to NCases do begin
im:=data(i,1);jm:=data(i,2);
di:=data(i,ivar)-table(im,jm);
work1(im,jm):=work1(im,jm)+1;
table(im,jm):=table(im,jm)+di/work1(im,jm);
end;
NewScrollsheet (2, 3, table, 'Means for variable '+VarName (ivar),
rowname$, colname$);
{Plot of Means}
for i:=1 to 3 do begin
xdata(i,1):=i;xdata(i,2):=i;
ydata(i,1):=table(1,i);ydata(i,2):=table(2,i);
end;
{make the default graph}
ihandl:=NewGraph (LINEPLOT, 'Plot of Means: '+VarName(ivar),
VarName(ivar), VarName(2), 3, xdata, ydata);
MatrixCopy (ydata, 1, 2, 3, 1, ydata, 1, 1);
{add second plot}
GraphAddPlot (ihandl, LINEPLOT, '', 3, xdata, ydata);
{turn on the points for plot 1, default size and color}
GraphSetPlotPointStyle (ihandl, 1, ON, 0, ?Size, ?Color);
{turn on the points for plot 2}
GraphSetPlotPointStyle (ihandl, 2, ON, 5, ?Size, ?Color);
{Set legend}
line01$:=VarName(1)+': @l[1]'+GetText(METHOD, 1)+
' @l[2]'+GetText(METHOD, 2);
GraphSetTitle (ihandl, 2, line01$);
{set scale for x-axis}
GraphSetScaleTextLabels (ihandl, AX_X, 3, xdata, colname$);
end;
| Back to List of Programs |
![[StatSoft]](../../../images/sssmall.gif)
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217
e-mail: info@statsoft.com
©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.