Currently users can't remove CIs from models, only add them. Given they can take hours to compute, this can be a hassle.
One way would be to make things like this work:
model$intervals = NULL model$intervals = model$intervals[-3]
An aid to learning would be to add a note to the help about remove = TRUE parameter to mxModel(), which would remove a CI of that name from the model.
newModel = mxModel(oldModel, mxCI("a_r1_c1"), remove = TRUE)
Comments
#1
I guess it might just be more intuitive in the model editing phase to support the equivalent using $
so
executes
nice to warn when the "removed" item never existed
#2
In term of implementation, I think "model$intervals = NULL" is the easiest. I have a patch for that. However, it's somewhat of a hack because "model$intervals = model$intervals[-3]" doesn't work. Only NULL works. If everybody is okay with that, I'll commit it.
#3
Users can remove CIs ... just not the way the op wants
So, are you saying you want the $ accessor to also work for setting and removing CIs?
Also as a note, selection with a negative character has never worked for anything to my knowledge in R.
#4
Yeah, having $ set and get work for CIs would be great, IMHO.
#5
Two issues
1. remove=TRUE doesn't warn the user when the CI doesn't exist (which is misleading),
2. remove = TRUE only works on items specified the same way.
We don't do any redundancy checking, or unpacking CIs into single parameter requests (the way, say that mxPath() effectively does). So
We can add the same cell three times, with all being computed (yielding an interesting message in summary)
Row names not always lost
#6
I think implementing allowing $intervals = NULL would be a good way forward here. Most cases where the user wants to remove a CI, they can then get what they want either with mxModel and remove = T, or just NULLing out intervals and starting over.
PS: the current error doesn't reflect what the user asked to do: mxModel(model, intervals) won't work, and this would apply to many things accessed via $, like matrices, algebras, constraints, etc.
f2r$intervals = NULL
Error: I'm very sorry, but direct modification of objects inside an mxModel is not supported. The recommended approach to modifying an mxMatrix, mxAlgebra or other object within a model is to rebuild the mxModel. So, for example, 'model <- mxModel(model, Something)' can be used to replace Something inside the model, instead of 'model$Something <- Something' which does not work
#7
I agree this is annoying, but I did add some examples of removal to the mxCI man page. Here is an easy-ish way to remove all intervals:
model <- mxModel(model, remove=TRUE, model$intervals)
#8
Although we don't support users using the
@
accessor, the following would also work:#9
Could close this with
model@intervals <- list()
as the work-around.#10
good work arounds available, and documented