[R] cov2cor exp
wacguy
gw57 at duke.edu
Wed Sep 18 19:28:39 CEST 2013
Ok, Thanks foe the answer, Ken:
*1L, 2L etc are integers. (That is, identical to as.integer(1) ,
as.integer(2) etc)
Using integers (instead of "numeric" type) is more efficient as here they're
used as indexes and would be converted to integer anyway.
Compare
> is(1)
... and
> is(1L)
1L:p is the sequence 1, 2, 3, ..., p (just like 1:p)
Just for curiosity, what is findFn('cov2cor') ?
Regards,
Kenn*
I don't know what findFn('cov2cor') is, I'm a total newbie to R but I
created a new, simpler to my opinion function for some descriptive
statistics as matrix functions for a matrix called "x":
one1=c(rep(1, nrow(x)))
means <- t(one1)%*%x/3#row vector of means
M=one1%*%means#A × matrix where each column is filled with the mean
value for that column
D=x-M#deviation matrix
S=(t(D)%*%D)/(nrow(x)-1)#Covariance matrix
R=function(S){###R is a Correlation matrix###
V=matrix(nrow=nrow(S),ncol=ncol(S))
V1 <- sqrt(1/diag(S))
diag(V)=V1
V[is.na(V)]=0
R=V%*%S%*%V
return(R)
}
R(S)
--
View this message in context: http://r.789695.n4.nabble.com/cov2cor-exp-tp4676395p4676450.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list