项目作者: javzapata

项目描述 :
R package for Partially Separable Multivariate Functional Data and Functional Graphical Models
高级语言: R
项目地址: git://github.com/javzapata/fgm.git
创建时间: 2019-09-27T02:39:42Z
项目社区:https://github.com/javzapata/fgm

开源协议:GNU General Public License v2.0

下载


fgm - Functional Graphical Models and Partial Separability

R package for Partially Separable Multivariate Functional Data and Functional Graphical Models
Binder

Installation: simply run install.packages('fgm') in the R console

This repository contains a copy of the R-package fgm at CRAN:

https://cran.r-project.org/web/packages/fgm/index.html

The methods implemented here are based on the following paper:

(Draft copy) https://arxiv.org/abs/1910.03134

(journal link) … under review…

posterFGM

Theory

A multivariate Gaussian process X is partially separable if there exists an orthonormal basis of such that the random vectors are mutually uncorrelated.

Univariate KL expansion possesses a potentially full inverse covariance structure. Under partial separability it remains block-diagonal.

Partial Separability Karhunen-Loeve expansion:

Univariate Karhunen-Loeve expansion:

Functions

fpca : Estimates the Karhunen-Loeve expansion for a partially separable multivariate Gaussian process.

  1. ## Variables
  2. # Omega - list of precision matrices, one per eigenfunction
  3. # Sigma - list of covariance matrices, one per eigenfunction
  4. # theta - list of functional principal component scores
  5. # phi - list of eigenfunctions densely observed on a time grid
  6. # y - list containing densely observed multivariate (p-dimensional) functional data
  7. install.packages('mvtnorm')
  8. install.packages('fda')
  9. install.packages('fgm')
  10. library(mvtnorm)
  11. library(fda)
  12. library(fgm)
  13. ## Generate data y
  14. source(system.file("exec", "getOmegaSigma.R", package = "fgm"))
  15. theta = lapply(1:nbasis, function(b) t(rmvnorm(n = 100, sigma = Sigma[[b]])))
  16. theta.reshaped = lapply( 1:p, function(j){
  17. t(sapply(1:nbasis, function(i) theta[[i]][j,]))
  18. })
  19. phi.basis=create.fourier.basis(rangeval=c(0,1), nbasis=21, period=1)
  20. t = seq(0, 1, length.out = time.grid.length)
  21. chosen.basis = c(2, 3, 6, 7, 10, 11, 16, 17, 20, 21)
  22. phi = t(predict(phi.basis, t))[chosen.basis,]
  23. y = lapply(theta.reshaped, function(th) t(th)\%*\%phi)
  24. ## Solve
  25. pfpca(y)

fgm: Estimates a sparse adjacency matrix representing the conditional dependency structure between features of a multivariate Gaussian process

  1. ## Variables
  2. # Omega - list of precision matrices, one per eigenfunction
  3. # Sigma - list of covariance matrices, one per eigenfunction
  4. # theta - list of functional principal component scores
  5. # phi - list of eigenfunctions densely observed on a time grid
  6. # y - list containing densely observed multivariate (p-dimensional) functional data
  7. install.packages('mvtnorm')
  8. install.packages('fda')
  9. install.packages('fgm')
  10. library(mvtnorm)
  11. library(fda)
  12. library(fgm)
  13. ## Estimation using fgm package
  14. ## Generate Multivariate Gaussian Process
  15. source(system.file("exec", "getOmegaSigma.R", package = "fgm"))
  16. theta = lapply(1:nbasis, function(b) t(rmvnorm(n = 100, sigma = Sigma[[b]])))
  17. theta.reshaped = lapply( 1:p, function(j){
  18. t(sapply(1:nbasis, function(i) theta[[i]][j,]))
  19. })
  20. phi.basis=create.fourier.basis(rangeval=c(0,1), nbasis=21, period=1)
  21. t = seq(0, 1, length.out = time.grid.length)
  22. chosen.basis = c(2, 3, 6, 7, 10, 11, 16, 17, 20, 21)
  23. phi = t(predict(phi.basis, t))[chosen.basis,]
  24. y = lapply(theta.reshaped, function(th) t(th)\%*\%phi)
  25. ## Solve
  26. fgm(y, alpha=0.5, gamma=0.8)