File: challengingCI.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 (28 lines) | stat: -rw-r--r-- 1,051 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
library(OpenMx)

if (0) {
  # move parameters to MLE
  load("memprobmodel2.RData")
  memprobmodel2 <- mxRun(memprobmodel2, intervals=FALSE)
  save(memprobmodel2, file="memprobmodel2.RData")
}
# load("~/bin/OpenMx/inst/models/failing/memprobmodel2.RData")
got <- try(load("models/failing/memprobmodel2.RData"))
if (is(got, "try-error")) {
  load("memprobmodel2.RData")
}

fit <- mxRun(mxModel(memprobmodel2, mxComputeOnce('fitfunction','fit')))
target <- fit$output$fit + 3.841459

ciModel <- mxModel("ciModel", memprobmodel2,
                   mxAlgebra((target - ctsem.objective)^2 - ctsem.DRIFT[2,1], name="ci"),
                   mxFitFunctionAlgebra("ci"),
                   mxComputeGradientDescent(engine="CSOLNP"))
print(ciModel$ctsem$DRIFT$result[2,1])
ciModel <- mxRun(ciModel)
csolnpBound <- ciModel$ctsem$DRIFT$result[2,1]
print(csolnpBound)
ciModel <- mxRun(mxModel(ciModel, mxComputeGradientDescent(engine="NPSOL")))
omxCheckCloseEnough(ciModel$ctsem$DRIFT$result[2,1], .3880241, .001)
omxCheckCloseEnough(csolnpBound, .3880241, .001)