ricf: Fitting Cyclic Linear Structural Equation Models

View source: R/ricf.R

ricfR Documentation

Fitting Cyclic Linear Structural Equation Models

Description

Estimates MLE's for cyclic linear SEM's as described in Drton, Fox, Wang (2019)

Usage

ricf(
  B,
  Omega,
  Y,
  BInit = NULL,
  OmegaInit = NULL,
  sigConv = TRUE,
  tol = 1e-07,
  maxIter = 5000,
  msgs = TRUE,
  omegaInitScale = 0.9,
  maxKap = 1e+13
)

Arguments

B

V by V matrix with 0, 1 giving structure of directed edges. B[i, j] = 1 indicates the edge j -> i.

Omega

V by V matrix with 0, 1 giving structure of bi-directed edges. Omega[i,h] = 1 indicates the edge i <-> j. The diagonal elements should also be 1

Y

V by n data matrix where each row corresponds to an observed variable and each column corresponds to a multivariate observation. The method assumes that each variable (row) is mean 0.

BInit

V by V matrix giving initial edges weights for directed edges. If BInit is NULL, a default initialization will be used.

OmegaInit

V by V matrix giving initial edge weights for bi-directed edges. If OmegaInit is NULL, a default initialization will be used

sigConv

boolean which specifies how to measure convergence. TRUE checks for convergence in Sigma while FALSE checks for convergence in the edge weight estimates

tol

convegence tolerance

maxIter

integer specifying the maximum number of iterations

msgs

boolean on whether to print warning messages to command line if there are bows in the graph

omegaInitScale

value in (0,1) which determines how to initialize estimates for the bidirected edges. The directed edges are initialized through OLS regression and the bidirected edge weights are initialized by placing the structural 0's in the covariance of the residuals. If the resulting initialization is not positive definite, we scale the elements of corresponding row/columns such that sum(OmegaInit[i,-i]) = OmegaInit[i,i] * omegaInitScale

Value

SigmaHat

estimated covariance matrix at convergence

OmegaHat

estimated Omega (edge weights for bi-directed edges) at convergence

BHat

estimated B matrix (edge weights for directed edges) at converegence

Iter

number of iterations until convergence. a single iteration is considered a pass through all nodes

Converged

boolean on whether or not the algorithm converged before the max iterations

Examples

## Select True Parameters
B <- (B.weights != 0) + 0
Omega <- (Omega.weights != 0) + 0 
ricf(B, Omega, Y)
out <- ricf(B, Omega, Y)
se <- var.ricf(Y, B, Omega,  out$BHat, out$OmegaHat, type = "expected")
# get parameter estimates and marginal standard errors
output <- cbind(c(out$BHat[which(B !=0)], out$OmegaHat[which(Omega !=0 & lower.tri(Omega, diag = T))]),
               sqrt(diag(se)))
colnames(output) <- c("estimates", "SE")
rownames(output) <- rownames(se)
output

ysamwang/BCD documentation built on Sept. 3, 2023, 1:33 a.m.