Move failing test to failing dir
[openmx:openmx.git] / models / failing / DefinitionIloo.R
1 # http://openmx.psyc.virginia.edu/thread/2363
2
3 set.seed(1)
4
5 library(OpenMx)
6 N <- 2000
7 u <- rbinom(N,1,.5)
8 x <- .5*u+rnorm(N)
9 y <- mxFactor( rbinom(N,1,pnorm(-2+u)) , levels=c(0,1) )
10  
11 model <- mxModel( 'BinCont',      
12   mxMatrix('Full',nrow=1,ncol=2,free=c(T,T),name='Betas'),
13   mxMatrix('Full',nrow=1,ncol=1,free=F,label='data.u',name='U'),
14   mxMatrix('Full',nrow=1,ncol=2,free=c(T,F),name='Means'),
15   mxAlgebra( Means + Betas%x%U , name='eMean'),
16   mxMatrix('Full',nrow=1,ncol=1,free=T,name='Thresh'),
17   mxMatrix('Symm',nrow=2,ncol=2,free=c(T,T,F),values=c(1,0,1),name='Cov'),
18   mxData( data.frame(x,y,u) , type='raw'),
19   mxFIMLObjective( means='eMean', covariance='Cov',thresholds='Thresh',threshnames='y',dimnames=c('x','y') )
20 )                                        
21
22 for (rep in 1:2) {
23   if (rep == 2) model <- mxOption(model, "Number of Threads", 1)
24
25   fit <- mxRun( model )
26   omxCheckCloseEnough(fit@output$Minus2LogLikelihood, 6578.69, .1)
27
28   est <- fit@output$estimate
29   #print(est)
30   omxCheckCloseEnough(est[1], 0.9998, .001)
31   omxCheckCloseEnough(est[2], 0.7177, .001)
32   omxCheckCloseEnough(est[3], -0.13521308, .001)
33   omxCheckCloseEnough(est[4], 1.68312081, .001)
34   omxCheckCloseEnough(est[5], 0.88751570, .001)
35   omxCheckCloseEnough(est[6], -0.08009792, .001)
36 }