0
$\begingroup$

In univariate regression, the standardized coefficient is equal to the Pearson correlation coefficient. When the two variables are ranked variables, Spearman correlation would be appropriate. Is it possible to derive Spearman correlation coefficient from a univariate regression? It may be useful under the condition when testing correlation between two ranked variables within cluster/group, hence a Spearman test may not be directly applied and a mixed effect model is needed.

Thanks!

$\endgroup$
4
  • 1
    $\begingroup$ The first sentence is untrue unless you have standardized both variables. A Spearman correlation can be related to a regression of one ranked variable on another, but not otherwise. (I wouldn't call regression with one predictor univariate myself, although I've seen that usage.) $\endgroup$
    – Nick Cox
    Commented May 30, 2018 at 10:09
  • $\begingroup$ @NickCox Thanks, I have edited my question. I do not quite understand what your sentence means, if both variables are ranked, the Spearman correlation = regression standard coefficient, but the regression standard cofficient NOT = Spearman coefficient? $\endgroup$
    – Lumos
    Commented May 30, 2018 at 17:14
  • $\begingroup$ What do you mean by "standard coefficient"? It's not (hmm) a standard term that I know. $\endgroup$
    – Nick Cox
    Commented May 30, 2018 at 17:35
  • $\begingroup$ @NickCox Sorry, "standardized coefficient", my bad. $\endgroup$
    – Lumos
    Commented May 30, 2018 at 17:58

2 Answers 2

2
$\begingroup$

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
$\endgroup$
2
  • $\begingroup$ Thanks for using the empirical analysis for me. Can I generalize from here that the standardized coefficient = Pearson correlation if the variables are continuous; standardized coefficient = Spearman correlation if the variables are ranked? $\endgroup$
    – Lumos
    Commented May 30, 2018 at 18:41
  • 1
    $\begingroup$ Yes; the spirit is correct there, but strictly being continuous is neither here nor there for the problem. Discrete variables are fine, just as the last example is partly about correlation between discrete variables that happen to be ranks. $\endgroup$
    – Nick Cox
    Commented May 30, 2018 at 18:52
0
$\begingroup$

You cannot derive Spearman coefficients from linear regression (on the unranked variables). The Spearman correlation summarizes the monotonic trend. They are related but it's not a bijective relation. At best, you only if one is non-zero, the other is non-zero.

$\endgroup$
2
  • $\begingroup$ If the variables are categorical variables and I rank them first before I put them into a linear regression, the magnitude of the coefficient is not meaningful, but a relationship is supported if it is non-zero. Am I understand correctly? If that is correct, can I interpret the significance of the correlation from the p-value of the regression standardized coefficient? Thanks! $\endgroup$
    – Lumos
    Commented May 30, 2018 at 18:38
  • 1
    $\begingroup$ @Lumos Ranking won't make sense for all categorical variables; they have to be ordered at a minimum. $\endgroup$
    – Nick Cox
    Commented May 30, 2018 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.