Calculate correlation for more than two variables?

前端 未结 5 1661
眼角桃花
眼角桃花 2021-01-30 02:36

I use the following method to calculate a correlation of my dataset:

cor( var1, var2, method = \"method\")

But I like to create a correlation m

5条回答
  •  别那么骄傲
    2021-01-30 02:58

    See corr.test function in psych package:

    > corr.test(mtcars[1:4])
    Call:corr.test(x = mtcars[1:4])
    Correlation matrix 
           mpg   cyl  disp    hp
    mpg   1.00 -0.85 -0.85 -0.78
    cyl  -0.85  1.00  0.90  0.83
    disp -0.85  0.90  1.00  0.79
    hp   -0.78  0.83  0.79  1.00
    Sample Size 
         mpg cyl disp hp
    mpg   32  32   32 32
    cyl   32  32   32 32
    disp  32  32   32 32
    hp    32  32   32 32
    Probability value 
         mpg cyl disp hp
    mpg    0   0    0  0
    cyl    0   0    0  0
    disp   0   0    0  0
    hp     0   0    0  0
    

    And yet another shameless self-advert: https://gist.github.com/887249

提交回复
热议问题