Package com.imsl.stat

Class TimeSeries

java.lang.Object
com.imsl.stat.TimeSeries
All Implemented Interfaces:
Serializable, Cloneable

public class TimeSeries extends Object implements Serializable, Cloneable
A specialized class for time series data and analysis.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for TimeSeries.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the date increment for this TimeSeries object.
    Returns the date array associated with the time series.
    int
    Returns the length of the time series.
    int[][]
    Returns an array of missing value indicators.
    int
    Returns the number of series stored in this TimeSeries object.
    int
    Returns the number of missing values.
    double[][]
    Returns the data values of the time series.
    double[]
    Returns the data values of the k-th time series.
    Returns the starting date of the time series.
    Returns the time zone of the time series.
    long
    Returns the number of hours (+ or -) from GMT of the time zone associated with the time series.
    boolean
    Returns a boolean indicating whether or not the TimeSeries object has a date increment expressed in milliseconds.
    boolean
    Returns a boolean indicating whether or not the TimeSeries has a non-null dates attribute.
    void
    setDateIncrement(int increment)
    Sets the date increment in number of days.
    void
    setDateIncrementInMillis(long incrementInMillis)
    Sets the date increment in milliseconds.
    void
    Sets the date array using the start date and date increment.
    void
    setDates(Date[] dateArray)
    Sets the date array equal to user supplied dates.
    void
    setSeriesValues(double[] y)
    Sets the values of a univariate time series and initializes the time index.
    void
    setSeriesValues(double[][] y)
    Sets the values of the TimeSeries.
    void
    setSeriesValues(double[] y, int numSeries)
    Sets the values of a multivariate time series and initializes the time index array.
    void
    setStartDate(Date startDate)
    Sets the start date of the series.
    void
    setTimeZone(int offset)
    Sets the time zone for the time series to the time zone associated with the given offset from GMT.
    void
    setTimeZone(int offset, String id)
    Sets the time zone for the time series using the offset and String id.
    void
    Sets the time zone for the time series to the given TimeZone.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimeSeries

      public TimeSeries()
      Constructor for TimeSeries.
  • Method Details

    • setSeriesValues

      public void setSeriesValues(double[] y)
      Sets the values of a univariate time series and initializes the time index. If the start date is set by the user, the date array starts at the starting date and increments by 1 day up to the series length. The start date can be set using setStartDate and the increment in days can be set using setDateIncrement or in milliseconds using setDateIncrementInMillis .
      Parameters:
      y - a double array containing the numeric values of the series. Missing values must be provided as NaN's.
    • setSeriesValues

      public void setSeriesValues(double[] y, int numSeries)
      Sets the values of a multivariate time series and initializes the time index array.
      Parameters:
      y - a double array containing the numeric values of the series. It is assumed that the values are row-oriented, meaning that the series index varies the fastest. Missing values must be provided as Double.NaN.
      numSeries - an int, the number of different series.
    • setSeriesValues

      public void setSeriesValues(double[][] y)
      Sets the values of the TimeSeries.
      Parameters:
      y - a double matrix containing the values of the time series. The number of series is set to the number of columns of y. Missing values must be provided as Double.NaN.
    • setStartDate

      public void setStartDate(Date startDate)
      Sets the start date of the series.
      Parameters:
      startDate - a Date value, the date associated with the first observation. The default start date is set to null.
    • setDateIncrement

      public void setDateIncrement(int increment)
      Sets the date increment in number of days.
      Parameters:
      increment - an int value representing the number of days between observations. By using increments, the time series is presumed to be evenly spaced.
    • setDateIncrementInMillis

      public void setDateIncrementInMillis(long incrementInMillis)
      Sets the date increment in milliseconds.
      Parameters:
      incrementInMillis - a long value representing the number of milliseconds between series values. By using increments, the time series is presumed to be evenly spaced.
    • setTimeZone

      public void setTimeZone(TimeZone tz)
      Sets the time zone for the time series to the given TimeZone.
      Parameters:
      tz - a java.util.TimeZone object.
    • setTimeZone

      public void setTimeZone(int offset)
      Sets the time zone for the time series to the time zone associated with the given offset from GMT.
      Parameters:
      offset - an int representing the number of hours (+ or -) difference from GMT.
    • setTimeZone

      public void setTimeZone(int offset, String id)
      Sets the time zone for the time series using the offset and String id.
      Parameters:
      offset - an int representing the number of hours (+ or -) difference from GMT
      id - a String representing the desired name of the time zone. A warning is generated if id is not an element of TimeZone.getAvailableIDS(offset * 60 * 60 * 1000).
    • getLength

      public int getLength()
      Returns the length of the time series.
      Returns:
      an int, the length of the time series
    • getNumberOfSeries

      public int getNumberOfSeries()
      Returns the number of series stored in this TimeSeries object.
      Returns:
      an int, the number of different series
    • getStartDate

      public Date getStartDate()
      Returns the starting date of the time series.
      Returns:
      a Date containing the first date of the series
    • getNumMissing

      public int getNumMissing()
      Returns the number of missing values.

      A missing value is represented in the series by a Double.NaN

      Returns:
      an int representing the number of missing values detected in the time series.
    • getMissingIndicator

      public int[][] getMissingIndicator()
      Returns an array of missing value indicators.

      A missing value is represented in the series by a Double.NaN.

      Returns:
      an int matrix having the same dimension as the time series where getMissingIndicator()[i][j]=1 if y[i*numSeries+j] or y[i][j] is a missing value, otherwise getMissingIndicator()[i][j]=0.
    • isHasDates

      public boolean isHasDates()
      Returns a boolean indicating whether or not the TimeSeries has a non-null dates attribute.
      Returns:
      a boolean. When true, the dates attribute is not null.
    • isDateIncrementInMillis

      public boolean isDateIncrementInMillis()
      Returns a boolean indicating whether or not the TimeSeries object has a date increment expressed in milliseconds. If true the date increment is considered to be expressed in milliseconds; otherwise, it is assumed to be in the number of days.
      Returns:
      a boolean
    • getDateIncrement

      public long getDateIncrement()
      Returns the date increment for this TimeSeries object.
      Returns:
      a long, the date increment
    • getDates

      public Date[] getDates()
      Returns the date array associated with the time series.

      See Java documentation on the Date class.

      Returns:
      a Date array containing the dates of the series
    • setDates

      public void setDates()
      Sets the date array using the start date and date increment.
    • setDates

      public void setDates(Date[] dateArray)
      Sets the date array equal to user supplied dates.
      Parameters:
      dateArray - a Date array containing the dates associated with each value of the time series
    • getSeriesValues

      public double[][] getSeriesValues()
      Returns the data values of the time series.
      Returns:
      a double matrix containing the values of the series
    • getSeriesValues

      public double[] getSeriesValues(int k)
      Returns the data values of the k-th time series.
      Parameters:
      k - an int, the index of the time series
      Returns:
      a double array containing the values of the series
    • getTimeZone

      public TimeZone getTimeZone()
      Returns the time zone of the time series.

      See Java documentation for the TimeZone class.

      Returns:
      a TimeZone object
    • getTimeZoneOffset

      public long getTimeZoneOffset()
      Returns the number of hours (+ or -) from GMT of the time zone associated with the time series. The time zone is the same as the local time zone unless it is changed by the user.

      To convert to milliseconds, multiply by 60*60*1000. Note that the displayed time zone will be the name of the local time zone, despite what is set for the TimeSeries object. For further information, see the Examples provided and Java documentation on Date and Calendar classes.

      Returns:
      a long value, the the number of hours