help for normalbvr (Roger Newson)

Generate Normal bivariate ridits

normalbvr newvarname [if exp] [in range] ,
x(expression_1) y(expression_2)
[ rho(expression_3)
mux(expression_4) muy(expression_5)
sdx(expression_6) sdy(expression_7)
float ]

where expressioni (for i from 1 to 7)
is a numeric expression. The numeric expression for each
option must be in the form required by the generate command. That is to say,
each expression must be specified so that the command

gene double newvarname=(expressioni)

will work.

Description

normalbvr inputs expressions specifying an X-variable and a Y-variable
and parameters for a bivariate normal distribution,
and generates a new variable,
containing bivariate ridits of the X-variable and the Y-variable
with respect to the specified bivariate Normal distribution.
Normal bivariate ridits are used in power calcuations for Kendall's tau-a.
If the X-variable and the Y-variable have the specified bivariate Normal distribution,
then the mean bivariate ridit is equal to the population Kendall's tau-a,
and the sampling variance of the sample Kendal's tau-a is equal
to 4 times the variance of the bivariate ridits
divided by the sample number.

Options

x(expression_1) must be specified.
It gives an expression for the X-variable.

y(expression_2) must be specified.
It gives an expression for the Y-variable.

rho(expression_3) gives an expression
for the correlation coefficient of the specified bivariate Normal distribution.
If not specified, it is set to zero.

mux(expression_4) gives an expression for the mean of the X-variable
in the specified bivariate Normal distribution.
If not specified, it is set to zero.

muy(expression_5) gives an expression for the mean of the Y-variable
in the specified bivariate Normal distribution.
If not specified, it is set to zero.

sdx(expression_6) gives an expression
for the standard deviation of the X-variable
in the specified bivariate Normal distribution.
If not specified, it is set to 1.

sdy(expression_7) gives an expression
for the standard deviation of the Y-variable
in the specified bivariate Normal distribution.
If not specified, it is set to 1.

float specifies that the output variable will have a storage type no higher than float.
If float is not specified, then normalbvr creates the output variable with storage type double.
Whether or not float is specified, normlbvr compresses the output variable as much as possible
without loss of precision. (See help for compress.)

Methods and Formulas

The bivariate ridit of an x-value and a y-value,
with respect to a bivariate distribution for a bivariate random variable (X,Y),
is equal to

B_XY(x,y) = E[sign(x-X)*sign(y-Y)]

or (equivalently) to the difference
between the probability that a random value of (X,Y) is concordant with (x,y)
and the probability that a random value of (X,Y) is discordant with (x,y).
The expectation and variance of the variable B_XY(X,Y)
are used in power calculations for Kendall's tau-a.
The population Kendall's tau-a is equal to the population mean of B_XY(X,Y),
and the standard deviation of the influence function of Kendall's tau-a
is equal to twice the population standard deviation of B_XY(X,Y).
The standard deviation of the influence function of a sample statistic
can be divided by the square root of the sample number
to obtain the asymptotic standard error of the sample statistic.

Note that bivariate ridits are defined on a scale fron -1 to 1,
by analogy with the univariate ridits defined by Brockett and Levene (1977).
For more about univariate ridits,
see the help for the SSC package wridit.

For more about estimating Kendall's tau-a in Stata,
using the SSC package somersd,
see Newson (2006).
For more about generalized power calculations
using standard deviations of influence functions,
and using the SSC package powercal,
see Newson (2004).
For more about the distribution theory of U-statistics
(such as Kendall's tau-a),
see Section 3.2 of Puri and Sen (1971).
For the application of this theory to power calculations for Kendall's tau-a,
see Newson (2018).

Examples

The first example generates 10000 observations,
each with a pair of values sampled from a standard bivariate Normal distribution
with a Pearson correlation cofficient of 0.5.
We then use normalbvr to compute the Normal bivariate ridits
in a new variable bvridit.
Finally, we use collapse to collapse the dataset to 1 observation,
containing the mean of bvridit in the variable taua,
which is an estimate for Kendall's tau-a,
and the standard deviation of the influence function
in a variable sdinf,
and list this summary datset.

. clear

. set seed 98765432

. set obs 10000

. scal rhoscal = 0.5

. gene xvar = rnormal()

. gene yvar = rhoscal*xvar + rnormal()*sqrt(1-rhoscal*rhoscal)

. normalbvr bvridit, x(xvar) y(yvar) rho(rhoscal)

. collapse (count) N=bvridit (mean) taua=bvridit (sd) sdinf=bvridit

. replace sdinf=2*sdinf

. list, abbr(32)

The second example first creates a dataset with 1 observation
for each of a sequence of 13 Pearson correlations
ranging from -1 to 1 by increments of 1/12,
stored in a variable rhovar.
We then use the SSC package expgen
to create an expanded dataset,
in which each observation in the original dataset
is replaced by 10000 observations,
and simulate, in each observation,
a pair of values in variables xvar and yvar,
sampled from a bivariate standard Normal distribution
with the Pearson correlation stored in rhovar.
After this, we use normalbvr to compute the Normal bivariate ridits,
and collapse the dataset to create a dataset with 1 observation per Pearson correlation,
and variables taua estimating the corresponding Kendall's tau-a
and sdinf estimatind the standard deviation of the influence function
for estimatin Kendall's tau-a.
This dataset, created using simulation, is listed,
and illustrates Greiner's relation between Kendall's tau-a and the Pearson correlation,
which is given by

taua = (2/_pi)*asin(rho)

and which holds for a bivariate Normal distribution.

. clear

. set seed 98765432

. set obs 25

. gene rhovar=(_n-13)/12

. sort rhovar

. expgen =10000, sortedby(unique) copyseq(xyseq)

. gene xvar = rnormal()

. gene yvar = rhovar*xvar + rnormal()*sqrt(1-rhovar*rhovar)

. normalbvr bvridit, x(xvar) y(yvar) rho(rhovar)

. collapse (count) N=bvridit (mean) taua=bvridit (sd) sdinf=bvridit, by(rhovar)

. replace sdinf=2*sdinf

. list, abbr(32)

Alternatively, we might use a grid of Normal percentiles,
instead of sampling by Monte Carlo simulation.
In either case, we are numerically integrating values for Kendall's tau-a
and the standard deviation of its influence function.
These can then be used in power calculations
by the SSC package powercal.

Author

Roger Newson, Imperial College London, UK.
Email: r.newson@imperial.ac.uk

References

Brockett, P. L., and Levene, A. 1977.
On a characterization of ridits.
The Annals of Statistics 5(6): 1245-1248.

Newson R.
2018.
Bivariate ridits and distribution theory for Kendall's tau-a.
Download from
Roger Newson's website.

Newson R.
2006.
Confidence intervals for rank statistics: Somers' D and extensions.
The Stata Journal 6(3): 309-334.
Download from
The Stata Journal website.

Newson R.
2004.
Generalized power calculations for generalized linear models and more.
The Stata Journal 4(4): 379-401.
Download from
The Stata Journal website.

Puri M. L., and Sen P. K.
1971.
Nonparametric Methods in Multivariate Statistics.
New York: John Wiley & Sons Inc.

Also see

Manual: [R] collapse

On-line: help for collapse

help for powercal, somersd, expgen, wridit (if installed)