fills %nan values in an matrix
[X,indNaN]=remNaNs_spline(X,method,k)
* X = a (T x k) matrix of values, data in columns
* method = a scalar, the way Na are filled:
. 1: replace all the missing values with a digital filter
. 2: Replaces missing values after removing trailing and leading NA rows (a row is 'missing' if >80% is NaN)
. 3: only remove rows with leading and closing zeros
. 4: replace missing values after removing trailing and leading rows with all values %nan
* k = an integer, that controls the rational transfer function argument's numerator (the denominator is set to 1). More specifically, the numerator of the filter takes the form: ones(2*k+1,1)./[1;1/z;...;1/z^k]/(2*k+1)
* X = the (T x k) matrix of values, with NA values repplaced
* indNaN = a (T x k) matrix, A matrix indicating the location for missing values
global GROCERDIR ; load(GROCERDIR+'\data\xnan.dat') // replace NA values in X with a digital filter of order 5 (=2*2+1) // in the numerator X_new1=remNaNs_spline(X,1,2) // remove NA values in the last 2 rows and replace other NA values in X with // a digital filter of order 5 (=2*2+1) in the numerator applied to // interpolated data X_new2=remNaNs_spline(X,2,2) // only remove NA values in the last 2 rows X_new3=remNaNs_spline(X,3) // replace other NA values in X with // a digital filter of order 5 (=2*2+1) in the numerator applied to // interpolated data X_new4=remNaNs_spline(X,4,2) | ![]() | ![]() |