VarObj {frechet}R Documentation

Fréchet Variance Trajectory for densities

Description

Modeling time varying density objects with respect to $L^2$-Wasserstein distance by Fréchet variance trajectory

Usage

VarObj(tgrid, yin = NULL, hin = NULL, din = NULL, qin = NULL, optns = list())

Arguments

tgrid

Time grid vector for the time varying object data.

yin

An array or list of lists holding the samples of observations. If yin is an array, it has size n x length(tgrid) x numbers of samples holding the observation, such that yin[i,j,] holds the observations to the ith sample at the jth time grid. If yin is a list of lists, yin[[i]][[j]] holds the observations to the ith sample at the jth time grid.

hin

A list of lists holding the histogram for each subject. hin[[i]][[j]] holds the histogram to the ith sample at the jth time grid.

din

A three dimension array of size n x length(tgrid) x length(optns$dSup) holding the observed densities, such that din[i,j,] holds the observed density function taking values on optns$dSup corresponding to the ith sample at the jth time grid.

qin

A three dimension array of size n x length(tgrid) x length(optns$qSup) holding the observed quantiles, such that din[i,j,] holds the observed density function taking values on optns$qSup corresponding to the ith sample at the jth time grid. Note that only one of yin, hin, din and qin needs to be input. If more than one of them are specified, yin overwrites hin, hin overwrites din and din overwrites qin. where each row holds the observations for one subject on the common grid tGrid.

optns

a list of options control parameters specified by list(name=value).

Details

Available control options are qSup, nqSup, dSup and other options in FPCA of fdapace.

Value

A list of the following:

tgridout

Time grid vector for the output time varying object data.

K

Numbers of principal components.

nu

A vector of dimension length(tgridout) giving the mean function support on tgridout of the Fréchet variance function.

lambda

A vector of dimension K containing eigenvalues.

phi

A length(tgridout) X K matrix containing eigenfunctions support on tgridout of the Fréchet variance function.

xiEst

A n X K matrix containing the FPC estimates.

cumFVE

A vector of dimension K with the fraction of the cumulative total variance explained with each additional FPC.

FPCAObj

FPCA Object of Fréchet variance function.

tgridin

Input tgrid.

qSup

A vector of dimension length(tgridin) giving the domain grid of quantile functions qout.

qout

A three dimension array of dimension n x length(tgridin) x length(qSup) holding the observed quantiles, such that qout[i,j,] holds the observed density function taking values on qSup corresponding to the ith sample at the jth time grid.

qmean

A length(tgridin) X length(qSup) matrix containing the time varying Fréchet mean function.

VarTraj

A n X length(tgridin) matrix containing the variance trajectory.

References

Dubey, P., & Müller, H. G. (2021). Modeling Time-Varying Random Objects and Dynamic Networks. Journal of the American Statistical Association, 1-33.

Examples


set.seed(1)
#use yin 
tgrid = seq(1, 50, length.out = 50)
dSup = seq(-10, 60, length.out = 100)
yin = array(dim=c(30, 50, 100))
for(i in 1:30){
  yin[i,,] = t(sapply(tgrid, function(t){
    rnorm(100, mean = rnorm(1, mean = 1, sd = 1/t))
  }))
}
result1 = VarObj(tgrid, yin = yin)
plot(result1$phi[,1])
plot(result1$phi[,2])
yin2 = replicate(30, vector("list", 50), simplify = FALSE)
for(i in 1:30){
  for(j in 1:50){
    yin2[[i]][[j]] = yin[i,j,]
  }}
result1 = VarObj(tgrid, yin = yin2)

# use hin
tgrid = seq(1, 50, length.out = 50)
dSup = seq(-10, 60, length.out = 100)
hin =  replicate(30, vector("list", 50), simplify = FALSE)
for(i in 1:30){
  for (j in 1:50){
    hin[[i]][[j]] = hist(yin[i,j,])
  }
}
result2 = VarObj(tgrid, hin = hin)

# use din
tgrid = seq(1, 50, length.out = 50)
dSup = seq(-10, 60, length.out = 100)
din = array(dim=c(30, 50, 100))
for(i in 1:30){
  din[i,,] = t(sapply(tgrid, function(t){
    dnorm(dSup, mean = rnorm(1, mean = t, sd = 1/t))
  }))
}
result3 = VarObj(tgrid, din = din, optns=list(dSup = dSup))

# use qin
tgrid = seq(1, 50, length.out = 50)
qSup = seq(0.00001,1-0.00001,length.out = 100)
qin = array(dim=c(30, 50, 100))
for(i in 1:30){
  qin[i,,] = t(sapply(tgrid, function(t){
    qnorm(qSup, mean = rnorm(1, mean = t, sd = 1/t))
  }))
}
result4 = VarObj(tgrid, qin = qin, optns=list(qSup = round(qSup, 4)))


[Package frechet version 0.3.0 Index]