1

I'm trying the DescTools package with the standard d.pizza datafile. When I try to do a bivariate analysis on the data it gives 0's for the correlation coefficients and I don't know how to change that.

Desc(price ~ delivery_min, d.pizza)

price ~ delivery_min (d.pizza)

Summary: 
n pairs: 1,209.0000, valid: 1,197.0000 (99.0%), missings: 12.0000 (1.0%)

Pearson corr. : 0
Spearman corr.: 0
Kendall corr. : 0
Anonymous
  • 11
  • 2
  • please provide your d.pizza dataset so we can reproduce the code, also include library() which you used – yuliaUU Jul 31 '22 at 18:49

1 Answers1

0

You elaborate further in a comment that all correlations are reported as 1, 0 or -1.

Since the correlation coefficient varies between -1 and 1, the evidence strongly suggests that you get rounded numbers: correlations between -1 and -0.5 are shows as -1; correlations between -0.5 and 0.5 are shown as 0; and correlations between 0.5 and 1 as 1. Surely this is not what you intend.

Why the output is rounded is not clear (have you changed any default settings?) and the issue is not reproducible. Here is what I get when I repeat your steps:

library("DescTools")

Desc(price ~ delivery_min, d.pizza)
#> ------------------------------------------------------------------------------ 
#> price ~ delivery_min (d.pizza)
#> 
#> Summary: 
#> n pairs: 1'209, valid: 1'197 (99.0%), missings: 12 (1.0%)
#> 
#> 
#> Pearson corr. : 0.095
#> Spearman corr.: 0.080
#> Kendall corr. : 0.054

Created on 2022-07-27 by the reprex package (v2.0.1)

dipetkov
  • 3,380
  • 1
  • 11
  • 19
  • Yes it is. With other variables it sometimes becomes 1 or -1 but it's always a single digit. – Anonymous Jul 27 '22 at 11:15
  • Then most likely somewhere in your code you've specified numbers to be rounded. In any case, we can't see what's happening on your computer. – dipetkov Jul 27 '22 at 11:16
  • PS. "Reproducible" means that others get the same results when they repeat your steps. This doesn't seem to be happening here. – dipetkov Jul 27 '22 at 11:17
  • Oh right, I thought you meant it happened more often for me. As far as I know I've not changed any default settings. I did try increasing digits with options and format after googling but nothing helped. How would you go about rounding numbers or unrounding them? – Anonymous Jul 28 '22 at 06:35
  • I can't help you debug an issue I can't reproduce, esp. since I suspect there are many lines of code before this one that you haven't shown us. My advice is to restart R to clean the environment and check whether you have the problem. Then run parts of your analysis and keep checking until you figure out what causes this. – dipetkov Jul 28 '22 at 06:56