Type: | Package |
Title: | Statistical Analysis of Circular Data using Nonnegative Trigonometric Sums (NNTS) Models |
Version: | 2.3 |
Date: | 2023-08-31 |
Author: | Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez |
Maintainer: | Maria Mercedes Gregorio-Dominguez <mercedes@itam.mx> |
Description: | Includes functions for the analysis of circular data using distributions based on Nonnegative Trigonometric Sums (NNTS). The package includes functions for calculation of densities and distributions, for the estimation of parameters, for plotting and more. |
Depends: | stats |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
LazyLoad: | yes |
NeedsCompilation: | no |
Packaged: | 2023-09-01 02:43:42 UTC; mercedesgregorio |
Repository: | CRAN |
Date/Publication: | 2023-09-01 04:20:02 UTC |
CircNNTSR: An R Package for the statistical analysis of circular data using nonnegative trigonometric sums (NNTS) models
Description
A collection of utilities for the statistical analysis of circular and spherical data using nonnegative trigonometric sum (NNTS) models
Details
Package: | CircNNTSR |
Type: | Package |
Version: | 2.2-1 |
Date: | 2020-02-16 |
License: | GLP (>=2) |
LazyLoad: | yes |
Fernandez-Duran, J.J. (2004) proposed a new family of distributions for circular random variables based on nonnegative trigonometric sums. This package provides functions for working with circular distributions based on nonnegative trigonometric sums, including functions for estimating the parameters and plotting the densities.
The distribution function in this package is a circular distribution based on
nonnegative trigonometric sums (Fernandez-Duran, 2004). Fejer (1915)
expressed a univariate nonnegative trigonometric (Fourier) sum (series), for a variable
\theta
, as the squared modulus of a sum of complex numbers, i.e.,
\left\|\sum_{k=0}^M c_ke^{ik\theta}\right\|^2\;\;\; (1)
where i=\sqrt{-1}
. From this result, the parameters (a_k,b_k)
for k=1,\ldots, M
of the trigonometric sum of order M
,T(\theta)
,
T(\theta)=a_0 + \sum_{k=1}^M(a_kcos(k\theta) + b_ksin(k\theta))
are expressed in terms of the complex parameters in Equation 1
, c_k
, for k=0,\ldots, M
, as a_k - ib_k=
2\sum_{\nu=0}^{n-k}c_{\nu + k}\overline{c}_{\nu}
. The additional constraint, \sum_{k=0}^n\left\|c_k\right\|^2=\frac{1}{2\pi}=a_0
, is imposed
to make the trigonometric sum to integrate one. Thus, c_0
must be real and positive, and there are 2*M free parameters. Then, the probability
density function for a circular (angular) random variable is defined
as (Fernandez-Duran, 2004)
f(\theta; \underline{a},\underline{b},M)=\frac{1}{2\pi} + \frac{1}{\pi}\
\sum_{k=1}^M(a_kcos(k\theta) + b_ksin(k\theta)).
Note that Equation 1 can also be expressed as a double sum as
\sum_{k=0}^{M}\sum_{m=0}^{M}c_k\bar{c}_me^{i(k-m)\theta}
.
The \underline{c}
parameters can also be expressed in polar coordinates as c_k=\rho_k e^{i\phi_k}
for \rho_k \geq 0
and \phi_k \in [0,2\pi)
; where \rho_k
is the modulus of c_k
and \phi_k
is the argument of c_k
for k=1,\ldots,M
.
Many functions of the packages use as parameters the squared moduli and the arguments of c_k
, \rho_k^2
and \phi_k
, for k=1,\ldots,M
. We refer to the parameter M
as the number of components in the NNTS.
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Maintainer: Maria Mercedes Gregorio Dominguez <mercedes@itam.mx>
References
Fernandez-Duran, J.J. (2004). Circular Distributions Based on Nonnegative Trigonometric Sums, Biometrics, 60(2), 499-503.
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2010). A Likelihood-Ratio Test for Homogeneity in Circular Data. Journal of Biometrics & Biostatistics, 1(3), 107. doi:10.4172/2155-6180.1000107
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2010). Maximum Likelihood Estimation of Nonnegative Trigonometric Sums Models Using a Newton-Like Algorithm on Manifolds. Electronic Journal of Statistics, 4, 1402-1410. doi:10.1214/10-ejs587
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2014). Distributions for Spherical Data Based on Nonnegative Trigonometric Sums. Statistical Papers, 55(4), 983-1000. doi:10.1007/s00362-013-0547-5
Fernandez-Duran, J.J., 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. doi:10.1515/sagmb-2012-0012
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2014). Testing for Seasonality Using Circular Distributions Based on Nonnegative Trigonometric Sums as Alternative Hypotheses. Statistical Methods in Medical Research, 23(3), 279-292. doi:10.1177/0962280211411531.
Juan Jose Fernandez-Duran, Maria Mercedes Gregorio-Dominguez (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(6), 1-19. doi:10.18637/jss.v070.i06
Examples
set.seed(200)
data(Turtles_radians)
#Empirical analysis of data
Turtles_hist<-hist(Turtles_radians,breaks=10,freq=FALSE)
#Estimation of the NNTS density with 3 componentes for data
est<-nntsmanifoldnewtonestimation(Turtles_radians,3,iter=100)
est
#plot the estimated density
nntsplot(est$cestimates[,2],3)
#add the histogram to the estimated density plot
plot(Turtles_hist, freq=FALSE, add=TRUE)
b<-c(runif(10,3*pi/2,2*pi-0.00000001),runif(10,pi/2,pi-0.00000001))
estS<-nntsestimationSymmetric(2,b)
nntsplotSymmetric(estS$coef,2)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
cest<-est$cestimates
mnntsplot(cest, M)
Movements of ants
Description
Directions chosen by 100 ants in response to an evenly illuminated black target.
Usage
data(Ants)
Format
Directions chosen by 100 ants in degrees
Source
Randomly selected values by Fisher (1993) from Jander (1957)
References
N.I. Fisher (1993) Statistical analysis of circular data. Cambridge University Press.
Movements of ants
Description
Direction chosen by 100 ants in response to an evenly illuminated black target.
Usage
data(Ants_radians)
Format
Directions chosen by 100 ants in radians
Source
Randomly selected values by Fisher (1993) from Jander (1957)
References
N.I. Fisher (1993) Statistical analysis of circular data. Cambridge University Press.
Spherical Data on Magnetic Remanence
Description
Measurements of magnetic remanence from 52 specimens of red beds from the Bowen Basin, Queensland.
Usage
data(DataB5FisherSpherical)
Format
Declination -inclination in degrees
Source
P.W. Schmidt
References
Fisher N.I., Lewis T. and Embleton B.J.J. (1987) Statistical Analysis of Spherical Data. Cambridge University Press, Cambridge. Data B.5.
Examples
data(DataB5FisherSpherical)
Uniform Bivariate Circular Data
Description
200 realizations of a uniform distribution on the torus
Usage
data(DataUniformBivariate200obs)
Format
Angles in radians
Database B3 from Fisher
Description
Database B3 from Fisher et al. (1987)
Usage
data(Datab3fisher)
Format
Datab3fisher
Details
The dataset Datab3fisher consists of 148 observations of the arrival directions of low-mu showers of cosmic rays (Toyoda et al., 1965; see Fisher et al., 1987, pp. 280-281). The observations are measured in declination and right ascension coordinates.
Source
Fisher, et al. (1987)
References
Toyoda, Y., Suga, K., Murakami, K., Hasegawa, H.,
Shibata, S., Domingo, V., Escobar, I., Kamata, K., Bradt, H.,
Clark, G. and La Pointe, M. (1965). Studies of Primary Cosmic Rays
in the Energy Region 10^{14}
eV to 10^{17}
eV (Bolivian Air
Shower Joint Experiment), Proceedings of the International
Conference on Cosmic Rays, vol. 2,
London, September, 1965, 708–711. London: The Institute of
Physics and the Physical Society.
Fisher, N.I., Lewis, T. and Embleton, B.J.J. (1987). Statistical Analysis of Spherical Data, Cambridge U.K.: Cambridge University Press.
Data transformed from Datab3fisher
Description
Data transformed from Datab3fisher
Usage
data(Datab3fisher_ready)
Format
Datab3fisher_ready
Details
datab3fisher[,2] <- 90 + datab3fisher[,2]; datab3fisher_ready <- datab3fisher*(pi/180)
Database B6 from Fisher et al. (1987)
Description
datab6fisher
Usage
data(Datab6fisher)
Format
The coordinates are declination and inclination measured in degrees
Details
The data-set Datab6fisher contains 107 measurements of magnetic remanence in samples of Precambrian volcanics collected in Northwest Australia. (Schmidt and Embleton, 1985; see Fisher et al., 1987, pp. 285).
Source
Fisher, et al. (1987)
References
Schmidt, P.W. and Embleton, B.J.J. (1985). Pre-folding and overprint magnetic signatures in Precambrian (~2.9-2.7ga) igneous rocks from the Pilbara Craton and Hamersley Basin, N.W. Australia, Journal of Geophysical Research, 90 (B4), 2967–2984.
Fisher, N.I., Lewis, T. and Embleton, B.J.J. (1987). Statistical Analysis of Spherical Data, Cambridge U.K.: Cambridge University Press.
Data transformed from datab6fisher
Description
Data transformed from datab6fisher
Usage
data(Datab6fisher_ready)
Format
Datab6fisher_ready
Details
dataaux <- datab6fisher; datab6fisher[,1] <- dataaux[,2]; datab6fisher[,2] <- dataaux[,1]; datab6fisher[,1] <- 360 - datab6fisher[,1]; datab6fisher[,2] <- 90 + datab6fisher[,2]; datab6fisher_ready <- datab6fisher*(pi/180)
Date of Occurrence of Earthquakes
Description
The time of occurrence of earthquakes of intensity greater than 6.0^o
Richter with an epicenter occurring in the coast
of the Pacific Ocean in Mexico from 1920 to 2002.
There is a total of 241 observations.
Usage
data(EarthquakesPacificMexicogt6)
Format
Time in years. All observations in the interval (0,1]
Source
Mexican Database of Strong Earthquakes. CENAPRED.
Date of Occurrence of Earthquakes 2
Description
The time of occurrence of earthquakes of intensity greater than 7.0^o
Richter with an epicenter occurring in the coast
of the Pacific Ocean in Mexico from 1920 to 2002.
There are a total of 76 observations.
Usage
data(EarthquakesPacificMexicogt7)
Format
Time in years. All observations in the interval (0,1]
Source
Mexican Database of Strong Earthquakes. CENAPRED.
Homicides in Mexico during 2005
Description
Monthly number of homicides in Mexico during 2005
Usage
data(HomicidesMexico2005)
Format
Integer values
Source
INEGI (Mexican National Statistical Agency) www.inegi.gob.mx
Hurricanes in Mexico from 1951 to 1970
Description
The time of occurrence (starting times) of hurricanes in the Gulf of Mexico for the 1951-1970 period. There are a total of 196 observations.
Usage
data(HurricanesGulfofMexico1951to1970)
Format
Time in years. All observations in the interval (0,1]
Source
http://weather.unisys.com/hurricane/atlantic/1978/index.html
Hurricanes in Mexico from 1971 to 2008
Description
The time of occurrence (starting times) of hurricanes in the Gulf of Mexico for the 1971-2008 period. There are a total of 417 observations
Usage
data(HurricanesGulfofMexico1971to2008)
Format
Time in years. All observations in the interval (0,1]
Source
http://weather.unisys.com/hurricane/atlantic/1978/index.html
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.
Dihedral angles in protein
Description
Dataset of the dihedral angles in a protein between three consecutive Alanine (Ala) amino acids. This dataset was constructed from the recommended July 2003 list of proteins via the algorithm in Hobohm et al. (1992). This algorithm selects a representative sample of proteins from the vast Protein Data Bank (PDB, Berman et al., 2000). The dataset contains 233 pairs of dihedral angles.
Usage
data(ProteinsAAA)
Format
Two columns of angles in radians
Source
Protein Data Bank (PDB)
References
Hobohm, U. and Scharf, M. and Schneider, R. and Sander, C. (1992) Selection of a Representative Set of Structures from the Brookhaven Protein Data Bank, Protein Science, 1, 409-417. Berman, H. M. and Westbrook, J. and Feng, Z. and Gilliand, G. and Bhat, T. N. and Weissing, H. and Shyndialov, I. N. and Bourne, P. E. (2000) The Protein Data Bank, Nucleic Acids Research, 28, 235-242.
Suicides in Mexico during 2005
Description
Monthly number of suicides in Mexico during 2005
Usage
data(SuicidesMexico2005)
Format
Integer values
Source
INEGI (Mexican National Statistical Agency) www.inegi.gob.mx
Movements of turtles
Description
Data measurement of the directions taken by 76 turtles after treatment
Usage
data(Turtles)
Format
Directions of turtles in degrees
Source
Stephens (1969) Techniques for directional data. Technical Report 150. Dept. of Statistics, Stanford University. Stanford, CA.
References
N.I. Fisher (1993) Statistical analysis of circular data. Cambridge University Press.
Movements of turtles
Description
Data measurement of the directions taken by 76 turtles after treatment
Usage
data(Turtles_radians)
Format
Directions of turtles in radians
Source
Stephens (1969) Techniques for directional data. Technical Report 150. Dept. of Statistics, Stanford University. Stanford, CA.
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)
MNNTS density function
Description
Density function for the MNNTS model
Usage
mnntsdensity(data, cpars = 1/sqrt(2 * pi), M = 0, R=1)
Arguments
data |
Matrix of angles in radians, a column for each dimension, a row for each data point |
cpars |
Parameters of the model. A vector of complex numbers of dimension prod(M+1). The first
element is a real and positive number. The first M[1]+1 elements correspond to dimension one, the next M[2]+1
elements correspond to dimension two, and so on. The sum of the SQUARED moduli of the c parameters must be
equal to |
M |
Vector of length R with number of components in the MNNTS for each dimension |
R |
Number of dimensions |
Value
The function returns the density function evaluated at each row in data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Juan Jose Fernandez-Duran, Maria Mercedes Gregorio-Dominguez (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(6), 1-19. doi:10.18637/jss.v070.i06
Examples
set.seed(200)
M<-c(2,3)
R<-length(M)
data<-c(0,pi,pi/2,pi,pi,3*pi/2,pi,2*pi,2*pi,pi)
data<-matrix(data,ncol=2,byrow=TRUE)
data
ccoef<-mnntsrandominitial(M,R)
mnntsdensity(data,ccoef,M,R)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
ccoef<-est$cestimates[,3]
mnntsdensity(data,ccoef,M,R)
MNNTS density function (the particular case has two dimensions)
Description
Density function for the MNNTS model (the particular case has two dimensions). This is an internal function used by mnntsplot
Usage
mnntsdensity2d(x,y, cpars,M)
Arguments
x |
Vector of angles in radians |
y |
Vector of angles in radians |
cpars |
Parameters of the model. A vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The first M[1]+1 elements correspond to dimension one, the next M[2]+1 elements correspond to dimension two. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Vector of length two with the number of components in the MNNTS for each dimension |
Value
The function returns the density function evaluated at each row in data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
MNNTS log-likelihood function
Description
Computes the log-likelihood function with MNNTS density for data
Usage
mnntsloglik(data, cpars = 1/sqrt(2 * pi), M = 0, R = 1)
Arguments
data |
Matrix of angles in radians, a column for each dimension, a row for each data point. |
cpars |
Parameters of the model. A vector of complex numbers of dimension prod(M+1). The first element is a real and positive number.
The first M[1]+1 elements correspond to dimension one, next M[2]+1 elements correspond to dimension two, and so on.
The sum of the SQUARED moduli of the c parameters must be equal to |
M |
Vector of length R with number of components in the MNNTS for each dimension. |
R |
Number of dimensions. |
Value
The function returns the value of the log-likelihood function for the data.
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Examples
M<-c(2,3)
R<-length(M)
data<-c(0,pi,pi/2,pi,pi,3*pi/2,pi,2*pi,2*pi,pi)
data<-matrix(data,ncol=2,byrow=TRUE)
data
ccoef<-mnntsrandominitial(M,R)
mnntsdensity(data,ccoef,M,R)
mnntsloglik(data,ccoef,M,R)
Parameter estimation for the MNNTS distributions
Description
Computes the maximum likelihood estimates of the MNNTS parameters using a Newton algorithm on the hypersphere
Usage
mnntsmanifoldnewtonestimation(data,M=0,R=1,iter=1000,initialpoint=FALSE,cinitial)
Arguments
data |
Matrix of angles in radians, a column for each dimension, a row for each data point |
M |
Vector of length R with number of components in the MNNTS for each dimension |
R |
Number of dimensions |
iter |
Number of iterations for the Newton algorithm |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
Initial value for cpars (parameters of the model) for the optimization algorithm.
Vector of complex numbers of dimension prod(M+1). The first element is a real and positive number.
The first M[1]+1 elements correspond to dimension one, the next M[2]+1 elements correspond to dimension two, and so on.
The sum of the SQUARED moduli of the c parameters must be equal to |
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 |
Optimum log-likelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
gradnormerror |
Gradient error after the last iteration |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Fernandez-Duran, J.J., 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. doi:10.1515/sagmb-2012-0012
Examples
set.seed(200)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest*(pi/180)
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
Marginal density function of the MNNTS model
Description
Marginal density function for one dimension of the MNNTS model evaluated at a point
Usage
mnntsmarginal(cestimatesarray, M, component, theta)
Arguments
cestimatesarray |
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 |
M |
Vector of length R with number of components in the MNNTS for each dimension |
component |
Number of the dimension for computing the marginal |
theta |
An angle in radians (or a vector of angles) |
Value
The function returns the density function evaluated at theta
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Fernandez-Duran, J.J., 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. doi:10.1515/sagmb-2012-0012
Examples
set.seed(200)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
cest<-est$cestimates
mnntsmarginal(cest,M,1,pi)
Plots an MNNTS bivariate density
Description
Plots the MNNTS bivariate density function
Usage
mnntsplot(cestimates, M, ...)
Arguments
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. R=2 for a bivariate distribution |
M |
Vector with the number of components in the MNNTS for each dimension |
... |
Arguments passed to the function plot |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Fernandez-Duran, J.J., 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. doi:10.1515/sagmb-2012-0012
Examples
set.seed(200)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
cest<-est$cestimates
mnntsplot(cest, M)
Plots an MNNTS marginal density
Description
Plots the MNNTS marginal density function
Usage
mnntsplotmarginal(cestimates, M, component, ...)
Arguments
cestimates |
Matrix of prod(M+1)*(R+1). The first R columns are the parameter number, and the last column the c parameter's estimators. The matrix could be the output of mnntsmanifoldnewtonestimation $cestimates |
M |
Vector with number of components in the MNNTS for each dimension |
component |
Number of the dimension for computing the marginal density |
... |
Arguments passed to the function plot |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Fernandez-Duran, J.J., 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. doi:10.1515/sagmb-2012-0012
Examples
set.seed(200)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
cest<-est$cestimates
mnntsplotmarginal(cest, M, 1)
mnntsplotmarginal(cest, M, 2)
Plots an MNNTS bivariate density together with the marginals
Description
Plots the MNNTS bivariate density function together with the marginals
Usage
mnntsplotwithmarginals(cestimates, M, ...)
Arguments
cestimates |
Matrix of prod(M+1)*(R+1). The first R columns are the parameter number, and the last column the c parameter's estimators. The matrix could be the output of mnntsmanifoldnewtonestimation $cestimates. |
M |
Vector of length R with number of components in the MNNTS for each dimension |
... |
Arguments passed to the function plot |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Fernandez-Duran, J.J., 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. doi:10.1515/sagmb-2012-0012
Examples
set.seed(200)
M<-c(2,3)
R<-length(M)
data(Nest)
data<-Nest
est<-mnntsmanifoldnewtonestimation(data,M,R,100)
est
cest<-est$cestimates
mnntsplotwithmarginals(cest, M)
Initial random point
Description
This function generates a random point on the surface of the prod(M+1)-dimensional unit hypersphere
Usage
mnntsrandominitial(M = 1, R = 1)
Arguments
M |
Vector of length R with number of components in the MNNTS for each dimension |
R |
Number of dimensions |
Value
Returns a valid initial point for estimation functions
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Examples
M<-c(2,3)
R<-length(M)
mnntsrandominitial(M,R)
MNNTS density simulation function
Description
Simulation for the density function for the MNNTS model
Usage
mnntssimulation(nsim=1, cpars = 1/(2 * pi), M = c(0,0), R=2)
Arguments
nsim |
Number of simulations |
cpars |
Parameters of the model. A vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The first M[1]+1 elements correspond to dimension one, next M[2]+1 elements correspond to dimension two, and so on. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Vector of length R with number of components in the MNNTS for each dimension |
R |
Number of dimensions |
Value
simulations |
The function generates nsim random values from the MNNTS density function |
conteo |
Number of uniform random numbers used for simulations |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. and Gregorio-Dominguez, M.M. (2009) Multivariate Angular Distributions Based on Multiple Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C09.1
Examples
M<-c(2,3)
R<-length(M)
ccoef<-mnntsrandominitial(M,R)
data<-mnntssimulation(10,ccoef,M,R)
data
Density function with AB coefficients
Description
Density function expressed in terms of the ab parameters at theta
Usage
nntsABDensity(theta, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
theta |
Vector of angles in radians |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi) |
M |
Number of components in the NNTS |
Value
Returns the density function in terms of the ab coefficients evaluated at theta
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
ccoef<-nntsrandominitial(3)
nntsABDensity(1,ccoef,3)
nntsABDensity(1+2*pi,ccoef,3)
Density function with AB coefficients
Description
Density function expressed in terms of the ab parameters at theta
Usage
nntsABDensitySymmetric(cpars = c(0, 0), M = 0, theta)
Arguments
theta |
Vector of angles in radians |
cpars |
Vector of complex numbers of dimension 2*M |
M |
Number of components in the NNTS |
Value
Returns the density function in terms of the ab coefficients evaluated at theta
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
AB coefficients
Description
This function transforms the complex parameters c to the parameters ab for a reparameterization of the density function
Usage
nntsABcoefficients(cpars = 1/sqrt(2 * pi), M = 0)
Arguments
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the parameters ab associated with the parameters cpars and returns a vector of real numbers of size 2*M, where the first M elements are the a_k, k=1,...,M, and the next M elements are the b_k, k=1,...,M
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
#random generation of c parameters
ccoef<-nntsrandominitial(3)
ccoef
ab<-nntsABcoefficients(ccoef,3)
ab
AB coefficients
Description
This function transforms the complex parameters c to the parameters ab for a reparameterization of the density function
Usage
nntsABcoefficientsSymmetric(cpars = c(0,0), M = 0)
Arguments
cpars |
Vector of complex numbers of dimension 2*M |
M |
Number of components in the NNTS |
Value
The function returns the parameters ab associated with the pararameters cpars
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
NNTS density function for a variable defined in the interval [0,1)
Description
Computes the density function at theta for a variable defined in the interval [0,1))
Usage
nntsDensityInterval0to1(S, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
S |
Vector of values defined in the interval [0,1) at which the density function is computed |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to 1/(2*pi) |
M |
Number of components in the NNTS |
Details
This function computes the density function of a variable S (S in the interval [0,1)). If theta is defined in radians (theta in the interval [0,2*pi)), the relation between S and theta is theta=2*pi*S.
Value
Value of the density function at each component of S
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
ccoef<-nntsrandominitial(3)
nntsDensityInterval0to1(c(.8,1.8),ccoef,3)
NNTS Distribution function
Description
Cumulative distribution function in terms of the c parameters at theta, measured in radians [0,2*pi).
Usage
nntsDistribution(theta, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
theta |
Vector of angles in radians at which the distribution is computed |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the value of the distribution function evaluated at each component of theta
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
ccoef<-nntsrandominitial(3)
nntsDistribution(c(0,pi/2,pi,2*pi-0.00000001,2*pi),ccoef,3)
NNTS distribution function for the incidence data defined in the interval [0,1)
Description
Computes the distribution function at theta for the incidence data (number of observed values in certain intervals defined in the interval [0,1))
Usage
nntsDistributioninterval0to1(theta, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
theta |
Value at which the distribution function is computed |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the value of the distribution function at theta
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
cpars<-nntsrandominitial(2)
nntsDistributioninterval0to1(pi, cpars, 2)
NNTS distribution function for data defined in the interval [0,2*pi)
Description
Computes the distribution function for the data at theta
Usage
nntsDistributioninterval0to2pi(theta, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
theta |
Value at which the distribution function is computed |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the value of the distribution function at theta
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
cpars<-nntsrandominitial(3)
nntsDistributioninterval0to2pi(0, cpars, 3)
nntsDistributioninterval0to2pi(pi, cpars, 3)
nntsDistributioninterval0to2pi(2*pi-0.00000001, cpars, 3)
nntsDistributioninterval0to2pi(2*pi, cpars, 3)
nntsDistributioninterval0to2pi(3*pi, cpars, 3)
Symmetric NNTS density function
Description
Density function for the Symmetric NNTS
Usage
nntsSymmetricDensity(cpars = c(0, 0), M = 0, theta)
Arguments
cpars |
Vector of real numbers of dimension 2*M. The first M numbers are the squared moduli of the c parameters. The sum must be less than 1/(2*pi). The last number is the mean of symmetry |
M |
Number of components in the NNTS |
theta |
Angle in radians |
Value
The function returns the density function evaluated at theta
Note
The default values provide the uniform circular density
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2009) Symmetric Circular Distributions Based on Nonnegative Trigonometric Sums. Working Paper, DE-C09.12, Department of Statistics, ITAM, Mexico
NNTS density function
Description
Density function for the NNTS model
Usage
nntsdensity(data, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
data |
Vector of angles in radians |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the density function evaluated at each point in data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. (2004). Circular Distributions Based on Nonnegative Trigonometric Sums, Biometrics, 60(2), 499-503.
Juan Jose Fernandez-Duran, Maria Mercedes Gregorio-Dominguez (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(6), 1-19. doi:10.18637/jss.v070.i06
Examples
ccoef<-nntsrandominitial(3)
nntsdensity(1,ccoef,3)
nntsdensity(1+pi,ccoef,3)
nntsdensity(c(1,1+pi),ccoef,3)
NNTS Symmetric Coefficient estimation
Description
Computes the maximum likelihood estimates of the symmetric NNTS parameters
Usage
nntsestimationSymmetric(M = 0, data, maxit = 500)
Arguments
M |
Number of components in the NNTS |
data |
Vector of angles in radians |
maxit |
Maximum number of iterations in the optimization algorithm |
Value
coef |
Vector of length M+1. The first M components are the squared moduli of the c parameters, and the last number is the mean of symmetry |
loglik |
Optimum log-likelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
convergence |
An integer code: zero indicates successful convergence; error codes are the following: one indicates that the iteration limit maxit has been reached, and 10 indicates degeneracy of the Nelder-Mead simplex |
Note
For the maximization of the loglikelihood function the function constrOptim from the package stats is used
Author(s)
Juan Jose Fernandez-Duran y Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2009) Symmetric Circular Distributions Based on Nonnegative Trigonometric Sums. Working Paper, DE-C09.12, Department of Statistics, ITAM, Mexico
Examples
b<-c(runif(10,3*pi/2,2*pi-0.00000001),runif(10,pi/2,pi-0.00000001))
estS<-nntsestimationSymmetric(2,b)
nntsplotSymmetric(estS$coef,2)
NNTS log-likelihood function
Description
Computes the log-likelihood function with NNTS density for data
Usage
nntsloglik(data, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
data |
Vector with observed angles in radians. |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the value of the log-likelihood function for the data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J. (2004). Circular Distributions Based on Nonnegative Trigonometric Sums, Biometrics, 60(2), 499-503.
Examples
a<-c(runif(10,3*pi/2,2*pi-0.00000001),runif(10,pi/2,pi-0.00000001))
est<-nntsmanifoldnewtonestimation(a,2)
ccoef<-est$cestimates[,2]
nntsloglik(a,ccoef,2)
NNTS log-likelihood function for the incidence data defined in the interval [0,1)
Description
Computes the log-likelihood function for incidence data (number of observed values in certain intervals defined in the interval [0,1))
Usage
nntsloglikInterval0to1(data, cutpoints, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
data |
Number of observations in each interval |
cutpoints |
Vector of size length(data)+1 with the limits of the intervals |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
Value
The function returns the value of the log-likelihood function for data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
data<-c(1,2,6,4,1)
cutpoints<-c(0,0.2,0.4,0.6,0.8,0.9999999)
cpars<-nntsrandominitial(1)
nntsloglikInterval0to1(data, cutpoints, cpars, 1)
NNTS log-likelihood function for the incidence data defined in the interval [0,2*pi)
Description
Computes the log-likelihood function for incidence data (number of observed values in certain intervals defined in the interval [0,2*pi))
Usage
nntsloglikInterval0to2pi(data, cutpoints, cpars = 1/sqrt(2 * pi), M = 0)
Arguments
data |
Number of observations in each interval |
cutpoints |
Vector of size length(data)+1 with the limits of the exhaustive and mutually exclusive intervals in which the interval [0,2*pi) is divided. |
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS density |
Value
The function returns the value of the log-likelihood function for the data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
data<-c(2,3,6,4)
cutpoints<-c(0,pi/2,pi,3*pi/2,2*pi-0.00000001)
est<-nntsmanifoldnewtonestimationinterval0to2pi(data,cutpoints,M=1)
cpars<-est$cestimates[,2]
nntsloglikInterval0to2pi(data,cutpoints,cpars,M=1)
NNTS symmetric log-likelihood function
Description
Computes the log-likelihood function with NNTS symmetric density for the data
Usage
nntsloglikSymmetric(cpars = c(0, 0), M = 0, data)
Arguments
cpars |
Vector of real numbers of dimension M+1. The first M numbers are the squared moduli of the c parameters. The sum must be less than 1/(2*pi). The last number is the mean of symmetry |
M |
Number of components in the NNTS |
data |
Vector with angles in radians. The first column is used if data are a matrix |
Value
The function returns the value of the log-likelihood function for the data
Note
The default values provide the Uniform circular log-likelihood for the data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2009) Symmetric Circular Distributions Based on Nonnegative Trigonometric Sums. Working Paper, DE-C09.12, Department of Statistics, ITAM, Mexico
Examples
nntsloglikSymmetric(c(.01,.02,2),2,t(c(pi,pi/2,2*pi,pi)))
Parameter estimation for NNTS distributions
Description
Computes the maximum likelihood estimates of the NNTS parameters, using a Newton algorithm on the hypersphere
Usage
nntsmanifoldnewtonestimation(data, M=0, iter=1000, initialpoint = FALSE, cinitial)
Arguments
data |
Vector of angles in radians |
M |
Number of components in the NNTS |
iter |
Number of iterations |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
Vector of size M+1. The first element is real and the next M elements are complex (values for $c_0$ and $c_1, ...,c_M$). The sum of the squared moduli of the parameters must be equal to 1/(2*pi) |
Value
cestimates |
Matrix of (M+1)x2. The first column is the parameter numbers, and the second column is the c parameter's estimators |
loglik |
Optimum log-likelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
gradnormerror |
Gradient error after the last iteration |
Author(s)
Juan Jose Fernandez-Duran y Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2010). Maximum Likelihood Estimation of Nonnegative Trigonometric Sums Models by Using a Newton-like Algorithm on Manifolds, Working Paper, Department of Statistics, ITAM, DE-C10.8
Examples
set.seed(200)
a<-c(runif(10,3*pi/2,2*pi-0.00000001),runif(10,pi/2,pi-0.00000001))
#Estimation of the NNTSdensity with 2 components for data and 200 iterations
nntsmanifoldnewtonestimation(a,2,iter=200)
data(Turtles_radians)
#Empirical analysis of data
Turtles_hist<-hist(Turtles_radians,breaks=10,freq=FALSE)
#Estimation of the NNTS density with 3 componentes for data
nntsmanifoldnewtonestimation(Turtles_radians,3,iter=200)
Maximum likelihood estimates of the NNTS parameters
Description
Computes the maximum likelihood estimates of the NNTS parameters, using a Newton algorithm on the hypersphere with the option to specify a minimum value of the norm of the gradient error to stop the algorithm
Usage
nntsmanifoldnewtonestimationgradientstop(data, M = 0, iter = 1000, initialpoint = FALSE,
cinitial,gradientstop=1e-10)
Arguments
data |
Vector of angles in radians |
M |
Number of components in the NNTS |
iter |
Number of iterations |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
Vector of size M+1. The first element is real and the next M elements are complex (values for |
gradientstop |
The value of the norm of the gradient error of the Newton algorithm at which the algorithms stops |
Value
cestimates |
Matrix of (M+1)x2. The first column is the parameter numbers, and the second column is the c parameter???s estimators |
loglik |
Optimum log-likelihood value |
AIC |
Value of Akaike???s Information Criterion |
BIC |
Value of Bayesian Information Criterion |
gradnormerror |
Gradient error after the last iteration |
Author(s)
Juan Jose Fernandez-Duran y Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2010). Maximum Likelihood Estimation of Nonnegative Trigonometric Sums Models by Using a Newton-like Algorithm on Manifolds, Working Paper, Department of Statistics, ITAM, DE-C10.8
Examples
set.seed(200)
a<-c(runif(10,3*pi/2,2*pi-0.00000001),runif(10,pi/2,pi-0.00000001))
#Estimation of the NNTSdensity with 2 components for data and gradientstop at 1e-12
nntsmanifoldnewtonestimationgradientstop(a,2,gradientstop=1e-12)
data(Turtles_radians)
#Empirical analysis of data
Turtles_hist<-hist(Turtles_radians,breaks=10,freq=FALSE)
#Estimation of the NNTS density with 3 componentes for data and gradientstop at 1e-12
nntsmanifoldnewtonestimationgradientstop(Turtles_radians,3,gradientstop=1e-12)
Parameter estimation for grouped data defined in [0,1)
Description
Parameter estimation for incidence data (number of observed values in certain intervals defined over [0,1))
Usage
nntsmanifoldnewtonestimationinterval0to1(data, cutpoints, subintervals, M = 0, iter=1000,
initialpoint = FALSE, cinitial)
Arguments
data |
Frequency of data on each interval |
cutpoints |
Vector with the limits of intervals. The length of cutpoints must be one plus the length of the data |
subintervals |
Number of intervals |
M |
Number of components in the NNTS |
iter |
Number of iterations |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
Vector of size M+1. The first element is real and the next M elements are complex (values for $c_0$ and $c_1, ...,c_M$).The sum of the squared moduli of the parameters must be equal to 1/(2*pi) |
Value
cestimates |
Matrix of M+1 * 2. The first column is the parameter numbers and the second column is the c parameter's estimators |
loglik |
Optimum loglikelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
gradnormerror |
Gradient error after the last iteration |
Author(s)
Juan Jose Fernandez-Duran y Maria Mercedes Gregorio-Dominguez
Examples
data<-c(1,2,4,6,1)
cutpoints<-c(0,0.2,0.4,0.6,0.8,0.999999999)
nntsmanifoldnewtonestimationinterval0to1(data, cutpoints, length(data), 1)
Parameter estimation for grouped data defined in [0,2*pi)
Description
Parameter estimation for incidence data (number of observed values in certain intervals defined over [0,2*pi))
Usage
nntsmanifoldnewtonestimationinterval0to2pi(data, cutpoints,
subintervals,M = 0, iter=1000, initialpoint = FALSE, cinitial)
Arguments
data |
Frequency of data on each interval |
cutpoints |
Vector with the limits of intervals. The length of cutpoints has to be one plus the length of the data |
subintervals |
Number of intervals |
M |
Number of components in the NNTS |
iter |
Number of iterations |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
A vector of size M+1. The first element is real, and the next M elements are complex (values for $c_0$ and $c_1, ...,c_M$).The sum of the squared moduli of the parameters must be equal to 1/(2*pi) |
Value
cestimates |
Matrix of M+1 * 2. The first column is the parameter numbers, and the second column is the c parameter's estimators |
loglik |
Optimum log-likelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
gradnormerror |
Gradient error after last iteration |
Author(s)
Juan Jose Fernandez-Duran y Maria Mercedes Gregorio-Dominguez
Examples
data<-c(1,2,6,4)
cutpoints<-c(0,pi/2,pi,3*pi/2,2*pi-0.00000001)
nntsmanifoldnewtonestimationinterval0to2pi(data, cutpoints, length(data),1)
Plots the NNTS density
Description
Plots the NNTS density
Usage
nntsplot(cpars = 1/sqrt(2 * pi), M = 0, ...)
Arguments
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
... |
Arguments passed to the function curve |
Examples
data(Turtles_radians)
#Empirical analysis of data
Turtles_hist<-hist(Turtles_radians,breaks=10,freq=FALSE)
#Estimation of the NNTS density with 3 componentes for data
est<-nntsmanifoldnewtonestimation(Turtles_radians,3,iter=200)
est
#plot the histogram
plot(Turtles_hist, freq=FALSE)
#add the estimated density to the histogram
nntsplot(est$cestimates[,2],3,add= TRUE)
Plots an NNTS density for a variable defined in the interval [0,1)
Description
Plots the NNTS density for a variable defined in the interval [0,1)
Usage
nntsplotInterval0to1(cpars = 1/sqrt(2 * pi), M = 0, ...)
Arguments
cpars |
Vector of complex numbers of dimension M+1. The first element is a real and positive number. The sum of the SQUARED moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS |
... |
Arguments passed to the function curve |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
data<-c(1,2,4,6,2)
cutpoints<-c(0,0.2,0.4,0.6,0.8,0.9999999)
est<-nntsmanifoldnewtonestimationinterval0to1(data,cutpoints,5,1)
cpars<-est$cestimates[,2]
nntsplotInterval0to1(cpars, 1)
Plots a symmetric NNTS density function
Description
Plots the Symmetric NNTS density function
Usage
nntsplotSymmetric(cpars = c(0, 0), M = 0, ...)
Arguments
cpars |
Vector of real numbers of dimension 2M. The first 2M-1 numbers are the squared moduli of the c parameters. The sum must be less than 1/(2*pi). The last number is the mean of symmetry |
M |
Number of components in the NNTS |
... |
Arguments passed to the function curve |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran, J.J., Gregorio-Dominguez, M.M. (2009) Symmetric Circular Distributions Based on Nonnegative Trigonometric Sums. Working Paper, DE-C09.12, Department of Statistics, ITAM, Mexico
Initial random point
Description
This function generates a random point on the surface of the (M+1)-dimensional unit hypersphere
Usage
nntsrandominitial(M=1)
Arguments
M |
Number of components in the NNTS |
Value
Returns a valid initial point for the estimation functions
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
nntsrandominitial(3)
nntsrandominitial(7)
Initial random point
Description
This function generates a random point on the surface of the (M+1)-dimensional unit hypersphere
Usage
nntsrandominitialSymmetric(M)
Arguments
M |
Number of components in the NNTS |
Value
Returns a valid initial point for the estimation functions nntsestimation and nntsestimationSymmetric
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
NNTS density simulation function
Description
Simulation for the density function for the NNTS model
Usage
nntssimulation(nsim=1, cpars = 1/(2 * pi), M = 0)
Arguments
nsim |
Number of simulations |
cpars |
Parameters of the model. A vector of complex numbers of dimension M+1. The sum of the squared moduli of the c parameters must be equal to 1/(2*pi). |
M |
Number of components in the NNTS model |
Value
simulations |
The function generates nsim random values from the MNNTS density function |
conteo |
Number of uniform random numbers used for simulations |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
M<-3
ccoef<-nntsrandominitial(M)
data<-nntssimulation(10,ccoef,M)
data
Computes the statistic and critical values of the circular uniformity test
Description
Computes the statistic and critical values at 10%, 5% and 1% of the circular uniformity test based on the NNTS likelihood ratio for M values from 1 to 7 and any sample size.
Usage
nntsuniformitytestlikelihoodratio(data,M=1, iter=1000, initialpoint = FALSE,
cinitial,gradientstop=1e-10)
Arguments
data |
Vector of angles in radians |
M |
Number of components in the NNTS |
iter |
Number of iterations |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
Vector of size M+1. The first element is real and the next M elements are complex (values for |
.
gradientstop |
The value of the gradient of the Newton algorithm at which the algorithms stops |
Value
gradient |
Gradient error after the last iteration |
likratiounifstat |
Value of the likelihood ratio NNTS circular uniformity test statistic |
criticalvalue10percent |
Critical value at a 10% significance level of the likelihood ratio NNTS circular uniformity test |
criticalvalue05percent |
Critical value at a 5% significance level of the likelihood ratio NNTS circular uniformity test |
criticalvalue01percent |
Critical value at a 1% significance level of the likelihood ratio NNTS circular uniformity test |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran and J. J. and Gregorio-Dominguez and M. M (2022). Sums of Independent Circular Random Variables and Maximum Likelihood Circular Uniformity Tests Based on Nonnegative Trigonometric Sums Distributions, arXiv preprint arXiv:2212.01416
Examples
set.seed(200)
a<-2*pi*runif(50)
#NNTS likelihood ratio circular uniformity test for M=2 and gradientstop at 1e-09
nntsuniformitytestlikelihoodratio(data=a,M=2,gradientstop=1e-09)
data(Turtles_radians)
#NNTS likelihood ratio circular uniformity test for M=5 and gradientstop at 1e-12
nntsuniformitytestlikelihoodratio(data=Turtles_radians,M=5,gradientstop=1e-09)
SNNTS density function for spherical data
Description
Density function for the SNNTS model for spherical data
Usage
snntsdensity(data, cpars = 1, M = c(0,0))
Arguments
data |
Matrix of angles in radians. The first column contains longitude data (between zero and 2*pi), and second column contains latitude data (between zero and pi), with one row for each data point |
cpars |
Vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to one. |
M |
Vector with the number of components in the SNNTS for each dimension |
Value
The function returns the density function evaluated for each row in the data
Note
The parameters cinitial and cestimates used by this function are the transformed parameters of the SNNTS density function, which lie on the surface of the unit hypersphere
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Juan Jose Fernandez-Duran, Maria Mercedes Gregorio-Dominguez (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(6), 1-19. doi:10.18637/jss.v070.i06
Examples
data(Datab6fisher_ready)
data<-Datab6fisher_ready
M<-c(2,3)
cpars<-rnorm(prod(M+1))+rnorm(prod(M+1))*complex(real=0,imaginary=1)
cpars[1]<-Re(cpars[1])
cpars<- cpars/sqrt(sum(Mod(cpars)^2))
snntsdensity(data, cpars, M)
Plots a SNNTS density for spherical data
Description
Computes the points needed to plot the SNNTS density function for spherical data
Usage
snntsdensityplot(long, lat, cpars = 1, M = c(0,0))
Arguments
long |
Grid for longitude. Vector with values between zero and 2*pi |
lat |
Grid for latitude. Vector with values between zero and pi |
cpars |
Vector of complex numbers of dimension prod(M+1). The sum of the squared moduli of the c parameters must be equal to one |
M |
Vector with the number of components in the SNNTS for each dimension |
Value
The points needed to plot the SNNTS density function
Note
The parameters cpars used by this function are the transformed parameters of the SNNTS density function, which lie on the surface of the unit hypersphere
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran J. J. y Gregorio Dominguez, M. M. (2008) Spherical Distributions Based on Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C08.6
Examples
set.seed(200)
data(Datab6fisher_ready)
data<-Datab6fisher_ready
M<-c(4,4)
cest<-snntsmanifoldnewtonestimation(data, M, iter=150)
cpars<-cest$cestimates[,3]
longitud<-seq(0,360,10)*(pi/180)
latitud<-seq(0,180,5)*(pi/180)
z<-outer(longitud,latitud,FUN="snntsdensityplot",cpars,M)
persp(longitud,latitud,z,theta=45,phi=30)
contour(longitud,latitud,z)
points(data[,1],data[,2])
SNNTS log-likelihood function for spherical data
Description
Computes the log-likelihood function with SNNTS density for spherical data
Usage
snntsloglik(data, cpars = 1, M = c(0,0))
Arguments
data |
Matrix of angles in radians. The first column contains longitude data (between zero and 2*pi), and the second column containslatitude data (between zero and pi), with one row for each data point |
cpars |
Vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The first M[1]+1 elements correspond to longitude, the next M[2]+1 elements correspond to latitude. The sum of the squared moduli of the c parameters must be equal to 1 |
M |
Vector with number of components in the SNNTS for each dimension |
Value
The function returns the value of the log-likelihood function for the data
Note
The parameters cpars used by this function are the transformed parameters of the SNNTS density function, which lie on the surface of the unit hypersphere
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran J. J. y Gregorio Dominguez, M. M. (2008) Spherical Distributions Based on Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C08.6
Examples
data(Datab6fisher_ready)
data<-Datab6fisher_ready
M<-c(4,4)
cpars<-rnorm(prod(M+1))+rnorm(prod(M+1))*complex(real=0,imaginary=1)
cpars[1]<-Re(cpars[1])
cpars<- cpars/sqrt(sum(Mod(cpars)^2))
snntsdensity(data, cpars, M)
snntsloglik(data, cpars, M)
Parameter estimation for SNNTS distributions for spherical data
Description
Computes the maximum likelihood estimates of the SNNTS model parameters using a Newton algorithm on the hypersphere
Usage
snntsmanifoldnewtonestimation(data, M = c(0,0), iter = 1000,
initialpoint = FALSE, cinitial)
Arguments
data |
Matrix of angles in radians, with one row for each data point. The first column contains longitude data (between zero and 2*pi), and second column contains latitude data (between zero and pi), with one row for each data point |
M |
Vector with number of components in the SNNTS for each dimension |
iter |
Number of iterations |
initialpoint |
TRUE if an initial point for the optimization algorithm will be used |
cinitial |
Initial value for cpars for the optimization algorithm, avector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to one. |
Value
cestimates |
Matrix of prod(M+1)*(3). The first two columns are the parameter numbers, and the last column is the c parameter's estimators |
loglik |
Optimum log-likelihood value |
AIC |
Value of Akaike's Information Criterion |
BIC |
Value of Bayesian Information Criterion |
gradnormerror |
Gradient error after the last iteration |
Note
The parameters cinitial and cestimates used by this function are the transformed parameters of the SNNTS density function, which lie on the surface of the unit hypersphere
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran J. J. y Gregorio Dominguez, M. M. (2008) Spherical Distributions Based on Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C08.6
Examples
set.seed(200)
data(Datab6fisher_ready)
data<-Datab6fisher_ready
M<-c(4,4)
cpar<-rnorm(prod(M+1))+rnorm(prod(M+1))*complex(real=0,imaginary=1)
cpar[1]<-Re(cpar[1])
cpar<- cpar/sqrt(sum(Mod(cpar)^2))
cest<-snntsmanifoldnewtonestimation(data,c(4,4),100,TRUE,cpar)
cest
cest<-snntsmanifoldnewtonestimation(data,c(1,2),100)
cest
Marginal density function for latitude of the SNNTS model for spherical data
Description
Marginal density function for latitude of the SNNTS model for spherical data
Usage
snntsmarginallatitude(data, cpars = 1, M = c(0,0))
Arguments
data |
Vector of angles in radians, with one row for each data point. The data must be between zero and pi. |
cpars |
Vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The sum of the squared moduli of the c parameters must be equal to one |
M |
Vector with the number of components in the SNNTS for each dimension |
Value
The function returns the SNNTS marginal density function for latitude evaluated at data
Note
The parameters cpars used by this function are the transformed parameters of the SNNTS density function, which lie on the surface of the unit hypersphere
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran J. J. y Gregorio Dominguez, M. M. (2008) Spherical Distributions Based on Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C08.6
Examples
set.seed(200)
data(Datab6fisher_ready)
data<-Datab6fisher_ready
M<-c(1,2)
cest<-snntsmanifoldnewtonestimation(data, M,iter=150)
lat<-snntsmarginallatitude(seq(0,pi,.1),cest$cestimates[,3],M)
plot(seq(0,pi,.1),lat,type="l")
Marginal density function for the longitude of the SNNTS model for spherical data
Description
Marginal density function for the longitude of the SNNTS model for spherical data
Usage
snntsmarginallongitude(data, cpars = 1, M = c(0,0))
Arguments
data |
Vector of angles in radians, with one row for each data point. The data must be between zero and 2*pi |
cpars |
Vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The first M[1]+1 elements correspond to longitude, and the next M[2]+1 elements correspond to latitude. The sum of the squared moduli of the c parameters must be equal to one. |
M |
Vector with number of components in the SNNTS for each dimension |
Value
The function returns the density function evaluated for the data
Note
The parameters cpars used by this function are the transformed parameters of the SNNTS density function, which lie on the surface of the unit hypersphere
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
References
Fernandez-Duran J. J. y Gregorio Dominguez, M. M. (2008) Spherical Distributions Based on Nonnegative Trigonometric Sums, Working Paper, Statistics Department, ITAM, DE-C08.6
Examples
set.seed(200)
data(Datab6fisher_ready)
data<-Datab6fisher_ready
M<-c(1,2)
cest<-snntsmanifoldnewtonestimation(data, M,iter=150)
long<-snntsmarginallongitude(seq(0,2*pi,.1),cest$cestimates[,3],M)
plot(seq(0,2*pi,.1),long,type="l")
SNNTS density simulation function
Description
Simulation for the density function for the SNNTS model
Usage
snntssimulation(nsim=1, cpars =(1/(2*pi))^2, M = c(0,0))
Arguments
nsim |
Number of simulations |
cpars |
Vector of complex numbers of dimension prod(M+1). The first element is a real and positive number. The first M[1]+1 elements correspond to longitude, the next M[2]+1 elements correspond to latitude. The sum of the squared moduli of the c parameters must be equal to one |
M |
Vector with the number of components in the SNNTS for each dimension |
Value
simulations |
The function generates nsim random values from the SNNTS density function |
conteo |
Number of uniform random numbers used for simulations |
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez
Examples
M<-c(2,3)
R<-length(M)
ccoef<-mnntsrandominitial(M,R)
data<-mnntssimulation(10,ccoef,M,R)
data
Auxiliary function for plotting
Description
Auxiliary function for plotting
Usage
trans3d(x,y,z,pmat)
Arguments
x |
x |
y |
y |
z |
z |
pmat |
pmat |
Value
The function returns the density function evaluated for each row in the data
Author(s)
Juan Jose Fernandez-Duran and Maria Mercedes Gregorio-Dominguez