1
矢量我在R上的下面的代碼:創建輸出
z <- scale(x)/sqrt(n-1) # standardized matrix x such that z'z=correlation matrix
R <- t(z) %*% z # correlation matrix
I <- diag(py - 1) # identity matrix(py defined before)
df <- rep(0, length(k)) # k=seq(0,5,0.001)
for (i in seq(0,5,0.001)) {
H <- z %*% solve(R+(i*I)) %*% t(z)
tr <- sum(diag(H))
df <- c(df,tr) ## problem here
}
在最後一行代碼並不好,因爲我要的是從tr
用於讀取每個號碼的載體(df
)每個我,以便DF返回一個載體,其中包含所有tr
。
任何幫助表示讚賞。
謝謝
非常感謝,非常有幫助 – 2011-04-02 08:26:09