mxPath {OpenMx} | R Documentation |

This function creates a list of paths.

mxPath(from, to = NA, connect = c("single", "all.pairs", "unique.pairs", "all.bivariate", "unique.bivariate"), arrows = 1, free = TRUE, values = NA, labels = NA, lbound = NA, ubound = NA, ..., joinKey = as.character(NA))

`from` |
character vector. These are the sources of the new paths. |

`to` |
character vector. These are the sinks of the new paths. |

`connect` |
String. Specifies the type of source to sink connection: "single", "all.pairs", "all.bivariate", "unique.pairs", "unique.bivariate". Default value is "single". |

`arrows` |
numeric value. Must be either 1 (for single-headed) or 2 (for double-headed arrows). |

`free` |
boolean vector. Indicates whether paths are free or fixed. |

`values` |
numeric vector. The starting values of the parameters. |

`labels` |
character vector. The names of the paths. |

`lbound` |
numeric vector. The lower bounds of free parameters. |

`ubound` |
numeric vector. The upper bounds of free parameters. |

`...` |
Not used. Allows OpenMx to catch the use of the deprecated ‘all’ argument. |

`joinKey` |
character vector. The name of the foreign key to join against some other model to create a cross model path (regression or factor loading. |

The mxPath function creates MxPath objects. These consist of a list of paths describing the relationships between variables in a model using the RAM modeling approach (McArdle and MacDonald, 1984). Variables are referenced by name, and these names must appear in the ‘manifestVar’ and ‘latentVar’ arguments of the mxModel function.

Paths are specified as going "from" one variable (or set of variables) "to" another variable or set of variables using the ‘from’ and ‘to’ arguments, respectively. If ‘to’ is left empty, it will be set to the value of ‘from’.

‘connect’ has five possible connection types: "single", "all.pairs", "all.bivariate", "unique.pairs", "unique.bivariate". The default value is "single". Assuming the values c(‘a’,‘b’,‘c’) for the ‘to’ and ‘from’ fields the paths produced by each connection type are as follows:

- "all.pairs":
(a,a), (a,b), (a,c), (b,a), (b,b), (b,c), (c,a), (c,b), (c,c).

- "unique.pairs":
(a,a), (a,b), (a,c), (b,b), (b,c), (c,c).

- "all.bivariate":
(a,b), (a,c), (b,a), (b,c), (c,a), (c,b).

- "unique.bivariate":
(a,b), (a,c), (b,c).

- "single":
(a,a), (b,b), (c,c).

Multiple variables may be input as a vector of variable names. If the ‘connect’ argument is set to "single", then paths are created going from each entry in the ‘from’ vector to the corresponding entry in the ‘to’ vector. If the ‘to’ and ‘from’ vectors are of different lengths when the ‘connect’ argument is set to "single", the shorter vector is repeated to make the vectors of equal length.

The ‘free’ argument specifies whether the paths created by the mxPath function are free or fixed parameters. This argument may take either TRUE for free parameters, FALSE for fixed parameters, or a vector of TRUEs and FALSEs to be applied in order to the created paths.

The ‘arrows’ argument specifies the type of paths created. A value of 1 indicates a one-headed arrow representing regression. This path represents a regression of the ‘to’ variable on the ‘from’ variable, such that the arrow points to the ‘to’ variable in a path diagram. A value of 2 indicates a two-headed arrow, representing a covariance or variance. If multiple paths are created in the same mxPath function, then the ‘arrows’ argument may take a vector of 1s and 2s to be applied to the set of created paths.

The ‘values’ is a numeric vectors containing the starting values of the created paths. ‘values’ gives a starting value for estimation. The ‘labels’ argument specifies the names of the resulting MxPath object. The ‘lbound’ and ‘ubound’ arguments specify lower and upper bounds for the created paths.

Returns a list of paths.

The previous implementation of ‘all’ had unsafe features. Its use is now deprecated, and has been replaced by the new mechanism ‘connect’ which supports safe and controlled generation of desired combinations of paths.

McArdle, J. J. and MacDonald, R. P. (1984). Some algebraic properties of the Reticular Action Model for moment structures. *British Journal of Mathematical and Statistical Psychology, 37,* 234-251.

The OpenMx User's guide can be found at http://openmx.ssri.psu.edu/documentation.

mxMatrix for a matrix-based approach to path specification; mxModel for the container in which mxPaths are embedded. More information about the OpenMx package may be found here.

# A simple Example: 1 factor Confirmatory Factor Analysis library(OpenMx) data(demoOneFactor) manifests <- names(demoOneFactor) latents <- c("G") factorModel <- mxModel(model="One Factor", type="RAM", manifestVars = manifests, latentVars = latents, mxPath(from=latents, to=manifests), mxPath(from=manifests, arrows=2), mxPath(from=latents, arrows=2,free=FALSE, values=1.0), mxData(cov(demoOneFactor), type="cov",numObs=500) ) factorFit <-mxRun(factorModel) summary(factorFit) # A more complex example using features of R to compress # what would otherwise be a long and error-prone script # list of 100 variable names: "01" "02" "03"... myManifest <- sprintf("%02d", c(1:100)) # the latent variables for the model myLatent <- c("G1", "G2", "G3", "G4", "G5") # Start building the model: # Define its type, and add the manifest and latent variable name lists testModel <- mxModel(model="testModel", type = "RAM", manifestVars = myManifest, latentVars = myLatent) # Create covariances between the latent variables and add to the model # Here we use combn to create the covariances # nb: To create the variances and covariances in one operation you could use # expand.grid(myLatent,myLatent) to specify from and to uniquePairs <- combn(myLatent,2) covariances <- mxPath(from = uniquePairs[1,], to=uniquePairs[2,], arrows = 2, free = TRUE, values = 1) testModel <- mxModel(model=testModel, covariances) # Create variances for the latent variables variances <- mxPath(from = myLatent, to=myLatent, arrows = 2, free = TRUE, values = 1) testModel <- mxModel(model=testModel, variances) # add variances to the model # Make a list of paths from each packet of 20 manifests # to one of the 5 latent variables # nb: The first loading to each latent is fixed to 1 to scale its variance. singles <- list() for (i in 1:5) { j <- i*20 singles <- append(singles, mxPath( from = myLatent[i], to = myManifest[(j - 19):j], arrows = 1, free = c(FALSE, rep(TRUE, 19)), values = c(1, rep(0.75, 19)))) } # add single-headed paths to the model testModel <- mxModel(model=testModel, singles)

[Package *OpenMx* version 2.7.2 Index]