You are here

omxSetParameters - warn when attempting to set non-existent parameter

Currently if the user calls omxSetParameters on a non existent label, they get no warning.
For instance

 omxSetParameters (cholFit2, labels=c("im not there"), free = F, value = 0);

It would be nice if that caused an error, as it usually means the user has made a typo (bad because they now think they have freed or reduced their model but have not) or misunderstands what their model contains (worse, I guess :-) ).

This can be done by adding the following code to the function

if(!all(labels %in%  names(omxGetParameters(model, indep)))){
     stop("all elements of 'labels' must be present in model")
}

If people think the current behavior is OK, perhaps add a new parameter "strict=F" or similar, to request an error when a label is found non existent.

Reporter: 
Created: 
Tue, 09/14/2010 - 08:13
Updated: 
Fri, 10/22/2010 - 15:56

Comments

edit: this (below) is a feature creep request... so ignore it: The work around reads well enough
mxRename(omxSetParameters(fit1, labels=c("quad11"), free=F, value = 0), "newName")

(Very) often when one sets parameters, it is appropriate to give the new model which is returned its own new name.

Currently this looks like

  model2 = omxSetParameters(fit1, labels=c("quad11"), free=F, value = 0);
  model2 = mxRename(model2, "G by E no quad")
  # or less safely
  model2$name="G by E no quad"

It would be nice to add a parameter to omxSetParameters() so this is a 1 liner.

  model2 = omxSetParameters(fit1, labels=c("quad11"), free=F, value = 0, newName="G by E no quad")

added as newName=NA, nothing existing will break

Oops. I forgot to add this error checking before the 0.9.2 release. We're making a concerted effort to have no more code changes before the 1.0 release on Thursday. I promise I'll add this in for Openmx 1.0.1.

Fixed in version 1.0.1.

Automatically closed -- issue fixed for 2 weeks with no activity.