stationary_bootstrap_calibrate#
Functions
| 
 | Function calculates the optimal parameter value when using a stationary bootstraping algorithm. | 
| 
 | Returns the value at points x of the Trapezoidal function. | 
| 
 | Returns a numpy array in which the k-th column is the series x pushed down (lagged) by k places. | 
- OptimalLength(data: ndarray)[source]#
- Function calculates the optimal parameter value when using a stationary bootstraping algorithm. The method is based on the 2004 paper by Politis & White: Dimitris N. Politis & Halbert White (2004) Automatic Block-Length Selection for the Dependent Bootstrap, Econometric Reviews, 23:1, 53-70, DOI: 10.1081/ETC-120028836 - The code was modified compared to Patton’s implementation in that it takes as input a one dimensional time-series and returns the optimalblock size only for the stationary bootstrap algorithm. - Warning! The minimal size of the time series is 9 elements. - Example - >>> import numpy as np >>> data = np.array([0.4,0.2,0.1,0.4,0.3,0.1,0.3,0.4,0.2,0.5,0.1,0.2]) >>> OptimalLength(data) 4.0 - Parameters:
- data – ndarray array containing the time-series that we wish to bootstrap. Ex. np.array([-1,0.2,0.3,0.7,0.5,0.1,0.4,0.3,0.5]) 
- Returns:
- optimal value of the parameter m Ex. 1 
- Return type:
- Bstar 
 - Original Matlab version written by: James P. LeSage, Dept of Economics University of Toledo 2801 W. Bancroft St, Toledo, OH 43606 jpl@jpl.econ.utoledo.edu - This Python implementation is based on Andrew J. Patton’s Matlab code avalible at: http://public.econ.duke.edu/~ap172/ - Implemented by Gregor Fabjan from Qnity Consultants on 12/11/2021. 
- mlag(x: ndarray, n) ndarray[source]#
- Returns a numpy array in which the k-th column is the series x pushed down (lagged) by k places. - Example: - >>> import numpy as np >>> x = np.array([1,2,3,4]) >>> n = 2 >>> mlag(x,n) array([[0, 0], [1, 0], [2, 1], [3, 2]]) - The function was tested passing a numpy array (ndarray) as input and requires numpy to run. - Parameters:
- x – ndarray array for which the lagged matrix is calculated. np.array([1,2,3,4]) 
- n – - integer specifying how many lags does the function consider - Returns:
- xlag: ndarray contining the k-th lagged values in the k-th column of the matrix 
 - Original Matlab version written by: James P. LeSage, Dept of Economics University of Toledo 2801 W. Bancroft St, Toledo, OH 43606 jpl@jpl.econ.utoledo.edu - This Python implementation is based on Andrew J. Patton’s Matlab code avalible at: http://public.econ.duke.edu/~ap172/ - Implemented by Gregor Fabjan from Qnity Consultants on 12/11/2021 
 
 
- lam(x: ndarray) ndarray[source]#
- Returns the value at points x of the Trapezoidal function. - Trapezoidal funcion maps all numbers bigger than 1 or smaller than -1 to zero. Values between -1/2 to 1/2 to 1 and the rest either on the line connecting (-1,0) to (-1/2,1) or (1/2,1) to (1,0). - Example - >>> import numpy as np >>> x = np.array([0.55]) >>> lam(x) array([0.9]) - Parameters:
- x – ndarray array of points on which we wish to apply the trapezoidal mapping. Ex. np.array([-1,0.2,0.3,0.7]) 
- Returns:
- ndarray of mapped points Ex. array([0. , 1. , 1. , 0.6]) 
 - Original Matlab version written by: James P. LeSage, Dept of Economics University of Toledo 2801 W. Bancroft St, Toledo, OH 43606 jpl@jpl.econ.utoledo.edu - This Python implementation is based on Andrew J. Patton’s Matlab code avalible at: http://public.econ.duke.edu/~ap172/ - Implemented by Gregor Fabjan from Qnity Consultants on 12/11/2021.