Type: | Package |
Title: | Multivariate Circular Data using MNNTS Models |
Version: | 0.1.0 |
Date: | 2023-09-09 |
Description: | A collection of utilities for the statistical analysis of multivariate circular data using distributions based on Multivariate Nonnegative Trigonometric Sums (MNNTS). The package includes functions for calculation of densities and distributions, for the estimation of parameters, and more. |
Depends: | R (≥ 3.5.0), stats, psychTools, CircNNTSR |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
LazyLoad: | yes |
NeedsCompilation: | no |
Packaged: | 2023-09-11 19:33:11 UTC; mercedesgregorio |
Author: | Juan Jose Fernandez-Duran [aut], Maria Mercedes Gregorio-Dominguez [aut, cre] |
Maintainer: | Maria Mercedes Gregorio-Dominguez <mercedes@itam.mx> |
Repository: | CRAN |
Date/Publication: | 2023-09-12 08:32:35 UTC |
Multivariate Circular Data using MNNTS Models
Description
A collection of utilities for the statistical analysis of multivariate circular data using distributions based on Multivariate Nonnegative Trigonometric Sums (MNNTS). The package includes functions for calculation of densities and distributions, for the estimation of parameters, and more.
Details
Package: | CircNNTSRmult |
Type: | Package |
Version: | 0.1.0 |
Date: | 2023-09-09 |
License: | GLP (>=2) |
Depends: | R (>= 3.5.0), stats, psychTools, CircNNTSR |
LazyLoad: | yes |
NeedsCompilation: | no |
The MNNTS (multivariate NNTS) density on a d-dimensional (d>2
) hypertorus by Fernandez-Duran and Gregorio-Dominguez (2014) (see also Fernandez-Duran and Gregorio-Dominguez, 2016) for a vector of angles, \underline{\Theta}=(\Theta_1,\Theta_2, \ldots, \Theta_d)^\top
, is defined as
f_{\underline{\Theta}}(\underline{\theta}) = \frac{1}{(2\pi)^d}\underline{c}_{12 \cdots d}^H\underline{e}\underline{e}^H\underline{c}_{12 \cdots d}
= \frac{1}{(2\pi)^d}\sum_{k_1=0}^{M_1}\sum_{k_2=0}^{M_2} \cdots \sum_{k_d=0}^{M_d}\sum_{m_1=0}^{M_1}\sum_{m_2=0}^{M_2} \cdots \sum_{m_d=0}^{M_d} c_{k_1 k_2 \cdots k_d}\bar{c}_{k_1 k_2 \cdots k_d}e^{\sum_{r=1}^d i(k_r-m_r)\theta_r} \nonumber \\
where \underline{c}_{12 \cdots d}
is a d
-dimensional parameter vector of complex numbers of dimension 2\prod_{r=1}^{d}(M_r+1) - 1
with subindexes given for all the combinations (Kronecker products) of the d
vectors \underline{M}_r=(0,1, \ldots, M_r)^\top
for r=1,2, \ldots, d
where M_r
is the number of terms of the sum in the equation for the r
-th component of the vector \underline{\Theta}
.
The vector \underline{c}_{12 \cdots d}
must satisfy
\underline{c}_{12 \cdots d}^H\underline{c}_{12 \cdots d}=||\underline{c}_{12 \cdots d}||^2=\sum_{k_1=0}^{M_1}\sum_{k_2=0}^{M_2} \cdots \sum_{k_d=0}^{M_d} ||c_{k_1k_2 \cdots k_d}||^2=1
.
For identifiabily, c_{00 \cdots 0}
is a nonnegative real number. The vector \underline{c}_{12 \cdots d}^H
is the Hermitian (conjugate and transpose) of vector \underline{c}_{12 \cdots d}
.
The MNNTS family has many desirable properties, the marginal and conditional densities of any order of an MNNTS density are also MNNTS densities and, independence among the elements of the vector \underline{\Theta}
is
translated into a Kronecker product decomposition in the parameter vector \underline{c}_{12 \cdots d}
. For example, in the trivariate case
\underline{\Theta}=(\Theta_1, \Theta_2, \Theta_3)^\top
, if \Theta_1
, \Theta_2
and \Theta_3
are joint independent then, \underline{c}_{123}=\underline{c}_{1} \bigotimes \underline{c}_{2} \bigotimes \underline{c}_{3}
where \underline{c}_1
, \underline{c}_2
and \underline{c}_3
are the parameter vectors of the NNTS marginal densities of \Theta_1
, \Theta_2
and \Theta_3
, respectively.
Similarly, if \Theta_1
is groupwise independent of (\Theta_2,\Theta_3)^\top
then, \underline{c}_{123}=\underline{c}_{1} \bigotimes \underline{c}_{23}
where \underline{c}_{23}
is the parameter vector
of the bivariate MNNTS density of (\Theta_2,\Theta_3)^\top
. These results apply to higher dimensions.
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Maintainer: Maria Mercedes Gregorio Dominguez <mercedes@itam.mx>
References
Fernandez-Duran, J. J. and Gregorio-Dominguez M. M. (2014) Modeling angles in proteins and circular genomes using multivariate angular distributions based on nonnegative trigonometric sums. Statistical Applications in Genetics and Molecular Biology, 13(1), 1-18.
Fernandez-Duran, J. J. and Gregorio-Dominguez, M. M. (2016). CircNNTSR: an R package for the statistical analysis of circular, multivariate circular, and spherical data using nonnegative trigonometric sums. Journal of Statistical Software, 70, 1–19.
Fernandez-Duran, J. J. and Gregorio-Dominguez, M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Minimun and Maximun daily exchange rates
Description
Minimun and maximun daily bid and ask exchange rates from Euro-US dollar, GB pound-US dollar, Bitcoin-US dollar from March 22, 2019 to March 22, 2023
Usage
data("EURUSDGBPBTCtimesminmax")
Format
A data frame with 1048 observations on the following 14 variables.
id
Observation number
day1
Date in format day/month/year
EURUSDAskMax
Daily maximum of ask Euro-US dollar exchange rate
EURUSDAskMin
Daily minimum of ask Euro-US dollar exchange rate
EURUSDBidMax
Daily maximum of bid Euro-US dollar exchange rate
EURUSDBidMin
Daily minimum of bid Euro-US dollar exchange rate
GBPUSDAskMax
Daily maximum of ask GB pound-US dollar exchange rate
GBPUSDAskMin
Daily minimum of ask GB pound-US dollar exchange rate
GBPUSDBidMax
Daily maximum of bid GB pound-US dollar exchange rate
GBPUSDBidMin
Daily minimum of bid GB pound-US dollar exchange rate
BTCUSDAskMax
Daily maximum of ask Bitcoin-US dollar exchange rate
BTCUSDAskMin
Daily minimum of ask Bitcoin-US dollar exchange rate
BTCUSDBidMax
Daily maximum of bid Bitcoin-US dollar exchange rate
BTCUSDBidMin
Daily minimum of bid Bitcoin-US dollar exchange rate
Source
Dukascopy publicly available tick-by-tick data
Nest orientations and creek directions
Description
Orientation of nests of 50 noisy scrub birds (theta) along the bank of a creek bed, together with the corresponding directions (phi) of creek flow at the nearest point to the nest.
Usage
data(Nest)
Format
Orientation of 50 nests (vectors)
Source
Data supplied by Dr. Graham Smith
References
N.I. Fisher (1993) Statistical analysis of circular data. Cambridge University Press.
Wind directions
Description
Wind directions registered at the monitoring stations of San Agustin located in the north, Pedregal in the southwest, and Hangares in the southeast of the Mexico Central Valley's at 14:00 on days between January 1, 1993 and February 29, 2000. There are a total of 1,682 observations
Usage
data(WindDirectionsTrivariate)
Format
Three columns of angles in radians
Source
Mexico Central Valleys pollution monitoring network. RAMA SIMAT (Red Automatica de Monitoreo Ambiental)
c Parameter Vector Estimate
Description
Computes the c parameter vector estimate based on the mean resultant vector of the vectors of observed trigonometric moments
Usage
mnntestimationresultantvector(data,M=0,R=1)
Arguments
data |
Data frame with the observed vectors of angles. The number of columns must be equal to R |
M |
Vector of M parameters. A nonnegative integer number for each of the R components of the vector |
R |
Number of dimensions |
Value
cestimates |
A matrix with the index and values of the c parameters estimates of the MNNTS density |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Examples
# A bivariate dataset
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
estmeanresultant<-mnntestimationresultantvector(data,M=Mbiv,R=Rbiv)
estmeanresultant
# A trivariate dataset
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
estmeanresultant<-mnntestimationresultantvector(data,M=Mtriv,R=Rtriv)
estmeanresultant
Characteristic Function of an MNNTS Density
Description
Computes the characteristic function from the c parameters of an MNNTS density
Usage
mnntscharacteristicfunction(cestimatesarray=as.data.frame(matrix(c(0,1/(2*pi)),
nrow=1,ncol=2)),M=0,R=1)
Arguments
cestimatesarray |
output from mnntsmanifoldnewtonestimation function |
M |
Vector of M parameters. A nonnegative integer number for each of the R components of the vector |
R |
Number of dimensions |
Value
A data frame (matrix) with the support and values of the characteristic function of the MNNTS density
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Examples
# A characteristic function from a bivariate MNNTS density
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
est<-mnntsmanifoldnewtonestimation(data,Mbiv,Rbiv,50)
est
charfunbiv23<-mnntscharacteristicfunction(cestimatesarray=est$cestimates,M=Mbiv,R=Rbiv)
charfunbiv23
# A characteristic function from a trivariate MNNTS density
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est<-mnntsmanifoldnewtonestimation(data,Mtriv,Rtriv,50)
est
charfuntriv233<-mnntscharacteristicfunction(cestimatesarray=est$cestimates,M=Mtriv,R=Rtriv)
charfuntriv233
Conditional MNNTS density
Description
Computes the c parameters of a conditional MNNTS density at a particular value of the conditioning random vector
Usage
mnntsconditional(cpars=as.data.frame(matrix(c(0,0,1/(2*pi)),nrow=1,ncol=3)),
M=c(0,0),R=2,cond=1,cond.values=0)
Arguments
cpars |
Matrix of parameters of an MNNTS density with the first R columns containing the index of the c parameter and the R+1 containing the complex parameter |
M |
Vector of M parameters. A nonnegative integer number for each of the R components of the vector |
R |
Number of dimensions |
cond |
A subset of 1:R indicating the elements of the vector of variables to conditioning on |
cond.values |
A vector of fixed values of the conditional elements of the random vector at which to conditioning on |
Value
param |
A matrix with the index and values of the c parameters for the MNNTS condtional density |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Examples
# A univariate conditional from a bivariate joint
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
est<-mnntsmanifoldnewtonestimation(data,Mbiv,Rbiv,100)
est
cpars2cond1<-mnntsconditional(cpars=est$cestimates,M=Mbiv,R=Rbiv,cond=1,cond.values=c(pi/2))
cpars2cond1
nntsplot(cpars2cond1$cpar.cond,M=Mbiv[2])
# A bivariate conditional from a trivariate joint
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est<-mnntsmanifoldnewtonestimation(data,Mtriv,Rtriv,100)
est
cpars23cond1<-mnntsconditional(cpars=est$cestimates,M=Mtriv,R=Rtriv,cond=1,cond.values=pi/4)
cpars23cond1
mnntsplot(cpars23cond1,M=Mtriv[c(2,3)])
mnntsplotwithmarginals(cpars23cond1,M=Mtriv[c(2,3)])
Design Matrix of the MNNTS Goodness of Fit Test
Description
Computes the design matrix of the auxiliary regression for the goodness of fit test of an MNNTS density based on the estimated characteristic function
Usage
mnntsgofdesignmatrix(data,charfunarray,R=1)
Arguments
data |
Matrix of angles in radians (with R columns) |
charfunarray |
A data frame (matrix) with the support and values of the characteristic function of the MNNTS density obtained by using the function mnntscharacteristic function with vector of parameters M of dimension R |
R |
Number of dimensions |
Value
A matrix that is the design matrix to run the auxiliary regression for the goodness of fit test
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Fan, Y. (1997). Goodness-of-fit tests for a multivariate distribution by the empirical characteristic function. Journal of Multivariate Analysis, 62, 36-63.
Examples
# A characteristic function from a bivariate MNNTS density
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
est<-mnntsmanifoldnewtonestimation(data,Mbiv,Rbiv,70)
est
charfunbiv23<-mnntscharacteristicfunction(cestimatesarray=est$cestimates,M=Mbiv,R=Rbiv)
charfunbiv23
designmatrix23<-mnntsgofdesignmatrix(data,charfunbiv23,R=2)
designmatrix23
# A characteristic function from a trivariate MNNTS density
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est<-mnntsmanifoldnewtonestimation(data,Mtriv,Rtriv,40)
est
charfuntriv233<-mnntscharacteristicfunction(cestimatesarray=est$cestimates,M=Mtriv,R=Rtriv)
charfuntriv233
designmatrix233<-mnntsgofdesignmatrix(data,charfuntriv233,R=3)
designmatrix233
Statistics of the MNNTS Goodness of Fit Test
Description
Computes the statistics of the goodness of fit test of an MNNTS density based on the estimated characteristic function
Usage
mnntsgofstatistics(data,charfunarray,R=1)
Arguments
data |
Matrix of angles in radians (with R columns) |
charfunarray |
A data frame (matrix) with the support and values of the characteristic function of the MNNTS density obtained by using the function mnntscharacteristicfunction with vector of parameters M of dimension R |
R |
Number of dimensions |
Value
gofstat |
The value of the goodness of fit statistic |
gofstatnormal |
The value of the normal approximation o fthe goodnes of fit statistic |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data,arXiv preprint arXiv:2301.03643v2
Fan, Y. (1997). Goodness-of-fit tests for a multivariate distribution by the empirical characteristic function. Journal of Multivariate Analysis, 62, 36-63.
Examples
# A characteristic function from a bivariate MNNTS density
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
est<-mnntsmanifoldnewtonestimation(data,Mbiv,Rbiv,70)
est
charfunbiv23<-mnntscharacteristicfunction(cestimatesarray=est$cestimates,M=Mbiv,R=Rbiv)
charfunbiv23
gofstats23<-mnntsgofstatistics(data,charfunbiv23,R=2)
gofstats23
# A characteristic function from a trivariate MNNTS density
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est<-mnntsmanifoldnewtonestimation(data,Mtriv,Rtriv,50)
est
charfuntriv233<-mnntscharacteristicfunction(cestimatesarray=est$cestimates,M=Mtriv,R=Rtriv)
charfuntriv233
gofstats233<-mnntsgofstatistics(data,charfuntriv233,R=3)
gofstats233
Mixing Probabilities of the Elements of the Mixture
Description
Computes the mixing probabilities (eigenvalues) and parameter c vectors (eigenvectors) of the elements of the mixture defining a general MNNTS marginal of any dimension from an MNNTS density
Usage
mnntsmarginalgeneral(cpars=as.data.frame(matrix(c(0,0,1/(2*pi)),nrow=1,ncol=3)),
M=c(0,0),R=2,marginal=1)
Arguments
cpars |
Matrix of parameters of an MNNTS density with the first R columns containing the index of the c parameter and the R+1 containing the complex parameter |
M |
Vector of M parameters. A nonnegative integer number for each of the R components of the vector |
R |
Number of dimensions |
marginal |
A subset of 1:R indicating the elements of the random vector in the marginal |
Value
index |
Matrix of the index of the marginal MNNTS density |
eigenvectors |
Matrix of the c parameter vectors of each element of the mixture. Each column is a parameter vector |
eigenvalues |
The vector of mixing probabilities |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Examples
# A univariate marginal from a bivariate joint
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
est<-mnntsmanifoldnewtonestimation(data,Mbiv,Rbiv,100)
est
cparsmarginal1<-mnntsmarginalgeneral(cpars=est$cestimates,M=Mbiv,R=Rbiv,marginal=1)
cparsmarginal1
# A bivariate marginal from a trivariate joint
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est<-mnntsmanifoldnewtonestimation(data,Mtriv,Rtriv,100)
est
cparsmarginal12<-mnntsmarginalgeneral(cpars=est$cestimates,M=Mtriv,R=Rtriv,marginal=c(1,2))
cparsmarginal12
Marginal Density Function at a Vector of Fixed Values
Description
Computes the value of the marginal density function at a set of vector of angles
Usage
mnntsmarginalgeneraldimension(cpars=as.data.frame(matrix(c(0,0,1/(2*pi)),nrow=1,
ncol=3)),M=c(0,0),R=2,marginal=1,theta=matrix(0,nrow=1,ncol=1))
Arguments
cpars |
Matrix of parameters of an MNNTS density with the first R columns containing the index of the c parameter and the R+1 containing the complex parameter |
M |
Vector of M parameters. A nonnegative integer number for each of the R components of the vector |
R |
Number of dimensions |
marginal |
A subset of 1:R indicating the elements of the vector of variables in the marginal |
theta |
A vector of fixed values of the marginal elements of the random vector at which to obtain the value of the marginal density |
Value
A scalar with the value of the marginal density at the specified value of the marginal vector.
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions f
Examples
# A univariate marginal from a bivariate joint
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,Mbiv,Rbiv,100)
est
marginal1value<-mnntsmarginalgeneraldimension(cpars=est$cestimates,
M=Mbiv,R=Rbiv,marginal=1,theta=matrix(c(pi/2),nrow=1,ncol=1))
marginal1value
# A bivariate marginal from a trivariate joint
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est<-mnntsmanifoldnewtonestimation(data,Mtriv,Rtriv,100)
est
marginal12value<-mnntsmarginalgeneraldimension(cpars=est$cestimates,
M=Mtriv,R=Rtriv,marginal=c(1,2),theta=matrix(c(pi/4,pi/2),nrow=1,ncol=2))
marginal12value
Marginal Density Function at a Vector of Fixed Values
Description
Computes the vector of c parameters of an MNNTS density from the vectors of c parameters of its independent marginals
Usage
mnntsparametersunderindependenceunivariate(data,R,Mvector,cparlist)
Arguments
data |
Matrix of angles in radians (with R columns) |
R |
Number of dimensions |
Mvector |
Vector of M parameters. A nonnegative integer number for each of the R components of the vector |
cparlist |
A list in which each element is a matrix containing the information of the vector of c parameters for each independent marginal component |
Value
cestimates |
Matrix of prod(M+1)*(R+1). The first R columns are the parameter number, and the last column is the c parameter's estimators |
loglik |
Log-likelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2023). Multivariate Nonnegative Trigonometric Sums Distributions for High-Dimensional Multivariate Circular Data, arXiv preprint arXiv:2301.03643v2
Examples
# Bivariate MNNTS density from independent marginals
set.seed(200)
Mbiv<-c(2,3)
Rbiv<-length(Mbiv)
data(Nest)
data<-Nest*(pi/180)
est1<-nntsmanifoldnewtonestimation(data[,1],Mbiv[1])
est1
est2<-nntsmanifoldnewtonestimation(data[,2],Mbiv[2])
est2
est12independent<-mnntsparametersunderindependenceunivariate(data,R=Rbiv,
Mvector=Mbiv,cparlist=list(est1,est2))
est12independent
# Trivariate MNNTS density from independent marginals
set.seed(200)
Mtriv<-c(2,3,3)
Rtriv<-length(Mtriv)
data(WindDirectionsTrivariate)
data<-WindDirectionsTrivariate
est1<-nntsmanifoldnewtonestimation(data[,1],Mtriv[1],70)
est1
est2<-nntsmanifoldnewtonestimation(data[,2],Mtriv[2],70)
est2
est3<-nntsmanifoldnewtonestimation(data[,3],Mtriv[3],70)
est3
est123independent<-mnntsparametersunderindependenceunivariate(data,R=Rtriv,
Mvector=Mtriv,cparlist=list(est1,est2,est3))
est123independent