Apologies for an elementary question by a R novice:

I'd like to use mxBounds to set the lower bound of just the diagonal of a lower matrix, a, to zero.

Is there a way to do this which would work regardless of the dimensionality of a?

I tried

mxBounds(c('diag(a)'),0)

This did not give an error message, but it did not work either!

mxBounds takes a vector of parameter names. Try using something like

to get the parameters on the diagonal. Your code above was looking for a parameter named

`'diag(a)'`

because you put the`diag()`

function in quotes, which is a valid command, but constraining that non-existent parameter didn't affect your model.Ryne's answer is correct. I've opened a bug report so that an error will be thrown next time: http://openmx.psyc.virginia.edu/issue/2010/03/throw-error-when-assigning-bounds-non-existent-parameters.

Thanks for the reply.

I'm afraid I am still stuck.

There was an spare bracket that I removed to give:

mxBounds(diag(a@labels),0),

but I got error message:

Error in diag(a@labels) :

trying to get slot "labels" from an object of a basic class ("numeric") with no slots

I tried substituting 'values' for labels, but that was no good.

I then tried to be clever and give labels to my matrix in the mxMatrix definition. However, unfortunately, that did not work either. But problem was compounded because my attempt to provide labels seemed to founder as well, because when I inspect matrix a, I continue to get:

LowerMatrix 'a'

@labels: No labels assigned.

Here's what I tried in my attempt to provide labels:

mylabels=paste("a",(1:sum(1:nv)),sep="")

(defined before the model definition began)

and then

mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=pathstartvalue, name="a",labels=mylabels ),

Given the error message about lack of slots, I have a nasty feeling that even if I make those pesky labels work, this might not solve my problem, but any advice you can give would be gratefully received.

PS despite my difficulties, I am growing to like OpenMx.

Certainly a huge improvement on Mx in terms of ease of use! Keep up the good work.

Sorry about the extra bracket.

For

`mxBounds`

to work, the parameters you are constraining to need to have labels. The code I gave assumed that`a`

was an R object that contained an`MxMatrix`

object; R's`diag`

function won't recognize OpenMx names. Your error regarding slots means you were trying to extract labels from an R matrix. If you put up the whole code you're trying to run, I could take a look at it.An easier way is to use the

`lbound`

argument in the`mxMatrix`

function. You may specify this argument the same way you would for the`values`

argument. Just put`NA`

wherever you don't want a bound.Either of the following will work:

OR

The second form will work under the assumptions that the R variable with your model is named 'model', and you've inserted the 'a' matrix into the model in a previous mxModel() statement. If you use the second form, you can't combine the matrix insertion and the bounds insertion into the same expression. That's because the 'model' object on the right-hand side of the '<-' operator contains the state of the model PRIOR to the insertion.

The style guide has a helpful section on accessing model components.