1 Data Management

  1. Load data
dtaHW3 <- read.table("C:/Users/ASUS/Desktop/data/geometryAL.txt", h=T)
  1. Define data level
dtaHW3$gender <- factor(ifelse(dtaHW3$gender==1,"Female","Male"))
dtaHW3$board <- factor(dtaHW3$board)
dtaHW3$iid <- factor(dtaHW3$iid)
dtaHW3$itype <- factor(dtaHW3$itype)


head(dtaHW3)
##   score board gender age mgcse itype  iid
## 1     8     3 Female   1 0.856     7 1001
## 2     8     3 Female  -6 0.856     7 1001
## 3     8     3 Female   5 0.856     7 1001
## 4    10     3 Female  -1 0.856     7 1001
## 5     8     3 Female  -5 0.856     7 1001
## 6    10     3 Female   3 0.856     7 1001

2 Histogram & Stats plots

library(ggplot2)

2.1 socre * institution type

#
ggplot(data=dtaHW3, aes(x=score)) +
 geom_histogram(binwidth=1) +
 aes(y = ..density..) +
 facet_grid(. ~ itype) +
 labs(x="Geometry score", y="Density") +
 ggtitle("Institution type")

2.2 score* institution type* exam board

#
ggplot(data=dtaHW3, aes(x=score)) +
 geom_histogram(binwidth=1) +
 aes(y = ..density..) +
 facet_grid(itype ~ board) +
 labs(x="Geometry score", y="Density")+
 ggtitle("Institution Type by Examination Board")

2.3 score * gender

ggplot(dtaHW3, aes(x=score, fill=gender)) +
 geom_bar(binwidth=1, position="dodge") + 
 labs(x="Geometry score", y="Count")
## Warning: Ignoring unknown parameters: binwidth

2.4 Gender& institution type differences

Stats plot describes GCSE ~ Geometry score,
grouped by 2 variables gender & institution type Looks like gender difference exists in
institution 6:boys has averaged poorer GCSE than girls. institution 5: girls has averaged better GCSE than boys.

#
ggplot(dtaHW3, aes(x=mgcse, y=score)) +
 geom_point(alpha=I(0.3), cex=0.1) +
 stat_smooth(method="lm") +
 facet_grid(itype ~ gender) +
 labs(y="Geometry score", x="GCSE score")
## `geom_smooth()` using formula 'y ~ x'

3 Clmm

Dependent variable is nominal/ordinal

這次作業跑GLMM系列的分析R軟體常算不出來,會再研究看看是版本還是其他問題?

The End