如何在Julia中运行加权相关?在Stata,您可以运行corr x y [aw=weight]
查找列之间的相关性x
和y
使用weight
的权重。我在Julia中找不到相同的功能。
这是这样做的方法:
julia> using Statistics, StatsBase
julia> x = [1 2
3 4
1 -2
3 -4
5 -6]
5×2 Matrix{Int64}:
1 2
3 4
1 -2
3 -4
5 -6
julia> cor(x, Weights([1,1,0,0,0]))
2×2 Matrix{Float64}:
1.0 1.0
1.0 1.0
julia> cor(x, Weights([0,0,1,1,1]))
2×2 Matrix{Float64}:
1.0 -1.0
-1.0 1.0
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句