Last data update: 2014.03.03

R: Make an object that inherits from class "manifest"
make_manifestR Documentation

Make an object that inherits from class "manifest"

Description

This function is intended for users and sets up the left-hand side of the factor analysis model and is a prerequisite for calling make_restrictions and Factanal.

Although it is possible to simply estimate and use the unbiased sample covariance matrix, there are many other ways to estimate a covariance that can be superior, particularly when the traditional maximum likelihood discrepancy function is not chosen in the call to make_restrictions.

In technical terms, make_manifest is the constructor for objects of manifest-class, which houses the sample covariance estimate and some ancillary information in its slots. The three arguments in the signature of the S4 generic function are:
x, data, and covmat

Usage

## S4 method for signature 'missing,missing,list'
make_manifest(covmat, n.obs = NA_integer_, shrink = FALSE)
## S4 method for signature 'missing,missing,hetcor'
make_manifest(covmat, shrink = FALSE)
## S4 method for signature 'missing,missing,matrix'
make_manifest(covmat, n.obs = NA_integer_, shrink = FALSE, sds = NULL)
## S4 method for signature 'missing,missing,CovMcd'
make_manifest(covmat)

# Use the methods above when only the covariance matrix is available
# Use the methods below when the raw data are available (preferable)

## S4 method for signature 'data.frame,missing,missing'
make_manifest(x, subset, shrink = FALSE, 
bootstrap = 0, how = "default", seed = 12345, wt = NULL, ...)

## S4 method for signature 'missing,data.frame,missing'
make_manifest(data, subset, shrink = FALSE,
bootstrap = 0, how = "default", seed = 12345, wt = NULL, ...)

## S4 method for signature 'missing,matrix,missing'
make_manifest(data, subset, shrink = FALSE,
bootstrap = 0, how = "default", seed = 12345, wt = NULL, ...)

## S4 method for signature 'matrix,missing,missing'
make_manifest(x, subset, shrink = FALSE,
bootstrap = 0, how = "default", seed = 12345, wt = NULL, ...)

## S4 method for signature 'formula,data.frame,missing'
make_manifest(x, data, subset, shrink = FALSE, na.action = "na.pass", 
bootstrap = 0, how = "default", seed = 12345, wt = NULL, ...)

Arguments

x

a formula, data.frame, nonsquare matrix of observations by variables, or missing. If a formula, then data must be a data.frame and the formula should not have a response. If a data.frame or a matrix of data, then all its columns are used.

data

a data.frame, nonsquare matrix of observations by variables, or missing. If a data.frame and formula is not specified, then all its columns are used and similarly if it is a matrix of data.

covmat

A covariance matrix, a list, an object of CovMcd-class, an object of S4 class "hetcor" from the polycor package, or missing. If a list, it must contain an element named "cov" and may contain the following named elements:

n.obs

the number of observations used in calculating the "cov" element

W

a positive definite matrix to be used as a weight matrix in the ADF discrepancy function. However, the make_restrictions-methods can calculate various weight matrices if the raw data are passed to make_manifest, so this mechanism should only be used if those options are inadequate

sds

a numeric vector of standard deviations to be used if "cov" is really a correlation matrix

n.obs

The number of observations, which is used if covmat is a covariance matrix or if covmat is a list with no element named n.obs. It is possible to obtain maximum likelihood estimates without knowing the number of observations but nothing else

shrink

A logical indicating whether to use a “shrinkage” estimator of the covariance matrix. If TRUE, then the “minimax shrinkage” estimator discussed in theorem 3.1 of Dey and Srinivasan (1985) is invoked on the sample covariance matrix as calculated according to the other arguments. In some circumstances, shrink is inappropriate and ignored with a warning

sds

Either NULL or a numeric vector that contains the standard deviations of the manifest variables, which is used when covmat is a correlation matrix

subset

A specification of the cases to be used

bootstrap

A nonnegative integer (defaulting to zero) indicating how many bootstraps to do when estimating the uncertainty of the sample covariance estimates.

how

A character string indicating how the covariance matrix should be estimated; see the Details section

seed

A vector of length at most one to be used as the random number generator seed if how = "mcd" or bootstrap > 0. If NULL, then the current seed is used. This argument defaults to 12345.

wt

An optional numeric vector of weights that is the same length as the number of observations that indicates the weight for each observation when x is specified. By default, the observations are weighted equally. The wt argument can be used in two ways. First, it is passed to the the corresponding argument of cov.wt if appropriate (see below). Second, it is passed to the prob argument of sample when bootstrap > 0.

na.action

The na.action to be used if x is a formula.

...

Further arguments that are passed to downstream functions when covmat is unspecified, implying that the raw data are being used to estimate the sample covariance.

Details

The rules governing the calculation of the sample covariance matrix are as follows and primarily depend on whether any of the manifest variables are ordered factors. First, consider the case where all manifest variables are numeric. If any of these manifest variables contain missing values, then the covariance matrix is estimated via maximum likelihood under multivariate normality assumptions but requires the suggested mvnmle package. Otherwise, the how argument dictates how the covariance matrix is estimated. There is much to be said in favor the Minimum Covariance Determinant (CovMcd) estimator (see Pison et. al. 2003) and it is used as the default when there are no missing data, although it can subtly affect the sampling distributions of estimates that subsequently derived from it. The same could probably be said for the shrinkage estimators (either via how = "lambda" or shrink = TRUE). The Dey and Srinivasan (1985) shrinkage estimator preserves the eigenvectors of the preliminarily-calculated covariance matrix but deterministically compresses the eigenvalues. The cov.shrink estimator in the corpcor package is based on the idea that the amount shrinkage should be proportional to the variance of the covariance estimates. Use how = "mle" or how = "unbiased" to obtain either the maximum likelihood or unbiased sample covariance estimator, the latter of which is the one used in virtually all factor applications whether appropriate or not.

Next, consider the case where at least one manifest variable is an ordered factor. If how = "ranks", Spearman correlations are estimated from the integer codes underlying the ordered factors. This mechanism is recommended only if there are at least five levels of each ordered factor and no missing data. In that case, one would presumably want to specify method = "ADF" in the subsequent call to make_restrictions). If how != "ranks" all pairwise correlations are estimated under bivariate normality assumptions via hetcor in the suggested polycor package, which will allow pairwise-deletion when there are missing data. If how != "ranks" and bootstrap > 0 (recommended), then there must not be any missing data because the bootstrapping utilizes fast Spearman correlations and then tries to correct the bias by rescaling the bootstrapped means to equal to point estimates calculated with the call to hetcor.

In general, bootstrapping is good for estimating the uncertainty of the estimated sample covariances and this uncertainty estimate is needed for the ADF discrepancy function and its special cases. In some cases, bootstrapping is the only way to obtain such an uncertainty estimate.

Value

An object that inherits from manifest-class.

Author(s)

Ben Goodrich

References

Dey, D. K. and Srinivasan K. (1985) Estimation of a covariance matrix under Stein's loss. The Annals of Statistics, 13, 1581–1591.

Pison, G., Rousseeuw, P.J., Filzmoser, P. and Croux, C. (2003) Robust factor analysis. Journal of Multivariate Analysis, 84, 145–172.

See Also

Factanal, make_restrictions, manifest-class, covMcd, cov.wt, hetcor, mlest, cov.shrink, and cov.

Examples

man <- make_manifest(covmat = Harman23.cor)
show(man)      # some basic info
if(require(nFactors)) screeplot(man) # advanced Scree plot
cormat(man)    # sample correlation matrix

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(FAiR)
Loading required package: rgenoud
##  rgenoud (Version 5.7-12.4, Build Date: 2015-07-19)
##  See http://sekhon.berkeley.edu/rgenoud for additional documentation.
##  Please cite software as:
##   Walter Mebane, Jr. and Jasjeet S. Sekhon. 2011.
##   ``Genetic Optimization Using Derivatives: The rgenoud package for R.''
##   Journal of Statistical Software, 42(11): 1-26. 
##

Loading required package: gWidgetsRGtk2
Loading required package: RGtk2
Loading required package: gWidgets
Loading required package: cairoDevice
Loading required package: stats4
Loading required package: rrcov
Loading required package: robustbase
Scalable Robust Estimators with High Breakdown Point (version 1.3-11)

Loading required package: Matrix
##  FAiR Version 0.4-15 Build Date: 2014-02-08
## See http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:fair for more info
FAiR  Copyright (C) 2008 -- 2012  Benjamin King Goodrich
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions, namely those specified in the LICENSE file
in the root directory of the source code.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/FAiR/01make_manifest.Rd_%03d_medium.png", width=480, height=480)
> ### Name: make_manifest
> ### Title: Make an object that inherits from class "manifest"
> ### Aliases: make_manifest make_manifest-methods
> ###   make_manifest,missing,missing,list-method
> ###   make_manifest,missing,missing,hetcor-method
> ###   make_manifest,missing,missing,matrix-method
> ###   make_manifest,missing,missing,CovMcd-method
> ###   make_manifest,data.frame,missing,missing-method
> ###   make_manifest,missing,data.frame,missing-method
> ###   make_manifest,missing,matrix,missing-method
> ###   make_manifest,matrix,missing,missing-method
> ###   make_manifest,formula,data.frame,missing-method
> ### Keywords: multivariate methods
> 
> ### ** Examples
> 
> man <- make_manifest(covmat = Harman23.cor)
Warning message:
In FAiR_make_manifest_list(covmat, shrink) :
  it is strongly preferable to pass the raw data to make_manifest()
> show(man)      # some basic info
Number of observations:  305 
Number of manifest variables:  8 
Proportion of positive correlations:  1 
p-value for null hypothesis that manifest variables are uncorrelated:  0 
p-value for null hypothesis that the anti-images are uncorrelated:  1.401625e-209 
Kaiser-Meyer-Okin Measure of Sampling Adequacy:  0.8454609 
Kaiser-Meyer-Okin Measure of Homogeneity of Each Manifest Variable
                    [,1]
height         0.8643147
arm.span       0.8162962
forearm        0.8576544
lower.leg      0.8866618
weight         0.7796144
bitro.diameter 0.8511215
chest.girth    0.8240441
chest.width    0.8984689

Eigenvalues of sample correlation matrix
[1] 4.67287960 1.77098284 0.48103549 0.42144078 0.23322126 0.18667352 0.13730387
[8] 0.09646264
> if(require(nFactors)) screeplot(man) # advanced Scree plot
Loading required package: nFactors
Loading required package: MASS
Loading required package: psych

Attaching package: 'psych'

The following object is masked from 'package:robustbase':

    cushny

Loading required package: boot

Attaching package: 'boot'

The following object is masked from 'package:psych':

    logit

The following object is masked from 'package:robustbase':

    salinity

Loading required package: lattice

Attaching package: 'lattice'

The following object is masked from 'package:boot':

    melanoma


Attaching package: 'nFactors'

The following object is masked from 'package:lattice':

    parallel

> cormat(man)    # sample correlation matrix
               height arm.span forearm lower.leg weight bitro.diameter
height          1.000    0.846   0.805     0.859  0.473          0.398
arm.span        0.846    1.000   0.881     0.826  0.376          0.326
forearm         0.805    0.881   1.000     0.801  0.380          0.319
lower.leg       0.859    0.826   0.801     1.000  0.436          0.329
weight          0.473    0.376   0.380     0.436  1.000          0.762
bitro.diameter  0.398    0.326   0.319     0.329  0.762          1.000
chest.girth     0.301    0.277   0.237     0.327  0.730          0.583
chest.width     0.382    0.415   0.345     0.365  0.629          0.577
               chest.girth chest.width
height               0.301       0.382
arm.span             0.277       0.415
forearm              0.237       0.345
lower.leg            0.327       0.365
weight               0.730       0.629
bitro.diameter       0.583       0.577
chest.girth          1.000       0.539
chest.width          0.539       1.000
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>