Modifying an Existing Model

Posted on
Picture of user. rabil Joined: 01/14/2010
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?

Replied on Tue, 09/01/2015 - 16:41
Picture of user. tbates Joined: 07/31/2009

Best is to use omxSetparameters

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"