diff --git a/.project b/.project index a875c237..96dbc769 100644 --- a/.project +++ b/.project @@ -20,6 +20,11 @@ + + org.eclipse.statet.docmlet.resourceProjects.WikitextBuilder + + + de.walware.statet.base.StatetNature @@ -27,5 +32,6 @@ org.eclipse.statet.ide.resourceProjects.Statet org.eclipse.statet.r.resourceProjects.R org.eclipse.statet.docmlet.resourceProjects.Tex + org.eclipse.statet.docmlet.resourceProjects.Wikitext diff --git a/R/fmCov.R b/R/fmCov.R index ec2884ed..0224d241 100644 --- a/R/fmCov.R +++ b/R/fmCov.R @@ -123,5 +123,32 @@ fmCov.sfm <- function(object, use="pairwise.complete.obs", ...) { fmCov.ffm <- function(object, use="pairwise.complete.obs", ...) { # already computed via fitFfm function - return(object$return.cov) -} + + # get parameters and factors from factor model + beta <- as.matrix(object$beta) + # convert NAs to 0 to enable matrix multiplication + beta[is.na(beta)] <- 0 + sig2.e = object$resid.var + factor <- as.matrix(object$data[, object$factor.names]) + factor.cov = object$factor.cov + # factor covariance matrix + if (is.null(factor.cov)) { + factor.cov = cov(factor, use=use, ...) + } else { + identical(dim(factor.cov), as.integer(c(ncol(factor), ncol(factor)))) + } + + # residual covariance matrix D + if (length(sig2.e) > 1) { + D.e = diag(sig2.e) + } else { + D.e = as.vector(sig2.e) + } + + cov.fm = beta %*% factor.cov %*% t(beta) + D.e + + if (any(diag(chol(cov.fm))==0)) { + warning("Covariance matrix is not positive definite!") + } + + return(cov.fm)} diff --git a/R/tsPlotMP.R b/R/tsPlotMP.R index 6390e114..80a04061 100644 --- a/R/tsPlotMP.R +++ b/R/tsPlotMP.R @@ -74,5 +74,3 @@ tsPlotMP = function (ret, add.grid = FALSE, layout = NULL, type = "l", yname = " panel = panel) print(pl) } - -