File: startingValues.R

package info (click to toggle)
r-cran-openmx 2.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,908 kB
  • sloc: cpp: 35,071; ansic: 13,690; fortran: 2,001; sh: 1,362; python: 350; perl: 21; makefile: 5
file content (60 lines) | stat: -rw-r--r-- 2,556 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
57
58
59
60
#
#   Copyright 2007-2018 by the individuals mentioned in the source code history
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
# 
#        http://www.apache.org/licenses/LICENSE-2.0
# 
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.


library(OpenMx)

covMatrix <- matrix( c(0.77642931, 0.39590663, 0.39590663, 0.49115615), 
	nrow = 2, ncol = 2, byrow = TRUE, dimnames = list(c('a','b'), c('a','b')))

model <- mxModel("missingtest",
	   mxMatrix("Full", values = c(0,0.2,0,0), name="A", nrow=2, ncol=2),
	   mxMatrix("Symm", values = c(0.8,0,0,0.8), name="S", nrow=2, ncol=2, free=TRUE),
	   mxMatrix("Iden", name="F", nrow=2, ncol=2, dimnames = list(c('a','b'), c('a','b'))),
	   mxData(covMatrix, 'cov', numObs = 100),
	   mxExpectationRAM("A", "S", "F"),
	   mxFitFunctionML())

model[["A"]]$free[2,1] <- TRUE
model[["A"]]$values[2,1] <- NA   # oops

omxCheckError(mxRun(model, silent=TRUE),
	      "Parameter 'missingtest.A[2,1]' has no starting value")

model$A$free[,] <- FALSE
model$S$free[,] <- FALSE
model <- omxAssignFirstParameters(model)  # should do nothing with no free parameters


test<-matrix(rnorm(100,0,1),ncol=2)
colnames(test)<-c('v1','v2')
testm<-mxModel(
  type='RAM',
  mxData(test,type='raw'),
  mxMatrix(name='A',ncol=2,nrow=2),
  mxMatrix(name='S',ncol=2,nrow=2,labels=c('freematrix1[1,1]',NA,NA,'freematrix2[1,1]')),
  mxMatrix(name='freematrix1',values=3,free=T,nrow=1,ncol=1,labels='freeparam1'),
  mxMatrix(name='freematrix2',values=2,free=T,nrow=1,ncol=1,labels='freeparam1'),
  mxMatrix(name='M',ncol=2,nrow=1),
  mxMatrix(name='F',type='Diag',,values=1,ncol=2,nrow=2,dimnames=list(c('v1','v2'),c('v1','v2'))),
  mxExpectationRAM(M='M',dimnames=c('v1','v2')),
  mxFitFunctionML()
)
omxCheckEquals(length(omxGetParameters(testm)), 1L)

vn <- omxCheckWarning(mxModel("varName", type="RAM",
                              manifestVars=':-<', latentVars = ":-)"),
                      c("The name ':-)' is illegal because it contains the characters '-' and ':' in FUN(X[[i]], ...)",
                        "The name ':-<' is illegal because it contains the characters '-', ':', and '<' in FUN(X[[i]], ...)"))