File: check_RAM_paths_dont_overwrite.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 (38 lines) | stat: -rw-r--r-- 1,561 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
## This behavior is purposeful.  We made a design decision to not allow mxPath 
## to create simultaneous single headed and double headed arrows in the same 
## position in the A and S matrices.  The rare (really, are there any?) cases 
## when this makes sense are far outweighed by the times when people are either 
## (a) making a mistake or (b) trying to convert a single headed into a double 
## headed arrow or vice versa.  Of course, this behavior can be overridden by 
## directly manipulating an mxMatrix.  We did (and I do still) consider mxPath() 
## to be the training wheels for OpenMx.  The idea being we would like to make 
## it difficult to make mistakes.  I believe this philosophy is still correct.
##
## https://lists.virginia.edu/sympa/arc/openmx-developers/2016-03/msg00085.html

# "~/bin/OpenMx/inst/models/failing/check_RAM_paths_dont_overwrite.R"

# When adding paths in mxModel, I think everything the user requests should be added
# in line with what you say is what you get?

m1 <- mxModel("x_to_y_is_OK", type="RAM",
	manifestVars = c("X", "Y"),
	# both these paths should be added:
	mxPath("X", to = "Y", arrows = 1)
)
# X->Y is fine
omxCheckEquals(m1$A$free["Y","X"], TRUE)

m1 <- mxModel("x_with_y_overwrites_x_to_y", type="RAM",
	manifestVars = c("X","Y"),
	# both these paths should be added:
	mxPath("X", to = "Y", arrows = 1), 
	mxPath("X", to = "Y", arrows = 2)
)
# Oops: the 2-headed path overwrote the 1-headed path
omxCheckEquals(m1$A$free["Y","X"], TRUE)

# Last-path-in is OK
omxCheckEquals(m1$S$free["Y","X"], TRUE)