Modifying an Existing Model
Posted on

Forums
I created a model (using a function) saved as "x". I would like to change a label in the A matrix. Here are the labels for the A matrix:
> x$matrices$A$labels
v_1 v_2 v_3 mu
v_1 NA NA NA "b_1"
v_2 NA NA NA "b_2"
v_3 NA NA NA "b_3"
mu NA NA NA NA
I would like to change "b_3" to "b_2":
> x$matrices$A$labels[3,4] <- "b_2"
Error: Right-hand side of assignment operator has illegal value FullMatrix, SymmMatrix, FullMatrix, and FullMatrix
Why does this not work?
omxSetparameters; upgrade; @ (frowned upon, as it might break)
omxSetParameters(m1, labels = "b_3", newlabels = "b_2")
To answer your question directly, I think this was not working with an early implementation of $ accessor. It is working now
labs <- c(
"v_1", "v_2", "v_3", "mu",
"v_1", NA, NA, "b_1",
"v_2", NA, NA, "b_2",
"v_3", NA, NA, "b_3",
"mu" , NA, NA, "NA")
x = mxMatrix("Full",4, 4, labels = labs, byrow=T)
# change "b_3" to "b_2":
x$labels[3,4] <- "b_2"
(if ever one encounters something like this, a work around is to use the @ accessor which skips validation)
x@labels[3,4] <- "b_2"
Log in or register to post comments