相关矩阵的VBA函数,无需调用任何工作表函数
我正在寻找一种计算束OB观察的相关矩阵的方法。到目前为止,我的试验是:
Function VarCovar(Rng As range) As Variant
Dim i As Integer
Dim j As Integer
Dim numcols As Integer
numcols = Rng.Columns.Count
Dim matrix() As Double
ReDim matrix(numcols - 1, numcols - 1)
For i = 1 To numcols
For j = 1 To numcols
matrix(i - 1, j - 1) = Application.WorksheetFunction.Covar(Rng.Columns(i), Rng.Columns(j))
Next j
Next i
VarCovar = matrix
End Function
但是,我想对此application.worksheetfunction.covar
part,并将其明确写入代码。有人会介意帮助我吗? 多谢 此致 托马斯
i'm looking for a way to calculate a correlation matrix of a bunch ob observations. My trials are so far this:
Function VarCovar(Rng As range) As Variant
Dim i As Integer
Dim j As Integer
Dim numcols As Integer
numcols = Rng.Columns.Count
Dim matrix() As Double
ReDim matrix(numcols - 1, numcols - 1)
For i = 1 To numcols
For j = 1 To numcols
matrix(i - 1, j - 1) = Application.WorksheetFunction.Covar(Rng.Columns(i), Rng.Columns(j))
Next j
Next i
VarCovar = matrix
End Function
However, i'd like to aviod this Application.WorksheetFunction.Covar
part and write it explicitly in the code. Would anyone mind to help me?
Thanks a lot
Best regards
Thomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论