Duplicate group counts.
Count of the number of occurrences that are in each observation’s or row’s duplicate group.
Syntax: @dupsobs(x1,[x2, x3, ... ], [s])
x: series, alpha, group, vector, matrix
x#: series, alpha, group, vector, matrix
s: (optional) sample string or object when the x are series, alpha, and groups and assigning to series
Return: series, vector
For series, alpha, and groups, a duplicate is defined as two observations having identical values for all of variables given by the arguments.
For vectors and matrix objects, a duplicate is defined as two row identifiers having identical values in each of the vector and matrix objects given by the arguments.
Once the sets of duplicates are identified, the observations or rows are within each set are counted, and the function produces n, the number of observations in the group to which each observation belongs.
An observation containing a unique combination of values among series, alphas, or groups s1, s2, etc., will therefore have the value one, while any duplicated observation will have a value larger than one.
Examples
Let x be a series of length 10 that alternates between 0 and 1. Then
show @dupsobs(x)
will return a linked series whose observations are all 5s since the size of both groups is 5.
Let MAT be a matrix whose rows correspond to different observations. Then
vector dobs = @dupsobs(mat)
is a (column) vector of within-group observation IDs.
Cross-references