Package com.imsl.stat
Class TimeSeries
java.lang.Object
com.imsl.stat.TimeSeries
- All Implemented Interfaces:
Serializable,Cloneable
A specialized class for time series data and analysis.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the date increment for this TimeSeries object.Date[]getDates()Returns the date array associated with the time series.intReturns the length of the time series.int[][]Returns an array of missing value indicators.intReturns the number of series stored in this TimeSeries object.intReturns the number of missing values.double[][]Returns the data values of the time series.double[]getSeriesValues(int k) 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.longReturns the number of hours (+ or -) from GMT of the time zone associated with the time series.booleanReturns a boolean indicating whether or not the TimeSeries object has a date increment expressed in milliseconds.booleanReturns a boolean indicating whether or not the TimeSeries has a non-null dates attribute.voidsetDateIncrement(int increment) Sets the date increment in number of days.voidsetDateIncrementInMillis(long incrementInMillis) Sets the date increment in milliseconds.voidsetDates()Sets the date array using the start date and date increment.voidSets the date array equal to user supplied dates.voidsetSeriesValues(double[] y) Sets the values of a univariate time series and initializes the time index.voidsetSeriesValues(double[][] y) Sets the values of the TimeSeries.voidsetSeriesValues(double[] y, int numSeries) Sets the values of a multivariate time series and initializes the time index array.voidsetStartDate(Date startDate) Sets the start date of the series.voidsetTimeZone(int offset) Sets the time zone for the time series to the time zone associated with the given offset from GMT.voidsetTimeZone(int offset, String id) Sets the time zone for the time series using the offset and String id.voidsetTimeZone(TimeZone tz) Sets the time zone for the time series to the given TimeZone.
-
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 usingsetStartDateand the increment in days can be set usingsetDateIncrementor in milliseconds usingsetDateIncrementInMillis.- Parameters:
y- adoublearray 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- adoublearray 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 asDouble.NaN.numSeries- anint, the number of different series.
-
setSeriesValues
public void setSeriesValues(double[][] y) Sets the values of the TimeSeries.- Parameters:
y- adoublematrix containing the values of the time series. The number of series is set to the number of columns ofy. Missing values must be provided asDouble.NaN.
-
setStartDate
Sets the start date of the series.- Parameters:
startDate- aDatevalue, the date associated with the first observation. The default start date is set tonull.
-
setDateIncrement
public void setDateIncrement(int increment) Sets the date increment in number of days.- Parameters:
increment- anintvalue 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- alongvalue representing the number of milliseconds between series values. By using increments, the time series is presumed to be evenly spaced.
-
setTimeZone
Sets the time zone for the time series to the given TimeZone.- Parameters:
tz- ajava.util.TimeZoneobject.
-
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- anintrepresenting the number of hours (+ or -) difference from GMT.
-
setTimeZone
Sets the time zone for the time series using the offset and String id.- Parameters:
offset- anintrepresenting the number of hours (+ or -) difference from GMTid- aStringrepresenting the desired name of the time zone. A warning is generated ifidis not an element ofTimeZone.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
Returns the starting date of the time series.- Returns:
- a
Datecontaining 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
intrepresenting 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
intmatrix having the same dimension as the time series wheregetMissingIndicator()[i][j]=1ify[i*numSeries+j]ory[i][j]is a missing value, otherwisegetMissingIndicator()[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. Whentrue, the dates attribute is notnull.
-
isDateIncrementInMillis
public boolean isDateIncrementInMillis()Returns a boolean indicating whether or not the TimeSeries object has a date increment expressed in milliseconds. Iftruethe 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
Returns the date array associated with the time series.See Java documentation on the Date class.
- Returns:
- a
Datearray containing the dates of the series
-
setDates
public void setDates()Sets the date array using the start date and date increment. -
setDates
Sets the date array equal to user supplied dates.- Parameters:
dateArray- aDatearray 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
doublematrix containing the values of the series
-
getSeriesValues
public double[] getSeriesValues(int k) Returns the data values of the k-th time series.- Parameters:
k- anint, the index of the time series- Returns:
- a
doublearray containing the values of the series
-
getTimeZone
Returns the time zone of the time series.See Java documentation for the TimeZone class.
- Returns:
- a
TimeZoneobject
-
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
longvalue, the the number of hours
-