RAMScaled: Scaled/Standardized RAM Matrices

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/RAMScaled.R

Description

Derives the scaled/standardized RAM matrices.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
RAMScaled(A, S, Filter, C = NULL, C.scaled = NULL, check = TRUE, ...)

## Default S3 method:
RAMScaled(A, S, Filter, C = NULL, C.scaled = NULL, check = TRUE, ...)

## S3 method for class 'yac_symbol'
RAMScaled(
  A,
  S,
  Filter,
  C = NULL,
  C.scaled = NULL,
  check = TRUE,
  exe = TRUE,
  R = FALSE,
  format = "ysym",
  simplify = FALSE,
  ...
)

Arguments

A

t by t matrix \mathbf{A}. Asymmetric paths (single-headed arrows), such as regression coefficients and factor loadings.

S

t by t numeric matrix \mathbf{S}. Symmetric paths (double-headed arrows), such as variances and covariances.

Filter

p by t numeric matrix \mathbf{F}. Filter matrix used to select observed variables.

C

t by t numeric matrix \mathbf{C}. Model-implied variance-covariance matrix.

C.scaled

t by t numeric matrix \mathbf{C}_{\mathrm{scaled}}. Scaled/standardized model-implied variance-covariance matrix.

check

Logical. If check = TRUE do some preprocessing with input matrices using CheckRAMMatrices().

...

...

exe

Logical. If exe = TRUE, executes the resulting yacas expression. If exe = FALSE, returns the resulting yacas expression as a character string. If exe = FALSE, the arguments str, ysym, simplify, and tex, are ignored.

R

Logical. If R = TRUE, returns symbolic result as an R expression. If R = FALSE, returns symbolic result as "ysym", "str", or "tex" depending of format.

format

Character string. Only used when R = FALSE. If format = "ysym", returns symbolic result as yac_symbol. If format = "str", returns symbolic result as a characetr string. If format = "tex", returns symbolic result as LaTeX math.

simplify

Logical. Simplify symbolic results.

Details

The scaled/standardized \mathbf{A} and \mathbf{S} are given by

\mathbf{A}_{\mathrm{scaled}} = \mathbf{D} \mathbf{A} \mathbf{D}^{-1}

\mathbf{S}_{\mathrm{scaled}} = \mathbf{D} \mathbf{S} \mathbf{D}

where \mathbf{D} is a diagonal matrix whose diagonal elements are the diagonal elements of \mathbf{C} raised to -\frac{1}{2}, that is, the inverse of the standard deviations of the variables.

Value

Returns a list with the following elements

A.scaled

t by t matrix \mathbf{A}_{\mathrm{scaled}}. Scaled/standardized asymmetric paths (single-headed arrows), such as regression coefficients and factor loadings.

S.scaled

t by t numeric matrix \mathbf{S}_{\mathrm{scaled}}. Scaled/standardized symmetric paths (double-headed arrows), such as variances and covariances.

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other RAM matrices functions: C(), Expectations(), E(), IminusA(), M(), S(), g(), u(), v()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Numeric -----------------------------------------------------------
# This is a numerical example for the model
# y = alpha + beta * x + e
# y = 0 + 1 * x + e
#--------------------------------------------------------------------

A <- S <- matrixR::ZeroMatrix(3)
A[1, ] <- c(0, 1, 1)
diag(S) <- c(0, 0.25, 1)
colnames(A) <- rownames(A) <- c("y", "x", "e")
Filter <- diag(2)
Filter <- cbind(Filter, 0)
colnames(Filter) <- c("y", "x", "e")
(RAM <- RAMScaled(A, S, Filter))
C(A = RAM$A.scaled, S = RAM$S.scaled)
M(A = RAM$A.scaled, S = RAM$S.scaled, Filter = Filter)
# Symbolic ----------------------------------------------------------
# This is a symbolic example for the model
# y = alpha + beta * x + e
# y = 0 + 1 * x + e
#--------------------------------------------------------------------

A <- S <- matrixR::ZeroMatrix(3)
A[1, ] <- c(0, "beta", 1)
diag(S) <- c(0, "sigmax2", "sigmae2")
(RAM <- RAMScaled(Ryacas::ysym(A), S, Filter))
RAMScaled(Ryacas::ysym(A), S, Filter, format = "str")
RAMScaled(Ryacas::ysym(A), S, Filter, format = "tex")
RAMScaled(Ryacas::ysym(A), S, Filter, R = TRUE)

C(A = RAM$A.scaled, S = RAM$S.scaled)
M(A = RAM$A.scaled, S = RAM$S.scaled, Filter = Filter)

# Assigning values to symbols

beta <- 1
sigmax2 <- 0.25
sigmae2 <- 1

RAMScaled(Ryacas::ysym(A), S, Filter)
RAMScaled(Ryacas::ysym(A), S, Filter, format = "str")
RAMScaled(Ryacas::ysym(A), S, Filter, format = "tex")
RAMScaled(Ryacas::ysym(A), S, Filter, R = TRUE)
eval(RAMScaled(Ryacas::ysym(A), S, Filter, R = TRUE))

C(A = RAM$A.scaled, S = RAM$S.scaled)
M(A = RAM$A.scaled, S = RAM$S.scaled, Filter = Filter)

jeksterslab/ramR documentation built on March 14, 2021, 9:38 a.m.