# Submodel testing: Dropping single parameters in a matrix

11 posts / 0 new
Offline
Joined: 11/30/2009 - 06:35
Submodel testing: Dropping single parameters in a matrix

Hi,
I am testing submodels under a multivariate (3 variables) common pathways ADE model. I want to run a submodel where I drop the specific d for the first of the three variables, but I keep getting error messages. I hope someone could help me out with this.

I have tried various versions of the procedure below:

mxModel(ADE_Common_Fit$ADE, mxMatrix( type="Diag", nrow=nvar, ncol=nvar, free[1,1]=FALSE, values[1,1]=0, name="ds" ) ) ) multiComPathAEad1eFit <- mxRun(multiComPathAEad1eModel) The error messages I keep getting are: Error: unexpected '=' in: " mxModel(ADE_Common_Fit$ADE,
mxMatrix( type="Diag", nrow=nvar, ncol=nvar, free[1,1]="
> )
Error: unexpected ')' in " )"
> )
Error: unexpected ')' in ")"

Offline
Joined: 07/31/2009 - 15:24
When invoking a function, the

When invoking a function, the syntax foo(a = 1, b = 2, c = 3) assigns the values 1, 2, and 3 to the variables a, b, and c. Since the function invocation binds a value to a variable, the square brackets cannot be used on the left-hand side of the binding.

One method to drop a free parameter would be to do the following:

multiComPathAEad1eModel <- mxRename(ADE_Common_Fit, &nbsp;&nbsp;&nbsp;&nbsp;"multiComPathAEad1e")
multiComPathAEad1eModel$ADE.ds@free[1,1] <- FALSE multiComPathAEad1eModel$ADE.ds@values[1,1] <- 0
Offline
Joined: 11/30/2009 - 06:35
Thank you, that way it

Thank you, that way it works.

One follow-up question:
I seem to be having trouble getting confidence intervals on the parameters within the new model. using the following syntax:

multiComPathAEad1eModel$ADE.ds@free[1,1] <- FALSE multiComPathAEad1eModel$ADE.ds@values[1,1] <- 0

mxCI(c('multiComPathAEad1eModel$ADE.al', 'multiComPathAEad1eModel$ADE.dl','multiComPathAEad1eModel$ADE.el', 'multiComPathAEad1eModel$ADE.f','multiComPathAEad1eModel$ADE.as', 'multiComPathAEad1eModel$ADE.ds','multiComPathAEad1eModel$ADE.es')) multiComPathADEad1eFit <- mxRun(multiComPathAEad1eModel,intervals=T) This is the only output I get : MxInterval @reference: multiComPathAEad1eModel$ADE.al multiComPathAEad1eModel$ADE.dl multiComPathAEad1eModel$ADE.el multiComPathAEad1eModel$ADE.f multiComPathAEad1eModel$ADE.as multiComPathAEad1eModel$ADE.ds multiComPathAEad1eModel$ADE.es
@lowerdelta: 3.841459
@upperdelta: 3.841459

This syntax produces the same result:

Any idea what's wrong?

Offline
Joined: 07/31/2009 - 15:24
Only one argument per

Only one argument per confidence interval for now. So you need to do:

intervals <- lapply(c('ADE.al', 'ADE.dl','ADE.el', 'ADE.f','ADE.as', 'ADE.ds','ADE.es'), mxCI)

Offline
Joined: 07/31/2009 - 14:25
won't this work? model =

won't this work?

fit = mxRun(model, intervals=T)
summary(fit)

Offline
Joined: 07/31/2009 - 15:24
Oops. Yes, Tim Bates

Oops. Yes, Tim Bates suggestion is simpler and it will work.

Offline
Joined: 11/30/2009 - 06:35
Thanks to both - that solved

Thanks to both - that solved the problems with the confidence intervals!

Offline
Joined: 11/30/2009 - 06:35
I have tried the same syntax

I have tried the same syntax in order to drop the common D:

multiComPathAEad2eModel$ADE.d1@free <- FALSE multiComPathAEad2eModel$ADE.d1@values <- 0

but I get a new error message:

> multiComPathAEad2eModel$ADE.d1@free <- FALSE Error in checkSlotAssignment(object, name, value) : "free" is not a slot in class "NULL" > multiComPathAEad2eModel$ADE.d1@values <- 0
Error in checkSlotAssignment(object, name, value) :
"values" is not a slot in class "NULL"

Writing free[1,1]
and values [1,1] does not help.

Why is this different, and what can I do if I want to drop one common factor and one of the parameters in the specific factors within the same sub model?

Offline
Joined: 07/31/2009 - 14:25
whenever an assignment like

whenever an assignment like that doesn't work, the thing to do is to try and access (rather than set) the path of interest, to make sure that you are addressing it correctly. Then if that is broken, go back up the chain of names to see where things are going wrong.

So if I saw
> multiComPathAEad2eModel$ADE.d1 return the error "free" is not a slot in class "NULL" Then I think "so, d1 is coming back NULL - it doesn't exist." You can see this by saying:  multiComPathAEad2eModel$ADE.d1


Then I would try

   multiComPathAEad2eModel\$ADE


and see what is in there. My guess is the object you want is not called 'd1' but something else?

Finally, I bet you'd have a lot more luck doing this directly by building new matrices that do what you want and replacing the existing ones. So

newModel = mxModel(oldModel,name="new name",
mxMatrix( type="Diag", nrow=nvar, ncol=nvar, free=F, values=0, name="d1" )
)

that will give new a new model, with the d1 matrix fixed to 0 in place of whatever used to be there

best, tim

Offline
Joined: 07/30/2009 - 14:03