************ G2.sps for Generalizability Theory analyses*************
* This file contains program syntax and illustrative data for
conducting Generalizability Theory analyses using the
SPSS VARCOMPS procedure. The VARCOMPS procedure has a number
of useful options for computing variance components, but it
also has three shortcomings: (1) it runs slowly for
even modest-sized data sets; (2) the set-up of the data that
is entered into the VARCOMPS procedure is quite different from
the set-up that many users will have for their data; and
(3) it provides only variance components and no additional
Generalizability Theory statistics. Nothing can be
done about the slow speed, but the other two shortcomings
are addressed by the syntax in this file.
* The VARCOMPS procedure requires that each row of a data matrix
consist of a single observation (e.g., a single score or rating)
and the condition values (e.g., as is the levels of
independent variables) for the observation/score/rating. This
is probably not the arrangement that many people will have in
their data files. More commonly, all of the data for one
case (person) appears on one line/record, and the observations
(scores or ratings) have variable names but with no explicit
levels. For example, if the data were based on 10 items
that were administered to each person on two occasions,
then the common data set-up would be to have 20 variables
for each person. To enter this data into VARCOMPS, the data
set would have to be rearranged. Every score for each person
would have to appear on a separate line, accompanied by
correct values for new variables indicating the item level (1-to-10)
and the occasion (1 and 2). The SPSS VARSTOCASES procedure can be
used to rearrange data sets in the correct, necessary
ways. The online documention for the VARSTOCASES procedure
is very good, and there is no need to repeat the
instructions here. Instead, the procedure is illustrated
below for the data sets used by Brennan (2001) and Shavelson
& Webb (1991) in their texts on Generalizability Theory. For each
example, the illustrative data are presented along with commands for
reading the data into SPSS, with VARSTOCASES commands for transforming
the data set-ups for entry into VARCOMPS, and by commands
for running VARCOMPS on the data.
* The VARCOMPS procedure has an option for saving the variance
components results to an SPSS data file. This file can
then be read and Generalizability Theory computations
can be performed on the saved data. At the end of the
illustrative data examples in this file is a set of
SPSS MATRIX-END MATRIX commands that read the saved
variance components and perform the remaining
Generalizability Theory analyses.
* Here are the options for the METHOD statement on the VARCOMPS
procedure: ML, REML, MINQUE (0), MINQUE (1), SSTYPE (1), and SSTYPE (3).
* one-facet crossed design, as in p x i
Type 1, based on Brennan, 2001, page 431, Table A.1
data from Brennan, 2001, p. 28, Table 2.2, & p. 36, Table 2.4
10 persons, 12 items.
data list free / v1 to v12.
begin data.
1 0 1 0 0 0 0 0 0 0 0 0
1 1 1 0 0 1 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0 0 0
1 1 0 1 1 0 0 1 0 0 0 0
1 1 1 1 1 0 1 0 0 0 0 0
1 1 1 0 1 1 1 0 0 0 0 0
1 1 1 1 1 1 1 0 0 0 0 0
1 1 1 1 0 1 1 1 1 1 0 0
1 1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1
end data.
descriptives var = all.
varstocases / make depend from v1 to v12 / index = item / id = person.
descriptives var = all.
VARCOMP depend BY person item
/RANDOM = person item
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person item
/INTERCEPT = INCLUDE .
* one-facet crossed design, as in p x i
Type 1, based on Brennan, 2001, page 431, Table A.1
data from Shavelson & Webb, 1991, p. 5, Table 1.1, & p. 29, Table 3.2
20 persons, 8 items.
data list free / v1 to v8.
begin data.
0 1 0 0 0 1 0 1
1 0 1 0 0 0 0 1
1 1 1 0 0 0 0 0
1 1 0 0 1 0 0 1
1 1 1 1 0 0 0 1
1 1 1 1 1 1 1 1
1 0 1 0 0 1 1 0
1 0 1 0 0 0 1 1
1 0 0 0 0 1 1 1
0 1 0 0 1 1 0 0
0 0 0 1 1 1 0 0
0 0 1 0 0 0 0 0
1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1
0 0 1 0 0 0 0 1
1 1 1 0 0 1 0 0
0 1 0 0 0 0 0 0
1 0 0 0 0 1 1 1
0 0 0 0 0 1 1 0
0 1 0 0 0 0 0 0
end data.
descriptives var = all.
varstocases / make depend from v1 to v8 / index = item / id = person.
descriptives var = all.
VARCOMP depend BY person item
/RANDOM = person item
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person item
/INTERCEPT = INCLUDE .
* one-facet nested design, as in i : p
Type 2, based on Brennan, 2001, page 431, Table A.2
data from Brennan, 2001, p. 43, Table 2.8, & p. 44
10 persons, 8 items per person, but none of the items are the same, so there are 80 items.
data list free / v1 to v8.
begin data.
2 6 7 5 2 5 5 5
4 5 6 7 6 7 5 7
5 5 4 6 5 4 5 5
5 9 8 6 5 7 7 6
4 3 5 6 4 5 6 4
4 4 4 7 6 4 7 8
2 6 6 5 2 7 7 5
3 4 4 5 6 6 6 4
0 5 4 5 5 5 5 3
6 8 7 6 6 8 8 6
end data.
descriptives var = all.
varstocases / make depend from v1 to v8 / index = item / id = person.
descriptives var = all.
VARCOMP
depend BY person
/RANDOM = person
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person
/INTERCEPT = INCLUDE .
* two-facet crossed design, as in p x i x o
Type 3, based on Brennan, 2001, page 432, Table A.3
data from Brennan, 2001, p. 72, Table 3.1, & p. 111
10 persons, 4 items, 2 occasions.
data list free / v1 to v8.
begin data.
2 6 7 5 2 5 5 5
4 5 6 7 6 7 5 7
5 5 4 6 5 4 5 5
5 9 8 6 5 7 7 6
4 3 5 6 4 5 6 4
4 4 4 7 6 4 7 8
2 6 6 5 2 7 7 5
3 4 4 5 6 6 6 4
0 5 4 5 5 5 5 3
6 8 7 6 6 8 8 6
end data.
descriptives var = all.
varstocases / make depend from v1 to v8 / index = occ(2) item(4) / id = person.
descriptives var = all.
VARCOMP depend BY person occ item
/RANDOM = person occ item
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person occ item person*item person*occ item*occ
/INTERCEPT = INCLUDE .
* two-facet crossed design, as in p x r x s
Type 3, based on Brennan, 2001, page 432, Table A.3
data from Shavelson & Webb, 1991, p. 69, Table 5.1
8 persons, 3 raters, 2 subject matters.
data list free / v1 to v6.
begin data.
4 4 4 5 5 6
6 7 6 7 9 5
8 7 7 4 3 2
6 8 7 9 11 7
2 1 1 5 5 3
5 4 4 7 6 5
4 5 6 6 8 9
7 7 6 5 9 9
end data.
descriptives var = all.
varstocases / make depend from v1 to v6 / index = subjmat(2) rater(3) / id = teacher.
descriptives var = all.
VARCOMP depend BY teacher rater subjmat
/RANDOM = teacher rater subjmat
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = teacher rater subjmat teacher*rater teacher*subjmat rater*subjmat
/INTERCEPT = INCLUDE .
* two-facet nested design, as in p x (r : t)
Type 4, based on Brennan, 2001, page 432, Table A.4
data from Brennan, 2001, p. 73, Table 3.2, & p. 116
10 persons, 12 raters, 3 tasks.
data list free / v1 to v12.
begin data.
5 6 5 5 5 3 4 5 6 7 3 3
9 3 7 7 7 5 5 5 7 7 5 2
3 4 3 3 5 3 3 5 6 5 1 6
7 5 5 3 3 1 4 3 5 3 3 5
9 2 9 7 7 7 3 7 2 7 5 3
3 4 3 5 3 3 6 3 4 5 1 2
7 3 7 7 7 5 5 7 5 5 5 4
5 8 5 7 7 5 5 4 3 2 1 1
9 9 8 8 6 6 6 5 5 8 1 1
4 4 4 3 3 5 6 5 5 7 1 1
end data.
descriptives var = all.
varstocases / make depend from v1 to v12 / index = rater(12) / id = person.
if rater ge 1 and rater le 4 task = 1.
if rater ge 5 and rater le 8 task = 2.
if rater ge 9 and rater le 12 task = 3.
descriptives var = all.
VARCOMP depend BY person task rater
/RANDOM = person task rater
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person task rater within task person*task
/INTERCEPT = INCLUDE .
* two-facet nested design, as in (F1 : P) * F2;
Type 5, based on Brennan, 2001, page 433, Table A.5
Brennan (2001) and Shavelson & Webb (1991) did not provide illustrative
data for this design. The data from Brennan (2001, p. 73, Table 3.2) are
therefore used below. facet1 is assumed to be nested within persons
10 persons, 4 levels of Facet 1, 3 levels of Facet 2.
data list free / v1 to v12.
begin data.
5 6 5 5 5 3 4 5 6 7 3 3
9 3 7 7 7 5 5 5 7 7 5 2
3 4 3 3 5 3 3 5 6 5 1 6
7 5 5 3 3 1 4 3 5 3 3 5
9 2 9 7 7 7 3 7 2 7 5 3
3 4 3 5 3 3 6 3 4 5 1 2
7 3 7 7 7 5 5 7 5 5 5 4
5 8 5 7 7 5 5 4 3 2 1 1
9 9 8 8 6 6 6 5 5 8 1 1
4 4 4 3 3 5 6 5 5 7 1 1
end data.
descriptives var = all.
varstocases / make depend from v1 to v12 / index = facet2(3) facet1(4) / id = person.
descriptives var = all.
VARCOMP depend BY person facet2 facet1
/RANDOM = person facet2 facet1
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person facet2 facet1 within person person*facet2
/INTERCEPT = INCLUDE .
* two-facet nested design, as in F1 : (P * F2)
Type 6, based on Brennan, 2001, page 433, Table A.6
Brennan (2001) and Shavelson & Webb (1991) did not provide illustrative
data for this design. The data from Brennan (2001, p. 73, Table 3.2) are
therefore used below. facet1 is assumed to be nested within person*facet2
10 persons, 4 levels of Facet 1, 3 levels of Facet 2.
data list free / v1 to v12.
begin data.
5 6 5 5 5 3 4 5 6 7 3 3
9 3 7 7 7 5 5 5 7 7 5 2
3 4 3 3 5 3 3 5 6 5 1 6
7 5 5 3 3 1 4 3 5 3 3 5
9 2 9 7 7 7 3 7 2 7 5 3
3 4 3 5 3 3 6 3 4 5 1 2
7 3 7 7 7 5 5 7 5 5 5 4
5 8 5 7 7 5 5 4 3 2 1 1
9 9 8 8 6 6 6 5 5 8 1 1
4 4 4 3 3 5 6 5 5 7 1 1
end data.
descriptives var = all.
varstocases / make depend from v1 to v12 / index = facet1(12) / id = person.
if facet1 ge 1 and facet1 le 4 facet2 = 1.
if facet1 ge 5 and facet1 le 8 facet2 = 2.
if facet1 ge 9 and facet1 le 12 facet2 = 3.
descriptives var = all.
VARCOMP depend BY person facet2 facet1
/RANDOM = person facet2 facet1
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person facet2 person*facet2
/INTERCEPT = INCLUDE .
* two-facet nested design, as in (F1 * F2) : P
Type 7, based on Brennan, 2001, page 433, Table A.7
Brennan (2001) and Shavelson & Webb (1991) did not provide illustrative
data for this design. The data from Brennan (2001, p. 73, Table 3.2) are
therefore used below. facet1*facet2 is assumed to be nested within persons
10 persons, 4 levels of Facet 1, 3 levels of Facet 2.
data list free / v1 to v12.
begin data.
5 6 5 5 5 3 4 5 6 7 3 3
9 3 7 7 7 5 5 5 7 7 5 2
3 4 3 3 5 3 3 5 6 5 1 6
7 5 5 3 3 1 4 3 5 3 3 5
9 2 9 7 7 7 3 7 2 7 5 3
3 4 3 5 3 3 6 3 4 5 1 2
7 3 7 7 7 5 5 7 5 5 5 4
5 8 5 7 7 5 5 4 3 2 1 1
9 9 8 8 6 6 6 5 5 8 1 1
4 4 4 3 3 5 6 5 5 7 1 1
end data.
descriptives var = all.
varstocases / make depend from v1 to v12 / index = facet2(3) facet1(4) / id = person.
descriptives var = all.
VARCOMP depend BY person facet2 facet1
/RANDOM = person facet2 facet1
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person facet1 within person facet2 within person
/INTERCEPT = INCLUDE .
* two-facet nested design, as in F1 : F2 : P
Type 8, based on Brennan, 2001, page 433, Table A.8
Brennan (2001) and Shavelson & Webb (1991) did not provide illustrative
data for this design. The data from Brennan (2001, p. 73, Table 3.2) are
therefore used below. facet1is assumed to be nested within facet2, which
is assumed to be nested within persons
10 persons, 4 levels of Facet 1, 3 levels of Facet 2.
data list free / v1 to v12.
begin data.
5 6 5 5 5 3 4 5 6 7 3 3
9 3 7 7 7 5 5 5 7 7 5 2
3 4 3 3 5 3 3 5 6 5 1 6
7 5 5 3 3 1 4 3 5 3 3 5
9 2 9 7 7 7 3 7 2 7 5 3
3 4 3 5 3 3 6 3 4 5 1 2
7 3 7 7 7 5 5 7 5 5 5 4
5 8 5 7 7 5 5 4 3 2 1 1
9 9 8 8 6 6 6 5 5 8 1 1
4 4 4 3 3 5 6 5 5 7 1 1
end data.
descriptives var = all.
varstocases / make depend from v1 to v12 / index = facet1(12) / id = person.
if facet1 ge 1 and facet1 le 4 facet2 = 1.
if facet1 ge 5 and facet1 le 8 facet2 = 2.
if facet1 ge 9 and facet1 le 12 facet2 = 3.
descriptives var = all.
VARCOMP depend BY person facet2 facet1
/RANDOM = person facet2 facet1
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person facet2 within person
/INTERCEPT = INCLUDE .
* 3-facet crossed design, as in p x i x o x b
using data from Brennan, 2001, p. 72, Table 3.1, & p. 111
10 persons, 4 items, 2 occasions, changing to 2 items, 2 occasions, & 2 levels of facet3.
data list free / v1 to v8.
begin data.
2 6 7 5 2 5 5 5
4 5 6 7 6 7 5 7
5 5 4 6 5 4 5 5
5 9 8 6 5 7 7 6
4 3 5 6 4 5 6 4
4 4 4 7 6 4 7 8
2 6 6 5 2 7 7 5
3 4 4 5 6 6 6 4
0 5 4 5 5 5 5 3
6 8 7 6 6 8 8 6
end data.
descriptives var = all.
varstocases / make depend from v1 to v8 / index = occs(2) items(2) facet3(2) / id = person.
descriptives var = all.
VARCOMP depend BY person items occs facet3
/RANDOM = person items occs facet3
/METHOD = reml
/OUTFILE = VAREST ('varcomps.sav')
/DESIGN = person items occs facet3 person*items person*occs person*facet3 items*occs items*facet3 occs*facet3
/INTERCEPT = INCLUDE .
*********** The following program reads a variance components
*********** matrix and produces Generalizability Theory statistics.
*********** Follow the instructions until you get to "End of user specifications".
*********** The program uses the SPSS Matrix--End Matrix procedure.
*********** To run the program you must select all of the commands
*********** between, and including, "matrix" and "end matrix", then click on Run.
matrix.
* Enter a one-row data matrix of variance components;
There are two main ways to enter such data;
(1) Use the GET command to read saved output from
the SPSS VARCOMPS procedure; or
(2) Use a COMPUTE statement to enter the variance components data
into a curly brackets matrix, with a comma between each component;
The data matrix must be named "VCS" in both cases.
* to use the following GET command, remove the '*' in the first column;
make sure to enter the correct file name. You may also need to enter the
path to the file depending on its location and on your SPSS File Location settings.
*get vcs / file = 'varcomps.sav'.
* instead of using the GET command, you can enter the variance components directly,
into a curly brackets matrix with commas between the values, as in the following:
the variance components from Brennan, 2001, Data Set 3, p 72 & p 111.
compute vcs = {0.5528, 0.4417, 0.0074, 0.5750, 0.1009, 0.1565, 0.9352}.
* Is the GET command being used to read a file containing variance
components? Enter "1" for yes, or enter "0" for no.
compute getyesno = 0.
* Now look at the terms in the SPSS Variance Components results and then
create the "facets" curly brackets matrix below (see the "compute facets"
statement), as follows:
* separate the values within each row by a comma, and
place a semi-colon at the end of every row (except the last row)
* 1st row: the first row should contain the sequence of digits from 1 to
the total number of variance components; e.g., enter "1,2,3,4;" if there
are four variance components
* 2nd row: indicate whether persons were involved in the computations for
each variance component; Enter "1" if persons were involved, and
enter "0" if persons were not involved;
e.g., if there were 7 variance components for
p i o p*i p*o i*o p*i*o, then enter
1,0,0, 1, 1, 0, 1;
* 3rd row: indicate whether your Facet 1 was involved in the computations for
each variance component; Enter the number of levels of Facet 1 if
Facet 1 was involved, and enter "0" if Facet 1 was not involved in
the computations for each term;
e.g., if there were 7 variance components, and Facet 1 ("i") had 4 levels
p i o p*i p*o i*o p*i*o, then enter
0,4,0, 4, 0, 4, 4;
* 4rth row: indicate whether Facet 2 was involved in the computations for
each variance component; Enter the number of levels of Facet 2 if
Facet 2 was involved, and enter "0" if Facet 2 was not involved in
the computations for each term;
e.g., if there were 7 variance components, and Facet 2 ("o") had 2 levels
p i o p*i p*o i*o p*i*o, then enter
0,0,2, 0, 2, 2, 2;
You can ignore this step/row for single-facet designs
* If there are more than 2 facets in your design, then continue adding
rows following the above instructions.
* the right-most column for row 2 onwards is for the residual variance
component (the highest order interaction). It should not have "0" values.
* the model "facets" matrix below is for the variance components from the data
from Brennan, 2001, Data Set 3, p 72 & p 111. Re-design this matrix for
your own variance components data.
compute facets = {
1, 2, 3, 4, 5, 6, 7 ;
1, 0, 0, 1, 1, 0, 1 ;
0, 4, 0, 4, 0, 4, 4 ;
0, 0, 2, 0, 2, 2, 2 }.
* The remaining commands are for producing D study statistics and
graphs. Although your design may have more than 3 facets for the
above G-study analyses, the D study analyses provided by this program
are conducted only 3 facets (the D study output for more than 3 facets would
be overwhelming and difficult to interpret).
* Enter D-study values for Facet 1; enter the values inside curly
brackets, and place a comma between the values.
compute dfacet1 = {4, 8, 16}.
* Enter D-study values for Facet 2; enter the values inside curly
brackets, and place a comma between the values. You can ignore this
step for single-facet designs.
compute dfacet2 = { 2, 4}.
* Enter D-study values for Facet 3; enter the values inside curly
brackets, and place a comma between the values. You can ignore this
step for single-facet or two-facet designs.
compute dfacet3 = { 2, 4}.
* Enter labels for the codes (5 characters maximum), if desired, here.
compute labels={"Term 1","Term 2","Term 3","Term 4","Term 5","Term 6",
"Term 7","Term 8","Term 9","Term 10","Term 11","Term 12","Term 13",
"Term 14","Term 15","Term 16","Term 17","Term 18","Term 19","Term 20","Term 21"}.
* At the very bottom of this file, after the END MATRIX statement, is a
GRAPH command that can be used to plot the results for the D-study
values that you specified above. Specify the data that you would
like to plot by entering the appropriate number on the
COMPUTE GRAPHDAT statement:
enter "1" for relative error variances;
enter "2" for absolute error variances;
enter "3" for G-coefficients;
enter "4" for phi coefficients.
compute graphdat = 3.
* Instructions for the GRAPH command appear at the end of this file.
* End of user specifications.
***************************************************************************
print /space = 4 /title="G-Theory Analyses:".
do if (getyesno = 1).
compute vcs = vcs(1,3:ncol(vcs)).
print /space = 2 /title = "You have requested the program to read a saved variance components data file.".
end if.
do if ( ncol(vcs) ne ncol(facets) ).
print /space = 2 /title = "ERROR: The number of columns in your variance components matrix".
print /title = "this not the same as the number of columns in your facets matrix.".
end if.
* setting negative variance components to zero.
loop #lupe = 1 to ncol(vcs).
do if ( vcs(1,#lupe) < 0 ).
compute vcs(1,#lupe) = 0.
end if.
end loop.
compute labels2 = labels(1,1:ncol(vcs)).
compute facets = facets(2:nrow(facets),:).
compute nfacets = nrow(facets) - 1.
* absolute & relative error variances.
compute absv = 0.
compute relv = 0.
compute dummat = facets(2:nrow(facets),:).
* setting all 0 values to 1.
loop #luper = 1 to nrow(dummat).
loop #lupec = 1 to ncol(dummat).
do if (dummat(#luper,#lupec) = 0).
compute dummat(#luper,#lupec) = 1.
end if.
end loop.
end loop.
compute denom = dummat(1,:).
loop #lupec = 2 to ncol(vcs).
loop #luper = 1 to nrow(dummat).
do if (#luper < nrow(dummat)).
compute denom(1,#lupec) = denom(1,#lupec) * dummat(#luper+1,#lupec).
end if.
end loop.
compute absv = absv + ( vcs(1,#lupec) / denom(1,#lupec) ).
do if ( facets(1,#lupec) ne 0 ).
compute relv = relv + ( vcs(1,#lupec) / denom(1,#lupec) ).
end if.
end loop.
compute relG = vcs(1,1) / ( vcs(1,1) + relv ).
compute absG = vcs(1,1) / ( vcs(1,1) + absv ).
compute percents = vcs / rsum(vcs).
print /space = 2 /title="Entered Specifications, Variance Components and".
print /title="their Proportions of the Total Variance:".
do if (nfacets = 1).
compute clabs = { "Persons","Facet1","VarComp","Proport" }.
else if (nfacets = 2).
compute clabs = { "Persons","Facet1","Facet2","VarComp","Proport" }.
else if (nfacets = 3).
compute clabs = { "Persons","Facet1","Facet2","Facet3","VarComp","Proport" }.
end if.
print { t(facets), t(vcs) , t(percents) }
/format "f12.3"
/title=" "
/cnames= clabs
/rnames=labels2.
print { relv,absv } /format "f12.3"
/title = "Error Variances:" /clabels = "Relative","Absolute".
print { relG,absG } /format "f12.3"
/title = "G-coefficients:" /clabels = "G", "Phi".
* D study.
do if (nfacets le 3).
print /space = 3 /title = 'D-Study:' .
print dfacet1 /title = 'Entered D-Study values for Facet 1:'.
do if (nfacets=2 or nfacets=3).
print dfacet2 /title = 'Entered D-Study values for Facet 2:' .
end if.
do if (nfacets = 3).
print dfacet3 /title = 'Entered D-Study values for Facet 3:' .
end if.
compute persons = facets(1,:).
compute vfacet1 = facets(2,:).
do if (nfacets = 1).
compute dfacet2 = 1.
compute vfacet2 = make(1,ncol(vcs),1).
compute dfacet3 = 1.
compute vfacet3 = make(1,ncol(vcs),1).
end if.
do if (nfacets = 2).
compute vfacet2 = facets(3,:).
compute dfacet3 = 1.
compute vfacet3 = make(1,ncol(vcs),1).
end if.
do if (nfacets = 3).
compute vfacet2 = facets(3,:).
compute vfacet3 = facets(4,:).
end if.
loop #f3 = 1 to ncol(dfacet3).
compute dabsv = t(dfacet1).
compute drelv = dabsv.
compute drelG = dabsv.
compute dabsG = dabsv.
compute dabsv2 = { -9999, -9999, -9999 }.
compute drelv2 = dabsv2.
compute drelG2 = dabsv2.
compute dabsG2 = dabsv2.
loop #f2 = 1 to ncol(dfacet2).
compute resdum = make(ncol(dfacet1),4,-9999).
compute counter = 1.
loop #f1 = 1 to ncol(dfacet1).
compute absvdum = 0.
compute relvdum = 0.
loop #lupe = 2 to ncol(vcs).
compute f3dum = 1.
compute f2dum = 1.
compute f1dum = 1.
do if ( vfacet1(1,#lupe) > 1 ).
compute f1dum = dfacet1(1,#f1).
end if.
do if ( vfacet2(1,#lupe) > 1 ).
compute f2dum = dfacet2(1,#f2).
end if.
do if ( vfacet3(1,#lupe) > 1 ).
compute f3dum = dfacet3(1,#f3).
end if.
compute absvdum = absvdum + ( vcs(1,#lupe) / (f1dum * f2dum * f3dum ) ).
do if ( persons(1,#lupe) ne 0 ).
compute relvdum = relvdum + ( vcs(1,#lupe) / (f1dum * f2dum * f3dum ) ).
end if.
end loop.
compute gdum = vcs(1,1) / ( vcs(1,1) + relvdum ).
compute pdum = vcs(1,1) / ( vcs(1,1) + absvdum ).
compute resdum(counter,:) = { absvdum, relvdum, gdum, pdum }.
compute dabsv2 = { dabsv2; dfacet2(1,#f2), dfacet1(1,#f1), absvdum }.
compute drelv2 = { drelv2; dfacet2(1,#f2), dfacet1(1,#f1), relvdum }.
compute drelG2 = { drelG2; dfacet2(1,#f2), dfacet1(1,#f1), gdum }.
compute dabsG2 = { dabsG2; dfacet2(1,#f2), dfacet1(1,#f1), pdum }.
compute counter = counter + 1.
end loop.
compute dabsv = { dabsv , resdum(:,1) }.
compute drelv = { drelv , resdum(:,2) }.
compute drelG = { drelG , resdum(:,3) }.
compute dabsG = { dabsG , resdum(:,4) }.
end loop.
do if (nfacets = 3).
print dfacet3(1,#f3) / space = 4/ title = "D study results for when Facet 3 = ".
end if.
print /title=
"In the D-study results below, the levels of Facet 1 appear in"/space=2.
print /title=
"the first column, and the levels of Facet 2 appear in the first row.".
print {0,dfacet2;dabsv} /format "f8.3" /title="D-Study Absolute Error Variances".
print {0,dfacet2;drelv} /format "f8.3" /title="D-Study Relative Error Variances".
print {0,dfacet2;drelG} /format "f8.3" /title="D-Study G Coefficients".
print {0,dfacet2;dabsG} /format "f8.3" /title="D-Study Phi Coefficients".
compute dabsv2 = dabsv2(2:nrow(dabsv2),:).
compute drelv2 = drelv2(2:nrow(drelv2),:).
compute drelG2 = drelG2(2:nrow(drelG2),:).
compute dabsG2 = dabsG2(2:nrow(dabsG2),:).
end loop.
* saving data for plots.
do if (nfacets le 2).
do if ( graphdat = 1).
save dabsv2 /outfile=* / var = facet2 facet1 gstat.
end if.
do if ( graphdat = 2).
save drelv2 /outfile=* / var = facet2 facet1 gstat.
end if.
do if ( graphdat = 3).
save drelG2 /outfile=* / var = facet2 facet1 gstat.
end if.
do if ( graphdat = 4).
save dabsG2 /outfile=* / var = facet2 facet1 gstat.
end if.
end if.
end if.
end matrix.
GRAPH title=
'Gstat is the coefficient you specified on the COMPUTE GRAPHDAT= statement'
/LINE(MULTIPLE) = mean(gstat) by facet1 by facet2 .
* The PLOT command is not available in SPSS 12, but
it can be used for earlier versions.
* plot vsize=15 / hsize=50 / format=contour(3)
/ plot = gstat with facet1 by facet2.