mifa.cov: mifa.cov

Description Usage Arguments Details Value Author(s) References Examples

Description

This function estimates the covariance matrix of an incomplete dataset using multiple imputation.

Usage

1
mifa.cov(data.miss,n.factor,M,maxit.mi = 5,method.mi='pmm',alpha = 0.05,rep.boot=NULL,ci=FALSE)

Arguments

data.miss

The incomplete dataset, a matrix with the items as its columns subject as its rows. The missing values should be shown with NA.

n.factor

A vector containing numbers of factors which should be used to compute proportion of explained variance or construct confidence intervals.

M

A scalar specifying number of multiple imputations.

maxit.mi

A scalar specifying number of iterations for each imputation. For more information see R documentation for mice package. The default is 5.

method.mi

The imputation method, it can be a string or a vector of strings of the size equal to number of items. For more information see R documentation for mice package. The default is set as 'pmm', i.e., predictive mean matching.

alpha

The significance level for constructing confidence intervals. The dafault if 0.05.

rep.boot

A scalar specifying number of bootstrap sub-samples to construct the confidence interval. If ci=TRUE rep.boot should be specified.

ci

A logical variable indicating whether confidence intervals should be constructed for proportion of explianed variance or not. The default value is FALSE.

Details

Note that one needs to install the package 'mice' before using this function. This can be done use the command: install.packages("mice")

Value

cov.mice

The estimatied covariance matrix of the incomplete data using multiple imputations.

cov.mice.imp

A list containing th estimated covariance matrix for each of M imputed data.

exp.var.mice

A vector containing the estimated proportions of explained variance for each of specified n.factor components.

ci.mice.fieller

A matrix containing the estimated Fieller's confidence interval for proportion of explained variance for each of specified n.factor components.

ci.mice.bootstrap

A matrix containing the estimated bootstrap confidence interval for proportion of explained variance for each of specified n.factor components.

Author(s)

Vahid Nassiri, Anikó Lovik, Geert Molenberghs, Geert Verbeke.

References

The mice documentation: https://cran.r-project.org/web/packages/mice/mice.pdf

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
# Generating incomplete data
# defining the vector of eigenvalues
e.vals=c(50,48,45,25,20,10,5,5,1,1,0.5,0.5,0.5,0.1,0.1)
# loading eigeninv package to generate a covariance matrix with the
# eigenvalues in e.vals, if this package is not installed, one needs
# to install it first using install.packages("eigeninv")
require(eigeninv)
library(eigeninv)
cov.mat = eiginv(evals=e.vals, symmetric=TRUE)
# Defining the sample size, N, and number of items, P.
P = length(e.vals)
N = 100
# Generate a set of centered indepdent normal data
data.ini1 = matrix(rnorm(N*P),N,P)
mean.data.ini = apply(data.ini1,2,mean)
data.ini = t(t(data.ini1)-mean.data.ini)
# Finding the Cholesky decomposition of the cov.mat
chol.cov=t(chol(cov.mat))
# Using col.cov to generate multivariate normal data
# with the given covariance matrix.
data=matrix(0,N,P)
for (i in 1:N){
  data[i,]=chol.cov
}
# Here we create 5-percent missing data with
# missing completely at random mechanism
data.miss=data
mcar.n.miss=0.05
for (i in 1:P){
  for (j in 1:N){
    rand.u=runif(1)
    if (rand.u<=mcar.n.miss){
      data.miss[j,i]=NA
    }
  }
}
result.mi=mifa.cov (data.miss,n.factor=1:10,M=10,maxit.mi = 5,method.mi='pmm',
                  alpha = 0.05,rep.boot=500,ci=TRUE)

vahidnassiri/mifa documentation built on June 23, 2019, 12:06 a.m.