Randomly draw from the rows of the data object.
Syntax: @resample(m[, n1, n2, v])
m: data object
n1: (optional) integer
n2: (optional) positive integer
v: (optional) vector
Output: data object
Returns a data object whose rows are randomly drawn with replacement from rows of the input matrix or vector.
By default, the output matrix will be the same size as the source m.
• represents the number of “extra” rows to be drawn from the matrix. If the input matrix has
r rows and
c columns, the output matrix will have
rows and
columns. By default,
.
• represents the block size for the resample procedure. If you specify
, then blocks of consecutive rows of length
will be drawn with replacement from the first
rows of the input matrix.
• You may provide a name for the vector
to be used for weighted resampling. The weighting vector must have length
and all elements must be non-missing and non-negative. If you provide a weighting vector, each row of the input matrix will be drawn with probability proportional to the weights in the corresponding row of the weighting vector. (The weights need not sum to 1. EViews will automatically normalize the weights).
To draw without replacement from rows of a matrix, use
@permute.
Examples
matrix xb = @resample(x)
yields the matrix XB whose rows were randomly sampled with replacement from the matrix X.
Cross-references