Models for Square Data Stat 557 Heike Hofmann

advertisement
Models for Square Data
Stat 557
Heike Hofmann
Outline
• Movies
• Political Views
• Relationships
Movie Reviews
•
•
•
Siskel/Ebert movie reviews
Use expand.grid to get the data into R quickly
Use a mosaicplot to plot the raw data
Ebert
Siskel
Con
Mixed
Pro
Con
24
8
10
Mixed
8
13
9
Pro
13
11
64
Movie Reviews
•
Discuss whether an assumption of marginal
homogeneity holds. - draw two barcharts for a start.
•
get the data into a shape that you can fit the
following two POLR models:
count variable value
1
24
ebert
con
2
8
ebert mixed
3
13
ebert
pro
4
8
ebert
con
5
13
ebert mixed
...
library(MASS)
mov.null <- polr(value~1, weight=count, data=reviews.melt)
mov.main <- polr(value~1+variable, weight=count, data=reviews.melt)
anova(mov.null, mov.main)
•
Why does this test marginal homogeneity, and what
is the conclusion?
Movie Reviews
•
•
We’ve discussed symmetry and quasi-symmetry.
•
Using a log-linear framework fit models of symmetry
and quasi-symmetry. Interpret results
•
If possible, compare models.
Introduce a factor variable symm that makes each
pair of cells (i,j) and (j,i) into one level
Movie Reviews
•
Besides independence, there is quasi-independence
(next slide)
•
Using a log-linear framework fit models of
independence and quasi-independence. Interpret
results
•
What is the structure between symmetry, quasisymmetry, independence and quasi-independence (if at
all)?
Quasi Independence
Quasi-Independence Model
Quasi-Independence Model
Quasi-Independence
Model
si-Independence Model
• Independence in matched pair data is usually
violated because
heavy
diagonal usually violated (beca
In matchedof
pair
data independence
•
heavily loaded)
tched pair data independence
usually violated (because diagonal
Quasi-Independence:
Quasi-independence model: fit independence for off-diago
y loaded)
cells on the main
separately:
givenmodel:
off-diagonality,
dodiagonal
we for
have
independence?
-independence
fit independence
off-diagonal
cells and fit
Y2
1
on the mainModel
diagonal
separately:
log µab = λ + λY
+
λ
Form
a
b + δa I (a = b) ,
•
1
λY
a
2
λY
b
�
��
independence
log µab = λ +
+
+ δa I (a = b) ,
�� with
�
� I is��
� �function,
where
an indicator
main diagonal
independence
I is an indicator function, with with
�
�
1
I (a = b) =
0
�
�
��
�
main diagonal
if a = b,
otherwise.
Political Views
• Download data polviews06.csv from our
website
• Discuss marginal homogeneity.
• How do political views and party affiliation
align? Draw a fluctuation diagram
Political Views
• Fit models of (quasi-)independence &
(quasi) symmetry and interpret results.
• Compare corresponding models.
• Does number of respondents have an
impact on model fit?
Pre- vs Extramarital
Relationships
• Download data set gss-ex-pre.txt from the
website
• GSS data: attitude towards pre/ex-marital
sexual relationships
• For one of the years, fit logistic regression
and check for marginal homogeneity
• Does attitude change over the years?
Download