Learn R Programming

simsem (version 0.2-8)

adjust: Change an element in SimMatrix, SymMatrix, or SimVector.

Description

This function will adjust an element in SimMatrix, SymMatrix, or SimVector. The specified element may be set to be free parameter with number or distribution object as starting values. Alternatively, the element can be fixed to be a value (such as 0).

Usage

adjust(target, value, pos, numAsFixed)

Arguments

target
Target SimMatrix, SymMatrix, or SimVector that you would like to adjust.
value
The name of distribution object that you would like to specify (put as character with single or double quotation) or number that represents fixed values or starting valu
pos
The position of element that you would like to adjust, such as "c(1,2)" for the element in Row 1 and Column 2 in the specified matrix.
numAsFixed
This argument is used when the VirtualDist argument was specified as number. If TRUE (as default), the number is treated as fixed parameters. If FALSE, the number is treated as a starting value and the element

Value

  • Return the input SimMatrix, SymMatrix, or SimVector with adjusted element.

See Also

  • SimMatrixfor random parameter matrix
  • SymMatrixfor symmetric random parameter matrix
  • SimVectorfor random parameter vector

Examples

Run this code
loading <- matrix(0, 6, 2)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
LX <- simMatrix(loading, 0.7)
summary(LX)
run(LX)

u34 <- simUnif(0.3, 0.4)
LX <- adjust(LX, "u34", c(2, 1))
summary(LX)
run(LX)

LX <- adjust(LX, 0, c(2,1))
LX <- adjust(LX, 0.5, c(2,2), FALSE)
summary(LX)
run(LX)

factor.mean <- rep(NA, 2)
factor.mean.starting <- c(5, 2)
AL <- simVector(factor.mean, factor.mean.starting)
run(AL)
summary(AL)

n01 <- simNorm(0, 1)
AL <- adjust(AL, "n01", 2)
run(AL)
summary(AL)

Run the code above in your browser using DataLab