-
- Downloads
Allow selections of periods or variables with vector of logicals.
Ref #4. If ts is a dseries object with T periods and N variables, then we can instantiate a new dseries object from ts by extracting periods or variables. Periods are selected by passing a vector of logicals with T elements. Variables are selected by passing a vector of logicals with N elements. If T==N, the convention is to pass a row vector to select variables and a colum vector to select periods. *Example* >> ts = dseries(randn(10,5), '2000Q1') ts is a dseries object: | Variable_1 | Variable_2 | Variable_3 | Variable_4 | Variable_5 2000Q1 | -0.53201 | -1.0642 | 0.39189 | -1.0667 | -0.73417 2000Q2 | 1.6821 | 1.6035 | -1.2507 | 0.93373 | -0.030814 2000Q3 | -0.87573 | 1.2347 | -0.94796 | 0.35032 | 0.23235 2000Q4 | -0.48382 | -0.22963 | -0.74111 | -0.029006 | 0.42639 2001Q1 | -0.712 | -1.5062 | -0.50782 | 0.18245 | -0.37281 2001Q2 | -1.1742 | -0.44463 | -0.32058 | -1.5651 | -0.23645 2001Q3 | -0.19224 | -0.15594 | 0.012469 | -0.084539 | 2.0237 2001Q4 | -0.27407 | 0.27607 | -3.0292 | 1.6039 | -2.2584 2002Q1 | 1.5301 | -0.26116 | -0.45701 | 0.098348 | 2.2294 2002Q2 | -0.24902 | 0.44342 | 1.2424 | 0.041374 | 0.33756 >> ts(mean(ts)>0) ans is a dseries object: | Variable_4 | Variable_5 2000Q1 | -1.0667 | -0.73417 2000Q2 | 0.93373 | -0.030814 2000Q3 | 0.35032 | 0.23235 2000Q4 | -0.029006 | 0.42639 2001Q1 | 0.18245 | -0.37281 2001Q2 | -1.5651 | -0.23645 2001Q3 | -0.084539 | 2.0237 2001Q4 | 1.6039 | -2.2584 2002Q1 | 0.098348 | 2.2294 2002Q2 | 0.041374 | 0.33756 >> ts(ts.dates>=dates('2001Q3')) ans is a dseries object: | Variable_1 | Variable_2 | Variable_3 | Variable_4 | Variable_5 2001Q3 | -0.19224 | -0.15594 | 0.012469 | -0.084539 | 2.0237 2001Q4 | -0.27407 | 0.27607 | -3.0292 | 1.6039 | -2.2584 2002Q1 | 1.5301 | -0.26116 | -0.45701 | 0.098348 | 2.2294 2002Q2 | -0.24902 | 0.44342 | 1.2424 | 0.041374 | 0.33756
Loading
Please register or sign in to comment