different results when using the same data for rcorr() , correlation

I used the rcorr() package, next to make the output more readable I tried using correlation()
When I did this I got p-values that did not match. For example, the p-value using rcorr for (Trips, OTP) was .0653, while for correlation() was > .999. Why are these values different, and what can I do to fix this?

newdat <- data.frame(Trips = c(103397, 105672, 103762, 108791, 109794),
                  Missed = c(1636, 2043, 2464, 3642, 3706),
                  Early = c(483, 407, 465, 481, 461),
                  Late = c(1287, 1057, 848, 883, 931),
                  Runs = c(11070, 10664, 10691, 10664, 11014),
                  Closed = c(2629, 2701, 2794, 3181, 3521),
                  Mileage = c(992142, 997744, 952024, 940950, 875145),
                  VOM = c(311, 321, 304, 298, 284),
                  VAM = c(485, 494, 505, 207, 507),
                  OTP = c(.8441, .7994, .7625, .7124, .7079))
 newdat                 
#>    Trips Missed Early Late  Runs Closed Mileage VOM VAM    OTP
#> 1 103397   1636   483 1287 11070   2629  992142 311 485 0.8441
#> 2 105672   2043   407 1057 10664   2701  997744 321 494 0.7994
#> 3 103762   2464   465  848 10691   2794  952024 304 505 0.7625
#> 4 108791   3642   481  883 10664   3181  940950 298 207 0.7124
#> 5 109794   3706   461  931 11014   3521  875145 284 507 0.7079
 library("Hmisc")
#> Loading required package: lattice
#> Loading required package: survival
#> Loading required package: Formula
#> Loading required package: ggplot2
#> 
#> Attaching package: 'Hmisc'
#> The following objects are masked from 'package:base':
#> 
#>     format.pval, units
 
 
 res2<- rcorr(as.matrix(newdat))
 res2
#>         Trips Missed Early  Late  Runs Closed Mileage   VOM   VAM   OTP
#> Trips    1.00   0.92  0.03 -0.49  0.00   0.93   -0.77 -0.72 -0.45 -0.85
#> Missed   0.92   1.00  0.26 -0.73 -0.11   0.94   -0.87 -0.85 -0.51 -0.98
#> Early    0.03   0.26  1.00  0.01  0.41   0.23   -0.30 -0.52 -0.39 -0.16
#> Late    -0.49  -0.73  0.01  1.00  0.60  -0.56    0.59  0.51  0.31  0.85
#> Runs     0.00  -0.11  0.41  0.60  1.00   0.17   -0.26 -0.34  0.41  0.25
#> Closed   0.93   0.94  0.23 -0.56  0.17   1.00   -0.95 -0.92 -0.27 -0.90
#> Mileage -0.77  -0.87 -0.30  0.59 -0.26  -0.95    1.00  0.97  0.07  0.85
#> VOM     -0.72  -0.85 -0.52  0.51 -0.34  -0.92    0.97  1.00  0.18  0.80
#> VAM     -0.45  -0.51 -0.39  0.31  0.41  -0.27    0.07  0.18  1.00  0.45
#> OTP     -0.85  -0.98 -0.16  0.85  0.25  -0.90    0.85  0.80  0.45  1.00
#> 
#> n= 5 
#> 
#> 
#> P
#>         Trips  Missed Early  Late   Runs   Closed Mileage VOM    VAM    OTP   
#> Trips          0.0293 0.9659 0.4012 0.9940 0.0231 0.1269  0.1720 0.4506 0.0653
#> Missed  0.0293        0.6741 0.1637 0.8587 0.0158 0.0569  0.0674 0.3768 0.0036
#> Early   0.9659 0.6741        0.9828 0.4926 0.7147 0.6266  0.3720 0.5120 0.7915
#> Late    0.4012 0.1637 0.9828        0.2827 0.3315 0.2959  0.3794 0.6125 0.0689
#> Runs    0.9940 0.8587 0.4926 0.2827        0.7792 0.6771  0.5757 0.4895 0.6836
#> Closed  0.0231 0.0158 0.7147 0.3315 0.7792        0.0129  0.0273 0.6571 0.0397
#> Mileage 0.1269 0.0569 0.6266 0.2959 0.6771 0.0129         0.0062 0.9158 0.0690
#> VOM     0.1720 0.0674 0.3720 0.3794 0.5757 0.0273 0.0062         0.7746 0.1007
#> VAM     0.4506 0.3768 0.5120 0.6125 0.4895 0.6571 0.9158  0.7746        0.4444
#> OTP     0.0653 0.0036 0.7915 0.0689 0.6836 0.0397 0.0690  0.1007 0.4444
 library(correlation)
 
 correlation::correlation(newdat,
                          include_factors = TRUE, method = "auto"
 )
#> # Correlation Matrix (auto-method)
#> 
#> Parameter1 | Parameter2 |         r |         95% CI |      t(3) |      p
#> -------------------------------------------------------------------------
#> Trips      |     Missed |      0.92 | [ 0.17,  0.99] |      3.93 | > .999
#> Trips      |      Early |      0.03 | [-0.88,  0.89] |      0.05 | > .999
#> Trips      |       Late |     -0.49 | [-0.96,  0.69] |     -0.98 | > .999
#> Trips      |       Runs | -4.70e-03 | [-0.88,  0.88] | -8.14e-03 | > .999
#> Trips      |     Closed |      0.93 | [ 0.25,  1.00] |      4.30 | 0.946 
#> Trips      |    Mileage |     -0.77 | [-0.98,  0.35] |     -2.10 | > .999
#> Trips      |        VOM |     -0.72 | [-0.98,  0.45] |     -1.79 | > .999
#> Trips      |        VAM |     -0.45 | [-0.95,  0.72] |     -0.87 | > .999
#> Trips      |        OTP |     -0.85 | [-0.99,  0.11] |     -2.85 | > .999
#> Missed     |      Early |      0.26 | [-0.81,  0.93] |      0.46 | > .999
#> Missed     |       Late |     -0.73 | [-0.98,  0.43] |     -1.84 | > .999
#> Missed     |       Runs |     -0.11 | [-0.90,  0.85] |     -0.19 | > .999
#> Missed     |     Closed |      0.94 | [ 0.37,  1.00] |      4.95 | 0.663 
#> Missed     |    Mileage |     -0.87 | [-0.99,  0.06] |     -3.02 | > .999
#> Missed     |        VOM |     -0.85 | [-0.99,  0.13] |     -2.81 | > .999
#> Missed     |        VAM |     -0.51 | [-0.96,  0.67] |     -1.03 | > .999
#> Missed     |        OTP |     -0.98 | [-1.00, -0.71] |     -8.31 | 0.164 
#> Early      |       Late |      0.01 | [-0.88,  0.89] |      0.02 | > .999
#> Early      |       Runs |      0.41 | [-0.74,  0.95] |      0.78 | > .999
#> Early      |     Closed |      0.23 | [-0.82,  0.92] |      0.40 | > .999
#> Early      |    Mileage |     -0.30 | [-0.93,  0.79] |     -0.54 | > .999
#> Early      |        VOM |     -0.52 | [-0.96,  0.67] |     -1.05 | > .999
#> Early      |        VAM |     -0.39 | [-0.95,  0.75] |     -0.74 | > .999
#> Early      |        OTP |     -0.16 | [-0.91,  0.84] |     -0.29 | > .999
#> Late       |       Runs |      0.60 | [-0.60,  0.97] |      1.31 | > .999
#> Late       |     Closed |     -0.56 | [-0.96,  0.64] |     -1.16 | > .999
#> Late       |    Mileage |      0.59 | [-0.61,  0.97] |      1.26 | > .999
#> Late       |        VOM |      0.51 | [-0.68,  0.96] |      1.03 | > .999
#> Late       |        VAM |      0.31 | [-0.79,  0.94] |      0.56 | > .999
#> Late       |        OTP |      0.85 | [-0.13,  0.99] |      2.78 | > .999
#> Runs       |     Closed |      0.17 | [-0.84,  0.92] |      0.31 | > .999
#> Runs       |    Mileage |     -0.26 | [-0.93,  0.81] |     -0.46 | > .999
#> Runs       |        VOM |     -0.34 | [-0.94,  0.77] |     -0.63 | > .999
#> Runs       |        VAM |      0.41 | [-0.74,  0.95] |      0.79 | > .999
#> Runs       |        OTP |      0.25 | [-0.81,  0.93] |      0.45 | > .999
#> Closed     |    Mileage |     -0.95 | [-1.00, -0.43] |     -5.33 | 0.555 
#> Closed     |        VOM |     -0.92 | [-0.99, -0.20] |     -4.04 | > .999
#> Closed     |        VAM |     -0.27 | [-0.93,  0.80] |     -0.49 | > .999
#> Closed     |        OTP |     -0.90 | [-0.99, -0.06] |     -3.49 | > .999
#> Mileage    |        VOM |      0.97 | [ 0.61,  1.00] |      6.93 | 0.271 
#> Mileage    |        VAM |      0.07 | [-0.87,  0.90] |      0.11 | > .999
#> Mileage    |        OTP |      0.85 | [-0.13,  0.99] |      2.78 | > .999
#> VOM        |        VAM |      0.18 | [-0.84,  0.92] |      0.31 | > .999
#> VOM        |        OTP |      0.80 | [-0.27,  0.99] |      2.35 | > .999
#> VAM        |        OTP |      0.45 | [-0.72,  0.95] |      0.88 | > .999
#> 
#> p-value adjustment method: Holm (1979)
#> Observations: 5

Created on 2022-03-12 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.