Learn R Programming

FactorCopulaModel (version 0.1.1)

bifactor_fa: Gaussian bi-factor structure correlation matrix

Description

Gaussian bi-factor structure correlation matrix with quasi-Newton

Usage

bifactor_fa(grsize,start,data=1,cormat=NULL,n=100,prlevel=0,mxiter=100)

Value

a list with$nllk, $parmat= dx2 matrix of correlations and partial correlations

Arguments

grsize

vector of group sizes for bi-factor model

start

starting point should have dimension 2*d

data

nsize x d data set to compute the correlation matrix if correlation matrix (cormat) not given

cormat

dxd empirical correlation matrix

n

sample size

prlevel

print.level for nlm()

mxiter

maximum number of iterations for nlm()

Examples

Run this code
# \donttest{
data(rainstorm)
rmat = rainstorm$cormat
n = nrow(rainstorm$zprecip)
d = ncol(rmat)
grsize = rainstorm$grsize
fa1 = pfactor_fa(1,start=rep(0.8,d),cormat=rmat,n=n,prlevel=1)
st2 = c(rep(0.7,d),rep(0.2,grsize[1]+grsize[2]),rep(0.6,grsize[3]))
fa2 = pfactor_fa(2,start=st2,cormat=rmat,n=n,prlevel=1,mxiter=50)
# some sensitivity to starting point because of non-identiabilty due to rotation
st3 = c(rep(0.7,grsize[1]),rep(0.1,d),rep(0.7,grsize[2]),rep(0.1,d),rep(0.7,grsize[3]))
fa3 = pfactor_fa(3,start=st3,cormat=rmat,n=n,prlevel=1,mxiter=50)
names(fa3)
loadmat_rotated = fa3$loading
# compare factanal
fa3b = factanal(factors=3,covmat=rmat)
compare = cbind(loadmat_rotated,fa3b$loadings)
print(round(compare,3)) # order of factors is different but interpretation similar
#
bifa = bifactor_fa(grsize,start=c(rep(0.8,d),rep(0.2,d)),cormat=rmat,n=n,
   prlevel=1,mxiter=70)
mgrp = length(grsize)
# oblique factor model is much more parsimonious than bi-factor
obfa = oblique_fa(grsize,start=rep(0.7,d+mgrp), cormat=rmat, n=n, prlevel=1)
#
cat(fa1$nllk, fa2$nllk, fa3$nllk, bifa$nllk, obfa$nllk,"\n")
# }

Run the code above in your browser using DataLab