cov.miss.mix.wt: weighted covariance for data with missing values

View source: R/cov-miss-mix-wt.R

cov.miss.mix.wtR Documentation

weighted covariance for data with missing values

Description

The weighted means and variances using the observation matrix and the estimated weight vectors for a data matrix containing missing values (NA or NaN)

Usage

cov.miss.mix.wt(
  x,
  means,
  secm,
  wt1 = rep(1/nrow(x), nrow(x)),
  wt2 = rep(1/nrow(x), nrow(x)),
  cor = FALSE,
  center = TRUE,
  method = c("unbiased", "ML")
)

Arguments

x

the observation matrix, which can contain missing values (NA or NaN)

means

a list containing the means of the missing values given observed values

secm

a list containing the second moments of the missing values given observed values

wt1

the state probabilities matrix (number of observations times number of states)

wt2

the mixture components probabilities list (of length nstate) of matrices (number of observations times number of mixture components)

cor

logical. if TRUE the weighted correlation is also given

center

logical. if TRUE the weighted mean is also given

method

with two possible entries:

  • "unbiased" the unbiased estimator is given

  • "ML" the maximum likelihood estimator is given

Value

list containing the following items:

  • center the weighted mean of x

  • cov the weighted covariance of x

  • n.obs the number of observations in x

  • cor the weighted correlation of x, if the parameter cor is TRUE

  • wt1 the state weighs wt1

  • wt2 the mixture component weights wt2

  • pmix the estimated mixture proportions

Author(s)

Morteza Amini, morteza.amini@ut.ac.ir

Examples

data(CMAPSS)
x0 = CMAPSS$train$x[1:CMAPSS$train$N[1], ]
n = nrow(x0)
wt1 = runif(n)
wt2 = runif(n)
p = ncol(x0)
sammissall = sample(1:n, trunc(n / 20))
means = secm = list()
for(ii in 1:n){ 
	if(ii %in% sammissall){
   means[[ii]] = colMeans(x0[sammissall, ])
   secm[[ii]] = t(x0[sammissall, ]) %*% x0[sammissall, ]
 }else{
  means[[ii]] = secm[[ii]] = NA
 }
}
x0[sammissall,] = NA

cov.miss.mix.wt(x0, means, secm, wt1, wt2)


hhsmm documentation built on Aug. 8, 2023, 9:06 a.m.

Related to cov.miss.mix.wt in hhsmm...