You are here

Modifying an Existing Model

2 posts / 0 new
Last post
rabil's picture
Joined: 01/14/2010 - 16:47
Modifying an Existing Model

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"

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?

tbates's picture
Joined: 07/31/2009 - 14:25
omxSetparameters; upgrade; @ (frowned upon, as it might break)

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"