My question probably reflects my inexperience scripting in R, but I thought I'd give it a shot here.

I am using OpenMx to test a two-wave multigroup model, with 17 groups. The same construct is measured with three indicators at each of the two waves, and I want to test a series of more restrictive measurement invariance assumptions (both across waves and across groups). I have a script to create an overall model with a submodel for each group. In this initial model, I created unique labels for loadings, variances, correlations, and means for each group, so that there are different estimates for each group. Now I want to be able to systematically change those labels to reflect the constraints that I want to make (e.g., Model 2 would equate the loadings for the indicators at Wave 1 to those at Wave 2; Model 3 would equate the loadings to be equal across groups). However, because there are so many groups, I would like to automate this with some sort of loop, rather than going in and changing each label for each submodel.

For instance, my A matrix is an 8 X 8 matrix, with the loadings for the Wave 1 indicators in rows 1, 2, and 3 of column 7 and the loadings for the Wave 2 indicators in rows 4, 5, and 6 in column 8. So to constrain the loadings at Wave 2 to be equal to those at Wave 1, I would need to have the same label in [1,7] as in [4,8], etc. I'm just not sure how to create a loop to do this for each of the submodels (or to do it some other way). Any suggestions for making this type of change to multiple submodels simultaneously?