est_disp {lazy.fa}R Documentation

Constrained ML Estimation of Normal Dispersion Matrix

Description

Constrained ML Estimation of Normal Dispersion Matrix

Usage

est_disp(
  S,
  n = 1,
  Phi0 = NULL,
  Phi = NULL,
  nodiag = 1,
  method = "BFGS",
  maxiter = 100,
  eps = 1e-11,
  control = NULL,
  print = 0
)

Arguments

S

Sample dispersion matrix: SSCP divided by n.

n

The # of observations or df: The denominator of S.

Phi0

The constraint matrix: Those elements of Phi corresponding to the NA elements of Phi0 will be estimated.

Phi

The initial value of Phi matrix

nodiag

= 0 to estimate the diagonal elements of Phi.
When nodiag=1, diag(Phi) <- diag(S) is enforced.

method

The method to be used in native optim function.

maxiter

Maximum # of iterations for optim: maxit

eps

Tolerance for optim: reltol

control

Control list for optim: maxi and reltol will be excluded.

print

= 1 to print the result

Details

Those elements of Phi matrix corresponding to the NA elements of Phi0 matrix will be vectorized and treated as the parameter vector.
R native optim function is used to optimize the following log likelihood:
n * (log( det(Phi) ) + tr(solve(Phi)\%*\%S) )

Examples


ndim=3
n=100

seed=1701
set.seed(seed)

S=matrix(rnorm(n*ndim),n)
S=t(S)%*%S
dsiS=diag(sqrt((1)/vecdiag(S)))
S=dsiS%*%S%*%dsiS

title <- "ML is simple."
Phi0 <- diag(ndim)
diag(Phi0) <- NA
Phi0[3,2] <- NA
Phi0[upper.tri(Phi0)] <- t(Phi0)[upper.tri(Phi0)]
locna <- which(is.na(Phi0))

cat(title)
res <- est_disp( S, n, Phi0=Phi0, Phi=NULL, nodiag=0, print=1 )
Print(Phi0, S-res$Phi, fmt="8.5")
Print((S-res$Phi)[locna], fmt="8.5")


title <- "ML is NOT simple."
Phi0 <- matrix(0.2,ndim,ndim)
diag(Phi0) <- NA
Phi0[3,2] <- NA
Phi0[upper.tri(Phi0)] <- t(Phi0)[upper.tri(Phi0)]
locna <- which(is.na(Phi0))

cat(title)
res <- est_disp( S, n, Phi0=Phi0, Phi=NULL, nodiag=1, prin=1 )
Print(Phi0, S-res$Phi, fmt="8.5")
Print((S/n-res$Phi)[locna], fmt="8.5")

cat(title)
res <- est_disp( S, n, Phi0=Phi0, Phi=NULL, nodiag=0, prin=1 )
Print(Phi0, S-res$Phi, fmt="8.5")
Print((S-res$Phi)[locna], fmt="8.5")



[Package lazy.fa version 0.1.4 Index]