Resample from observations in a series.
Syntax
series_name.resample(options) [output_spec]
You should follow the resample keyword and options with, if desired, an output_spec containing a list of names or a wildcard expression identifying the series to hold the output. If a list is used to identify the targets, the number of target series must match the number of names implied by the keyword.
Options
outsmpl= smpl_spec | Sample to fill the new series. Either provide the sample range in double quotes or specify a named sample object. The default is the current workfile sample. |
permute | Draw from rows without replacement. Default is to draw with replacement. |
weight= series_name | Name of series to be used as weights. The weight series must have non-missing, non-negative values in the current workfile sample. If no weights are specified, observations will be drawn with equal probability weights. |
block=integer (default = 1) | Block length for each draw. Must be a positive integer. The default block length is 1. |
withna (default) | [Draw / Do not draw] from all rows in the current sample, including those with NAs. |
dropna | Do not draw from rows that contain missing values in the current workfile sample. |
fixna | Excludes NAs from draws but copies rows containing missing values to the output series. |
prompt | Force the dialog to appear from within a program. |
• You may not use this proc with an auto-series unless you provide an output_spec. For example, resampling from X(–1) or LOG(X) without providing explicit output names will produce an error since we will attempt to append a suffix to the original name, producing an invalid object name.
• Block bootstrap (block length larger than 1) requires a continuous output sample. Therefore a block length larger than 1 cannot be used together with the “fixna” option, and the “outsmpl” should not contain any gaps.
• The “fixna” option will have an effect only if there are missing values in the overlapping sample of the input sample (current workfile sample) and the output sample specified by “outsmpl”.
• If you specify “fixna”, we first copy any missing values in the overlapping sample to the output series. Then the input sample is adjusted to drop rows containing missing values and the output sample is adjusted so as not to overwrite the copied values.
• If you choose “dropna” and the block length is larger than 1, the input sample may shrink in order to ensure that there are no missing values in any of the drawn blocks.
• If you choose “permute”, the block option will be reset to 1, the “dropna” and “fixna” options will be ignored (reset to the default “withna” option), and the “weight” option will be ignored (reset to default equal weights).
Examples
ser1.resample
creates a new series SER1_B by drawing with replacement from the rows of SER1 in the current workfile sample. If SER1_B already exists in the workfile, it will be overwritten if it is a series objects, otherwise EViews will error. Note that only values of SER_B (in this case the current workfile sample) will be overwritten.
ser1.resample(weight=wt,suffix=_2)
will append “_2” to the SER1 for the name of the new series, SER_2. The rows in the sample will be drawn with probabilities proportional to the corresponding values in the series WT. WT must have non-missing non-negative values in the current workfile sample.
Cross-references
See
“Resample” for a discussion of the resampling procedure. For additional discussion of wildcards, see
Appendix A. “Wildcards”.
See also
@resample and
@permute for sampling from matrices.