单相关系数偏相关系数和复相关系数在计算上有什么联系,复相关系数和偏相关系数的关系
根据四个要素的48个样本数据,计算得到的简单相关系数如下,试计算各级偏相关系数和复相关系数,并对其显著性进行检验。
1 .导入数学2。将numpy作为NP 3导入。进口熊猫当PD 4。将pingouin作为pg 5导入.6.a=np.array([[1,0.9954,0.9994,0.9989],7 .[0.9954,1,0.9926,0.9923], 8.[0.9904,0.9926,1,0.9977], 9.[0.9989,0.9923,0.9977,1]],dtype=float) 10 .11.r231=(a[1,2]-a[0,1]*a[0,2])/((1-a[0,1]**2)*(1-a[0,2]**2))**0.5 12 .13.r241=(a[1,3]-a[0,1]*a[0,3])/((1-a[0,1]**2)*(1-a[0,3]**2))**0.5 14 .15.r341=(a[2,3]-a[0,2]*a[0,3])/((1-a[0,2]**2)*(1-a[0,3]**2))**0.5 16 .17.r132=(a[0,2]-a[0,1]*a[1,2])/((1-a[0,1]**2)*(1-a[1,2]**2))**0.5 18 .19.r142=(a[0,3]-a[0,1]*a[1,3])/((1-a[0,1]**2)*(1-a[1,3]**2))**0.5 20 .21.r342=(a[2,3]-a[1,2]*a[1,3])/((1-a[1,2]**2)*(1-a[1,3]**2))**0.5 22 .23.r123=(a[0,1]-a[0,2]*a[1,2])/((1-a[0,2]**2)*(1-a[1,2]**2))**0.5 24 .25.r143=(a[0,3]-a[0,2]*a[2,3])/((1-a[0,2]**2)*(1-a[2,3]**2))**0.5 26 .27.r243=(a[1,3]-a[1,2]*a[2,3])/((1-a[1,2]**2)*(1-a[2,3]**2))**0.5 28 .29.r124=(a[0,1]-a[0,3]*a[1,3])/((1-a[0,3]**2)*(1-a[1,3]**2))**0.5 30 .31.r134=(a[0,2]-a[0,3]*a[2,3])/((1-a[0,3]**2)*(1-a[2,3]**2))**0.5 32 .33.r234=(a[1,2]-a[1,3]*a[2,3])/((1-a[1,3]**2)*(1-a[2,3]**2))**0.5 34 .打印(r231)打印(r241) 37打印(r341)打印(r132) 39。打印(r142) 40。打印(r342)打印(r123) 42打印(r134) 43。打印(r234)
1 .t231=(r231/((1-r231 * * 2)* * 0.5))*(45 * * 0.5)2 .3 .t241=(r241/((1-r241 * * 2)* * 0.5))*(45 * * 0.5)4 .5 .t341=(r341/((1-r341 * * 2)* * 0.5))*(45 * * 0.5)6 .7 .t132=(r143/((1-r132 * * 2)* * 0.5))*(45 * * 0.5)8 .9 .t142=(r231/((1-r142 * * 2)* * 0.5))*(45 * * 0.5)10 .11 .t342=(r342/((1-r342 * * 2)* * 0.5))*(45 * * 0.5)12 .13 .t123=(r123/((1-r123 * * 2)* * 0.5))*(45 * * 0.5)14 .15 .t134=(r134/((1-r134 * * 2)* * 0.5))*(45 * * 0.5)16 .17 .t234=(r234/((1-r234 * * 2)* * 0.5))*(45 * * 0.5)18 .19 .打印(t231)打印(t241) 21打印(t341) 22。打印(t132) 23打印(t142) 24打印(t342) 25。打印(t123) 26打印(t134) 27打印(t234)
1.1234=(r123-r143 * r243)/((1-r143 * * 2)*(1-r243 * * 2))* * 0.5 2 .3 .r 1324=(r132-r142 * r342)/((1-r142 * * 2)*(1-r342 * * 2))* * 0.5 4 .5 .r 1423=(r142-r132 * r342)/((1-r132 * * 2)*(1-r342 * * 2))* * 0.5 6 .7 .r 2314=(r231-r241 * r341)/((1-r241 * * 2)*(1-r341 * * 2))* * 0.5 8 .9 .r 2413=(r241-r231 * r341)/((1-r231 * * 2)*(1-r341 * * 2))* * 0.5 10 .11 .r 3412=(r341-r231 * r241)/((1-r231 * * 2)*(1-r241 * * 2))* * 0.5 12 .13 .打印(r1234) 14。打印(r1324) 15。打印(r1423) 16。打印(r2314) 17。打印(r2413) 18。打印(r3412) #二级偏相关系数的显著性检验,也采用的是T检验,代码实现(python):1。t 1234=(r 1234/((1-r 1234 * * 2)* * 0.5))*(45 * * 0.5)2 .3 .t 1324=(r 1324/((1-r 1324 * * 2)* * 0.5))*(45 * * 0.5)4 .5 .t 1423=(r 1423/((1-r 1423 * * 2)* * 0.5))*(45 * * 0.5)6 .7 .t 2314=(r 2314/((1-r 2314 * * 2)* * 0.5))*(45 * * 0.5)8 .9 .t 2413=(r 2413/((1-r 2413 * * 2)* * 0.5))*(45 * * 0.5)10 .11 .t 3412=(r 3412/((1-r 3412 * * 2)* * 0.5))*(45 * * 0.5)12 .13 .打印(t1234) 14。打印(t1324) 15。打印(t1423) 16。打印(t2314) 17打印(t2413) 18打印(t3412)
1 .ry 1234=(1-(1-0.9954 * * 2)*(1-r132 * * 2)*(1-r1423 * * 2))2 .3 .ry 2134=(1-(1-0.9926 * * 2)*(1-r243 * * 2)*(1-r 3412 * * 2))4 .5 .ry 3124=(1-(1-0.9977 * * 2)*(1-r341 * * 2)*(1-r 2413 * * 2))6 .7 .ry 4123=(1-(1-0.9989 * * 2)*(1-r241 * * 2)*(1-r 1234 * * 2))8。印刷(ry 1234)9。打印(ry 2134)10。打印(ry 3124)11。打印(ry 4123)
1 . f 1234=(ry 1234 * * 2/(1-ry 1234 * * 2))*(44/3)2 .f 2134=(ry 2134 * * 2/(1-ry 2134 * * 2))*(44/3)3 .f 3124=(ry 3124 * * 2/(1-ry 3124 * * 2))*(44/3)4 .f 4123=(ry 4123 * * 2/(1-ry 4123 * * 2))*(44/3)5 .6 .打印(F1234) 7。打印(2134) 8。打印(F3124) 9。打印(F4123)