The index numbers are based on the model coefficient table that comes straight out of the model, with no sorting.

The function will return a dataframe with the results for each pair of coeeficients tested.

rankr(coeftable = NULL, vcovmat = NULL, mysongidlist = NULL)

Arguments

coeftable

coefficients table from mlogit, with one row per coefficient

vcovmat

variance covariance matrix from mlogit, with one row and one column per coefficient

mysongidlist

a dataframe containing the list of song ids to be tested. It can contain other variables but only songid will be used.

Details

rankr

Examples

songstobecompared <- summary %>% slice(seq(from=1, to=92, by=10))
mycomparisons <- rankr(coeftable = results_ml_Repeatr4, vcovmat = vcovmat_ml_Repeatr4, mysongidlist = songstobecompared)
#> 
#>  
#> First coefficient: 3.15410011862666 
#>  
#> Second coefficient: 0.556194899753802 
#>  
#> Difference to be tested: 2.59790521887286 
#>  
#> Variance of the first coefficient: 0.528235277021886 
#>  
#> Variance of the second coefficient: 0.0124891074988492 
#>  
#> Covariance of the two coefficients: 0.0016387992505919 
#>  
#> Z-statistic: 3.54368872931844 
#>  
#> P-statistic: 1.99960542920876 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: 1.16101427897077 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: 4.03479615877495 
#>  
#> 
#>  
#> First coefficient: 0.556194899753802 
#>  
#> Second coefficient: 3.01431445853816 
#>  
#> Difference to be tested: -2.45811955878436 
#>  
#> Variance of the first coefficient: 0.0124891074988492 
#>  
#> Variance of the second coefficient: 0.0046794363459201 
#>  
#> Covariance of the two coefficients: 0.00169180892121045 
#>  
#> Z-statistic: -20.9363409803388 
#>  
#> P-statistic: 2.49932545342412e-97 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: -2.68824163884323 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: -2.22799747872549 
#>  
#> 
#>  
#> First coefficient: 3.01431445853816 
#>  
#> Second coefficient: 1.57184389416361 
#>  
#> Difference to be tested: 1.44247056437455 
#>  
#> Variance of the first coefficient: 0.0046794363459201 
#>  
#> Variance of the second coefficient: 0.0494846260902958 
#>  
#> Covariance of the two coefficients: 0.00406706571721051 
#>  
#> Z-statistic: 6.72336668103597 
#>  
#> P-statistic: 1.99999999998224 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: 1.02196065612446 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: 1.86298047262463 
#>  
#> 
#>  
#> First coefficient: 1.57184389416361 
#>  
#> Second coefficient: 1.78114720183353 
#>  
#> Difference to be tested: -0.209303307669916 
#>  
#> Variance of the first coefficient: 0.0494846260902958 
#>  
#> Variance of the second coefficient: 0.0444326554597425 
#>  
#> Covariance of the two coefficients: 0.0206092237692128 
#>  
#> Z-statistic: -0.911749614761924 
#>  
#> P-statistic: 0.361900539424168 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: -0.659245349203058 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: 0.240638733863226 
#>  
#> 
#>  
#> First coefficient: 1.78114720183353 
#>  
#> Second coefficient: 3.43791820832147 
#>  
#> Difference to be tested: -1.65677100648794 
#>  
#> Variance of the first coefficient: 0.0444326554597425 
#>  
#> Variance of the second coefficient: 0.00569784656156396 
#>  
#> Covariance of the two coefficients: 0.00404870824434851 
#>  
#> Z-statistic: -8.08103243725475 
#>  
#> P-statistic: 6.42207239840726e-16 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: -2.05860965741897 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: -1.25493235555691 
#>  
#> 
#>  
#> First coefficient: 3.43791820832147 
#>  
#> Second coefficient: 2.20062999796656 
#>  
#> Difference to be tested: 1.23728821035491 
#>  
#> Variance of the first coefficient: 0.00569784656156396 
#>  
#> Variance of the second coefficient: 0.00389868718892827 
#>  
#> Covariance of the two coefficients: 0.0017020834387324 
#>  
#> Z-statistic: 15.7232578065369 
#>  
#> P-statistic: 2 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: 1.08305268727601 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: 1.39152373343382 
#>  
#> 
#>  
#> First coefficient: 2.20062999796656 
#>  
#> Second coefficient: 2.53411619602825 
#>  
#> Difference to be tested: -0.333486198061698 
#>  
#> Variance of the first coefficient: 0.00389868718892827 
#>  
#> Variance of the second coefficient: 0.0107625693703899 
#>  
#> Covariance of the two coefficients: 0.00171381562879152 
#>  
#> Z-statistic: -3.14642872030667 
#>  
#> P-statistic: 0.00165277542163832 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: -0.541224242144012 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: -0.125748153979383 
#>  
#> 
#>  
#> First coefficient: 2.53411619602825 
#>  
#> Second coefficient: 2.66301057328181 
#>  
#> Difference to be tested: -0.128894377253554 
#>  
#> Variance of the first coefficient: 0.0107625693703899 
#>  
#> Variance of the second coefficient: 0.057980060154878 
#>  
#> Covariance of the two coefficients: 0.00797617930683449 
#>  
#> Z-statistic: -0.560992463923153 
#>  
#> P-statistic: 0.574802674609498 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: -0.57922659321639 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: 0.321437838709283 
#>  
#> 
#>  
#> First coefficient: 2.66301057328181 
#>  
#> Second coefficient: -1.07987315490175 
#>  
#> Difference to be tested: 3.74288372818356 
#>  
#> Variance of the first coefficient: 0.057980060154878 
#>  
#> Variance of the second coefficient: 0.0804502488495918 
#>  
#> Covariance of the two coefficients: 0.0163387855450476 
#>  
#> Z-statistic: 11.5096078307829 
#>  
#> P-statistic: 2 
#>  
#> Lower boundary of 95% confidence interval of the difference between the two coefficients: 3.10549866562572 
#>  
#> Upper boundary of 95% confidence interval of the difference between the two coefficients: 4.3802687907414 
#>  
#> 
#> Joining with `by = join_by(songid1)`
#> Joining with `by = join_by(songid2)`
mycomparisons
#>                 song1               song2   mycoef1    mycoef2 mycoefdiff
#> 1        waiting room         provisional 3.1541001  0.5561949  2.5979052
#> 2         provisional           blueprint 0.5561949  3.0143145 -2.4581196
#> 3           blueprint              stacks 3.0143145  1.5718439  1.4424706
#> 4              stacks returning the screw 1.5718439  1.7811472 -0.2093033
#> 5 returning the screw      do you like me 1.7811472  3.4379182 -1.6567710
#> 6      do you like me        back to base 3.4379182  2.2006300  1.2372882
#> 7        back to base        floating boy 2.2006300  2.5341162 -0.3334862
#> 8        floating boy            the kill 2.5341162  2.6630106 -0.1288944
#> 9            the kill  turn off your guns 2.6630106 -1.0798732  3.7428837
#>           myz          myp  lower95ci  upper95ci
#> 1   3.5436887 1.999605e+00  1.1610143  4.0347962
#> 2 -20.9363410 2.499325e-97 -2.6882416 -2.2279975
#> 3   6.7233667 2.000000e+00  1.0219607  1.8629805
#> 4  -0.9117496 3.619005e-01 -0.6592453  0.2406387
#> 5  -8.0810324 6.422072e-16 -2.0586097 -1.2549324
#> 6  15.7232578 2.000000e+00  1.0830527  1.3915237
#> 7  -3.1464287 1.652775e-03 -0.5412242 -0.1257482
#> 8  -0.5609925 5.748027e-01 -0.5792266  0.3214378
#> 9  11.5096078 2.000000e+00  3.1054987  4.3802688