author: Michael A. Erickson date: 8 March 2014 autosize: true
## Loading required package: lattice
## Loading required package: MASS
## Loading required namespace: car
##
## Attaching package: 'memisc'
##
## The following objects are masked from 'package:stats':
##
## contr.sum, contr.treatment, contrasts
##
## The following object is masked from 'package:base':
##
## as.array
## read.spss() is from the foreign library -- note the errors rto.raw <-
## read.spss('../TRAUMA_FEB_25_2014_final merge_Edman_WATSON.sav', to.data.frame=TRUE,
## use.value.labels=TRUE) rm(rto.raw)
## spss.system.file() is from the memisc library
hate <- spss.system.file("Hate_Study 2.sav")
hate.ds <- as.data.set(hate)
hate.df <- as.data.frame(hate.ds)
## description(rto.ds) # does not work with knitr because of unicode values
I don't feel like I'm looking at the right thing, but the p-value does not rely on the theoretical \( \chi^2 \) distribution.
hg <- droplevels(subset(hate.df, select = grep("Gender|Haterelati", names(hate.df), value = TRUE)))
(hgt <- with(hg, table(Haterelati1, GenderPers)))
## GenderPers
## Haterelati1 Male Female
## Family 1 10
## Friend 8 15
## Ex 2 8
## Coworker/Student 12 31
## Step Family Member 0 3
## Authority Figure 1 4
## Acquaintance 0 4
## NoHate 3 3
## Other 0 1
round(prop.table(hgt, 2), 3)
## GenderPers
## Haterelati1 Male Female
## Family 0.037 0.127
## Friend 0.296 0.190
## Ex 0.074 0.101
## Coworker/Student 0.444 0.392
## Step Family Member 0.000 0.038
## Authority Figure 0.037 0.051
## Acquaintance 0.000 0.051
## NoHate 0.111 0.038
## Other 0.000 0.013
chisq.test(hgt, simulate.p.value = TRUE)
##
## Pearson's Chi-squared test with simulated p-value (based on 2000 replicates)
##
## data: hgt
## X-squared = 7.612, df = NA, p-value = 0.4858