File: xxm-faces.R

package info (click to toggle)
r-cran-openmx 2.21.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,412 kB
  • sloc: cpp: 36,577; ansic: 13,811; fortran: 2,001; sh: 1,440; python: 350; perl: 21; makefile: 5
file content (47 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# http://xxm.times.uh.edu/learn-xxm/bivariate-cross-classified-model/

library(OpenMx)

options(width=120)
got <- suppressWarnings(try(load("models/nightly/data/faces.xxm.RData")))
if (is(got, "try-error")) load("data/faces.xxm.RData")

#head(faces.response)
faces.response$rater <- as.integer(faces.response$rater)
faces.response$target <- as.integer(faces.response$target)

# way too slow with OpenMx
faces.response <- subset(faces.response, response < 500)

any(table(faces.response$rater, faces.response$target) > 1)  # Rampart can't help

raterModel <- mxModel(
  "raterModel", type="RAM",
  latentVars = c("SYM", "PA"),
  mxData(data.frame(rater=unique(faces.response$rater)), "raw",
         primaryKey="rater"),
  mxPath(c("SYM", "PA"), arrows=2, connect="unique.pairs", values=c(1,0,1)))

targetModel <- mxModel(
  "targetModel", type="RAM",
  latentVars = c("SYM", "PA"),
  mxData(data.frame(target=unique(faces.response$target)), "raw",
         primaryKey="target"),
  mxPath(c("SYM", "PA"), arrows=2, connect="unique.pairs", values=c(1,0,1)))

faces <- mxModel(
  "faces", type="RAM", raterModel, targetModel,
  manifestVars=c("SYM", "PA"),
  mxData(faces.response, "raw"),
  mxPath("one", c("SYM", "PA")),
  mxPath(c("SYM", "PA"), arrows=2, connect="unique.pairs", values=c(1,0,1)),
  mxPath(paste0('raterModel.', c("SYM", "PA")), c("SYM", "PA"),
         free=FALSE, values=1, joinKey="rater"),
  mxPath(paste0('targetModel.', c("SYM", "PA")), c("SYM", "PA"),
         free=FALSE, values=1, joinKey="target"))

#faces <- mxRun(mxModel(faces, mxComputeOnce('fitfunction', 'fit')))

faces <- mxRun(faces)

summary(faces)