R: Jiggle parameter values.

mxJiggle {OpenMx} | R Documentation

## Jiggle parameter values.

### Description

Jiggle free parameter values, subject to box constraints. `imxJiggle()` is called internally by `mxTryHard()` (q.v.). `mxJiggle()` provides a more user-friendly wrapper to `imxJiggle()`, and can alternately emulate the 'JIGGLE' behavior of classic Mx.

### Usage

    mxJiggle(model, classic=FALSE, dsn=c("runif","rnorm","rcauchy"), loc=1, scale=0.25)
    imxJiggle(params, lbounds, ubounds, dsn, loc, scale)

### Arguments

`model` | An object of class MxModel.
`classic` | Logical; should `mxJiggle()` emulate the classic-Mx behavior elicited by keyword JIGGLE? Defaults to `FALSE`. See below, under "Details," for additional information.
`dsn` | Character string naming which random-number distribution–either uniform (rectangular), normal (Gaussian), or Cauchy–to be used to perturb free-parameter values. Defaults to the uniform distribution (for `mxJiggle()`).
`loc, scale` | Numeric. The location and scale parameters of the distribution from which random values are drawn to perturb free-parameter values, defaulting respectively to 1 and 0.25 (for `mxJiggle()`).
`params` | Numeric vector of current free parameter values.
`lbounds` | Numeric vector of lower bounds on parameters.
`ubounds` | Numeric vector of upper bounds on parameters.

### Details

If `mxJiggle()` argument `classic=FALSE` (the default), `mxJiggle()` calls `imxJiggle()`. In that case, `mxJiggle()` passes `imxJiggle()` its own values for arguments `dsn`, `loc`, and `scale`, and extracts values for arguments `params`, `lbounds`, and `ubounds` from `model`. Then, `model`'s free-parameter values are randomly perturbed before being re-assigned to it. The distributional family from which the perturbations are randomly generated is dictated by argument `dsn`. The distribution is parameterized by arguments `loc` and `scale`, respectively the location and scale parameters. The location parameter is the distribution's median. For the uniform distribution, `scale` is the absolute difference between its median and extrema (i.e., half the width of the rectangle); for the normal distribution, `scale` is its standard deviation; and for the Cauchy, `scale` is one-half its interquartile range. Free-parameter values are first multiplied by random draws from a distribution with the provided `loc` and `scale`, then added to random draws from a distribution with the same `scale` but with a median of zero.

If `mxJiggle()` argument `classic=TRUE`, then each free-parameter value x_i is replaced with x_i + 0.1(x_i + 0.5); this is the same behavior elicited in classic Mx by keyword JIGGLE.

### Value

`imxJiggle()` returns a numeric vector of randomly perturbed free-parameter values. `mxJiggle()` returns `model`, with its free parameter values altered according to the other function arguments.

### See Also

`mxTryHard()`

### Examples

    data(demoOneFactor)
    manifests <- names(demoOneFactor)
    latents <- c("G")
    factorModel <- mxModel(
    	"One Factor",
    	type="RAM",
    	manifestVars = manifests,
    	latentVars = latents,
    	mxPath(from=latents, to=manifests,values=0.8),
    	mxPath(from=manifests, arrows=2,values=1),
    	mxPath(from=latents, arrows=2,
    				 free=FALSE, values=1.0),
    	mxData(cov(demoOneFactor), type="cov",
    				 numObs=500)
    )

    iniPars <- coef(factorModel)
    print(iniPars)

    pars2 <- imxJiggle(params=iniPars,lbounds=NA,ubounds=NA,dsn="runif",loc=1,scale=0.05)
    print(pars2)

    mod2 <- mxJiggle(model=factorModel,scale=0.05)
    coef(mod2)

    mod3 <- mxJiggle(model=factorModel,classic=TRUE)
    coef(mod3)

[Package OpenMx version 2.17.3 Index]