com.jstatcom.util
Class UData
- java.lang.Object
-
- com.jstatcom.util.UData
-
public final class UData extends java.lang.ObjectThis class contains a collection of methods to be used withJSCDataobjects. Some methods are directly related to time series analysis. The methods defined here should help to prepare parameters for procedure calls, as well as to make simple data transformations often needed to prepare input panels. They are not used as often as to make them part of particularJSCDataimplementations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static JSCSArrayappendSuffix(JSCSArray arg, java.lang.String suffix, java.lang.String newName)Creates a new data object withsuffixbeing appended to all string elements inarg.static JSCNArraycreateDeterministic(TSDateRange range, JSCNArray dummies, boolean isIntercept, boolean isSeasDum, boolean isSeasDumCentered, boolean isTrend, java.lang.String newName)Creates a data object with the deterministic variables to be used for estimation according to the parametrization.static JSCNArraycreateResMat(JSCNArray det, JSCNArray end, JSCNArray ex, java.lang.String name)Creates a restriction matrix to be used for model estimation.static JSCNArray[]createYZMat(JSCNArray detData, JSCNArray endData, JSCNArray exData, int endLags, int exLags, java.lang.String yName, java.lang.String zName)Creates the Y and Z matrices to be used for estimation.static booleanhasFullColumnRank(JSCNArray arg, int truncationLag)Checks the rank ofargafter deleting the firsttruncationLagrows of it.static JSCNArray[]imp2ExpRes(JSCNArray res, JSCNArray r)Gets the explicit representation of restrictions on the cointegrating space, given the implicit representation.static JSCNArrayindexData(JSCNArray arg, java.lang.String newName)Gets a new array with the elements ofargbeing transformed into an index with the mean of each column being normalized to +100 or -100, depending on the sign of the mean.static JSCData[]mergeTS(JSCSArray namesOfData, java.lang.String nameDat, java.lang.String nameRange)Merges time series with possibly different length and fills them with missing values at the beginning and/or the end.static JSCNArray[]splitDeterministics(JSCNArray dets, boolean zeroBased)Takes an array with deterministic terms and computes indices for the breaks of all dummy variables.static JSCNArraystandardize(JSCNArray dat, java.lang.String name)Creates a new data object with the elements ofdatdivided by the standard devitation of the respective columns ofdat.static java.lang.StringstringForArray(JSCSArray data)String representation of the first row of a string data object.
-
-
-
Method Detail
-
appendSuffix
public static JSCSArray appendSuffix(JSCSArray arg, java.lang.String suffix, java.lang.String newName)
Creates a new data object withsuffixbeing appended to all string elements inarg.- Parameters:
arg- the original data objectsuffix- the string to be appended to all elements ofargnewName- the name of the new data object to be created- Returns:
- a new data object with the changed string elements
- Throws:
java.lang.IllegalArgumentException-if (arg == null || suffix == null || newName == null)or ifargis not of a string type
-
createDeterministic
public static JSCNArray createDeterministic(TSDateRange range, JSCNArray dummies, boolean isIntercept, boolean isSeasDum, boolean isSeasDumCentered, boolean isTrend, java.lang.String newName)
Creates a data object with the deterministic variables to be used for estimation according to the parametrization. The data object is constructed in the orderdummies~intercept~seasonal dummies~trend, where each component may be there or not. If nothing is specified, an empty data object is returned.- Parameters:
range- theTSDateRangedefining start and enddummies- impulse and shift dummies, or other manually specified deterministics, can be either empty ornullisIntercept-trueif a constant should be includedisSeasDum-trueif seasonal dummies should be included, this automatically setsisIntercept=trueas well,falseotherwiseisSeasDumCentered-trueif centered seasonal dummies should be used, onlyif (isSeasDum)isTrend-trueif a trend should be includednewName- the name of the new data object to create- Returns:
- a new data object containing the deterministics for an estimation
dummies~intercept~seasonal dummies~trend - Throws:
java.lang.IllegalArgumentException-if (newName == null || range == null)or if the number of observations indummiesdoes not fit withrange
-
createResMat
public static JSCNArray createResMat(JSCNArray det, JSCNArray end, JSCNArray ex, java.lang.String name)
Creates a restriction matrix to be used for model estimation. The restriction matrix R is implicitely defined by vec(B)=R*gamma+r, where R is a (K(K*py + d + X(px+1)) x M) matrix with:- K being dimension of the process
- py the endogenous lags
- d the number of deterministic variables
- X the number of exogenous variables
- px the exogenous lags
- M the number of free parameters to estimate
- gamma (M x 1) vector of free parameters
- r vector of known constants, here assumed to be 0
- B matrix of all estimators
det, end, ex). This method only supports exclusion restrictions for certain coefficients .- Parameters:
det- K x d matrix containing zeros and ones to exclude the respective coefficient for the deterministicsend- K x K*py matrix containing zeros and ones to exclude the respective coefficient for the endogenous partex- K x X(px+1) matrix containing zeros and ones to exclude the respective coefficient for the exogenous partname- the name of the data object to create- Returns:
- a new data object containing the restriction matrix, is empty if the input data objects are empty or if they do not contain any restrictions
- Throws:
java.lang.IllegalArgumentException-if (name == null || det == null || end == null || ex == null )
-
createYZMat
public static JSCNArray[] createYZMat(JSCNArray detData, JSCNArray endData, JSCNArray exData, int endLags, int exLags, java.lang.String yName, java.lang.String zName)
Creates the Y and Z matrices to be used for estimation. For the definition of Z see Helmut Lutkepohl, Introduction to Multiple Time Series Analysis, 10.3. The input data objects must contain the same number of observations including the presample values which will be truncated according to the maximum number of endogenous/exogenous lags.The order of the variables within Z must be det|end|ex. If subset restrictions are set, then this must correspond to the ordering of R.
The following symbols are defined:
- T sample size
- D number of deterministic variables
- K number of endogenous variables (dimension of process)
- X number of deterministic variables
- Parameters:
detData- data object with dimensionT + Math.max(endLags, exLags) x DendData- data object with dimensionT + Math.max(endLags, exLags) x K, must not be emptyexData- data object with dimensionT + Math.max(endLags, exLags) x XendLags- number of endogenous lags in levelsexLags- number of exogenous lags in levelsyName- name of data object for Y matrixzName- name of data object for Z matrix- Returns:
- 2 x 1 array of data objects with the created matrices {Y, Z}
- Throws:
java.lang.IllegalArgumentException- if one of the arguments wasnullorif (endLags < 0 || exLags < 0)orif (endData.isEmpty())or if the dimensions of the nonempty data objects are not the same or if there are too many lags for the given sample dize
-
hasFullColumnRank
public static boolean hasFullColumnRank(JSCNArray arg, int truncationLag)
Checks the rank ofargafter deleting the firsttruncationLagrows of it. Returns whether the rank is equal toarg.getCols().- Parameters:
arg- the data object to be checked for column ranktruncationLag- the number of rows to delete fromargbefore checking the rank- Returns:
trueifrank(arg) == >arg.getCols(),falseotherwise- Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (truncationLag < 0)orif (arg.isEmpty())
-
imp2ExpRes
public static JSCNArray[] imp2ExpRes(JSCNArray res, JSCNArray r)
Gets the explicit representation of restrictions on the cointegrating space, given the implicit representation.
Implicit Representation:res*vec(beta') = r
Explicit Representation: vec(beta') =H*eta + h, withetabeing the free parameters.In the context of cointegration analysis,
betais the part of theBetamatrix inBeta = [I_r : beta], because the firstrcolumns ofBetaare normalized, withrbeing the cointegration rank.etaare the elements ofbetathat are freely estimated after imposing the restrictions.- Parameters:
res- the matrix with implicit restrictions (J x K-r)r- a vector with numbers (J x 1)- Returns:
- a 3 x 1 array of data objects with
H, a vector of zeros and ones selecting the free elements of vec(beta') and h, respectively - Throws:
java.lang.IllegalArgumentException-if (res == null || r == null)orif (res.getRows() != r.getRows())or ifrescontains restrictions that are linearly dependent
-
indexData
public static JSCNArray indexData(JSCNArray arg, java.lang.String newName)
Gets a new array with the elements ofargbeing transformed into an index with the mean of each column being normalized to +100 or -100, depending on the sign of the mean. This is usefull to compare series which differ greatly in levels. The index is computed asarg[i][j] * 100 / mean[j]- Parameters:
arg- the data object with the numbers to be transformed to an indexnewName- the name of the new data object to be created- Returns:
- a new data object with the indexed numbers
- Throws:
java.lang.IllegalArgumentException-if (arg == null || newName == null)
-
mergeTS
public static JSCData[] mergeTS(JSCSArray namesOfData, java.lang.String nameDat, java.lang.String nameRange)
Merges time series with possibly different length and fills them with missing values at the beginning and/or the end.- Parameters:
namesOfData- data object with the names of the time series in theTSHoldernameDat- name of the new data object which holds the observationsnameRange- name of the new data object which holds the date range- Returns:
- a 2 x 1 array of data objects, the 1st element holds the
observations, the 2nd element holds the earliest date of all time
series defined by
namesOfData - Throws:
java.lang.IllegalArgumentException-if (namesOfData == null || nameDat == null || nameRange == null)
-
splitDeterministics
public static JSCNArray[] splitDeterministics(JSCNArray dets, boolean zeroBased)
Takes an array with deterministic terms and computes indices for the breaks of all dummy variables. Recognized variables are impulse, extended impulse, shift dummies, and trend breaks. All other variables are ignored.This method splits the data object with deterministic variables into the following data objects:
- data object with indices of impulses for each impulse dummy with name "impulseIndices"
- data object with start and end indices of shifts with name "extImpulseIndices"
- data object with shift start indices with name "shiftIndices"
- data object with trend break start indices with name "trendBreakIndices"
- impulse dummy: 0001000 (there is a sequence 010)
- extended impulse dummy: 00111000 OR 11110000 (ends with 0 and has at least one 11 sequence)
- shift dummy: 00011111 (starts with 0, ends with 11 sequence)
- trended variables like 002345678
- dummy variables that contain only 11111, 0000, or a pure trend are ignored
- dummy variables like 001000100 will be indexed like 00111100
- all other variables are ignored
- Parameters:
dets- the data object containing the deterministic variableszeroBased- whether zero based index should be used, iffalsethen 1 based index is used (like in Gauss)- Returns:
- 4x1 array of data objects {impulse indices, extended impulse start/end indices, shift start indices, trend break indices}
- Throws:
java.lang.IllegalArgumentException-if (dets == null)
-
standardize
public static JSCNArray standardize(JSCNArray dat, java.lang.String name)
Creates a new data object with the elements ofdatdivided by the standard devitation of the respective columns ofdat.- Parameters:
dat- the original data objectname- the name of the new data object to create- Returns:
- a new data object with all elements standardized
- Throws:
java.lang.IllegalArgumentException-if (dat == null || name == null)
-
stringForArray
public static java.lang.String stringForArray(JSCSArray data)
String representation of the first row of a string data object. The elements are just printed space separated.- Parameters:
data- array containing names- Returns:
- string with names, for example
"y x invest cons" - Throws:
java.lang.IllegalArgumentException-if (array == null)
-
-
DMelt 3.0 © DataMelt by jWork.ORG