Here is an example using data on gallons per 1000 miles and weight in pounds for 22 foreign cars (meaning, cars made outside the United States) from Stata's auto
data (and before that from Chambers, J.M., W.S. Cleveland, B. Kleiner and P.A. Tukey. 1983. Graphical Methods for Data Analysis. Belmont, CA: Wadsworth).
The data
clear
input float gpm int weight
58.82353 2830
43.47826 2070
40 2650
43.47826 2370
28.57143 2020
41.66667 2280
47.61905 2750
47.61905 2130
40 2240
35.714287 1760
33.333332 1980
71.42857 3420
38.46154 1830
28.57143 2050
55.55556 2410
32.258064 2200
55.55556 2670
43.47826 2160
24.390244 2040
40 1930
40 1990
58.82353 3170
end
The regression coefficient in a one-predictor regression of standardized variables, i.e. each scaled to (value $-$ mean) / SD, is equal to the Pearson correlation.
. egen gpm_std = std(gpm)
. egen weight_std = std(weight)
. reg gpm_std weight_std
Source | SS df MS Number of obs = 22
-------------+---------------------------------- F(1, 20) = 40.22
Model | 14.025405 1 14.025405 Prob > F = 0.0000
Residual | 6.97459503 20 .348729751 R-squared = 0.6679
-------------+---------------------------------- Adj R-squared = 0.6513
Total | 21 21 1 Root MSE = .59053
------------------------------------------------------------------------------
gpm_std | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight_std | .8172371 .128865 6.34 0.000 .5484295 1.086045
_cons | 9.00e-09 .1259022 0.00 1.000 -.2626273 .2626273
------------------------------------------------------------------------------
. corr gpm weight
(obs=22)
| gpm weight
-------------+------------------
gpm | 1.0000
weight | 0.8172 1.0000
The regression coefficient in a one-predictor regression of ranks that are also standardized variables, i.e. each scaled to (value $-$ mean) / SD, is equal to the Spearman correlation of the original variables.
. egen gpm_rank = rank(gpm)
. egen gpm_rank_std = std(gpm_rank)
. egen weight_rank = rank(weight)
. egen weight_rank_std = std(weight_rank)
. regress gpm_rank_std weight_rank_std
Source | SS df MS Number of obs = 22
-------------+---------------------------------- F(1, 20) = 27.73
Model | 12.2003095 1 12.2003095 Prob > F = 0.0000
Residual | 8.79969068 20 .439984534 R-squared = 0.5810
-------------+---------------------------------- Adj R-squared = 0.5600
Total | 21.0000002 21 1.00000001 Root MSE = .66331
--------------------------------------------------------------------------------
gpm_rank_std | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---------------+----------------------------------------------------------------
weight_rank_~d | .762212 .1447468 5.27 0.000 .4602754 1.064149
_cons | 4.40e-09 .1414189 0.00 1.000 -.2949946 .2949946
--------------------------------------------------------------------------------
. spearman gpm weight if foreign
Number of obs = 22
Spearman's rho = 0.7622
Test of Ho: gpm and weight are independent
Prob > |t| = 0.0000