The raw data consist of the binary judgments of 101 first-year psychology students who indicated whether or not they would display each of 8 anger-related behaviors when being angry at someone in each of 6 situations.
Each situation is presented as one level of a factor, without specifying a level for the other factor.
library(plfm)
## Loading required package: sfsmisc
## Loading required package: abind
data(anger)
D = anger$data
Plot a graph based on the Ising model pour the subset of the data of situation “like”.
library(IsingFit)
r.nb = 1 # "like"
D.subset = matrix(0,nrow(D),ncol(D[1,,]))
for (ii in 1:nrow(D)){
D.subset[ii,] = c(D[ii,r.nb,])
}
D.subset = data.frame(D.subset)
colnames(D.subset) <- colnames(D[1,,])
mod.ising = IsingFit(D.subset,gamma=.25)
##
|
| | 0%
|
|======== | 12%
|
|================ | 25%
|
|======================== | 38%
|
|================================ | 50%
|
|========================================= | 62%
|
|================================================= | 75%
|
|========================================================= | 88%
|
|=================================================================| 100%
title("Like")
Question: What are the conditionnal independence describd by this graph?
This result can be compared to some plots from the MCA (multivariate correspondance analysis)
library(FactoMineR)
mca = MCA(apply(D.subset,2,as.factor),graph=FALSE)
plot(mca,choix="var")
Question: What are the information on the MCA plot? Can retrieve some informations which help to understand the graph plot?
Plot a graph based on the Ising model pour the subset of the data of situation “like”.
c.nb = c(5,6) #
D.subset = matrix(0,nrow(D),6)
for (ii in 1:nrow(D)){
D.subset[ii,] = c(D[ii,1:3,c.nb])
}
D.subset = data.frame(D.subset)
colnames(D.subset)[1:3] <- paste("Hart","/",rownames(D[1,1:3,]),sep="")
colnames(D.subset)[4:6] <- paste("Story","/",rownames(D[1,1:3,]),sep="")
mod.ising = IsingFit(D.subset,gamma=.01)
##
|
| | 0%
|
|=========== | 17%
|
|====================== | 33%
|
|================================ | 50%
|
|=========================================== | 67%
|
|====================================================== | 83%
|
|=================================================================| 100%
title("Hart+Story")