* SOC593 [02/02/2001]
* STATA EXAMPLE OF GRAPHING INTERACTION EFFECTS BETWEEN TWO CATEGORICAL VARIABLES
. des
Contains data from stats.dta
obs: 43 Statistics students survey
vars: 6 19 Apr 1997 10:38
size: 559 (99.5% of memory free)
-------------------------------------------------------------------------------
1. gender byte %8.0g genlbl Gender
2. age byte %8.0g Age
3. party byte %8.0g partylbl Political party preference
4. grade byte %8.0g gradelbl Expected grade in statistics
5. msat float %9.0g Mathematics SAT score
6. quiz byte %8.0g # concepts named from reading
-------------------------------------------------------------------------------
Sorted by: party
. codebook gender party grade
gender ----------------------------------------------------------------- Gender
type: numeric (byte)
label: genlbl
range: [0,1] units: 1
unique values: 2 coded missing: 0 / 43
tabulation: Freq. Numeric Label
12 0 male
31 1 female
party ---------------------------------------------- Political party preference
type: numeric (byte)
label: partylbl
range: [1,3] units: 1
unique values: 3 coded missing: 3 / 43
tabulation: Freq. Numeric Label
17 1 Democrat
7 2 Republic
16 3 Independ
grade -------------------------------------------- Expected grade in statistics
type: numeric (byte)
label: gradelbl
range: [2,4] units: 1
unique values: 3 coded missing: 0 / 43
tabulation: Freq. Numeric Label
6 2 C
28 3 B
9 4 A
. * COLLAPSE DATA AND GET MEAN MSAT SCORES FOR EACH GENDER-GRADE GROUP
. sort gender grade
. collapse (mean) msat, by (gender grade)
. des
Contains data
obs: 6 Statistics students survey
vars: 3
size: 60 (99.5% of memory free)
-------------------------------------------------------------------------------
1. gender byte %8.0g genlbl Gender
2. grade byte %8.0g gradelbl Expected grade in statistics
3. msat float %9.0g (mean) msat
-------------------------------------------------------------------------------
Sorted by: gender grade
Note: dataset has changed since last saved
. list
gender grade msat
1. male C 456.6667
2. male B 596.6667
3. male A 503.3333
4. female C 493.3333
5. female B 496.875
6. female A 590
. * RESHAPE DATA SO THAT UNIT OF ANALYSIS IS GRADE, AND MSAT SCORES ARE TRANSFO
> RMED INTO TWO VARIABLES: ONE FOR MALE AND ONE FOR FEMALE.
. reshape groups gender 0-1
. reshape vars msat
. reshape cons grade
. reshape wide
. list
grade msat0 msat1
1. C 456.6667 493.3333
2. B 596.6667 496.875
3. A 503.3333 590
. * HURRAY!!
. * RENAME NEW MSAT VARIABLES
. rename msat0 mmsat
. label variable mmsat "male mean msat"
. rename msat1 fmsat
. label variable fmsat "female mean msat"
. * GRAPH IT!
. graph mmsat fmsat grade, connect (ll) xlabel ylabel