Displaying 2 results from an estimated 2 matches for "covab".
Did you mean:
colab
2008 Mar 16
2
How to loop through all the columns in dataframe
....4817,1.4957,1.4431,1.5676)
pd<-
c(0.017046,0.018504,0.012157,0.012253,0.012348,0.011997,0.012825)
td<- c(160524,163565,143973,111956,89677,95269,81558)
mydf<-data.frame(xd,pd,td)
trans<-t(mydf)
trans
I have these values that I need to include while
looping:
varA<- 0.0000036084
covAB<- (-0.0000013046)
varB<- 0.00000052628
After transposing my dataframe I need something like
the following:
varA + col1*covAB + col2*covAB + col1*col2*varB
varA + col1*covAB + col3*covAB + col1*col3*varB
varA + col1*covAB + col4*covAB + col1*col4*varB
varA + col1*covAB + col5*covAB +...
2004 Dec 21
3
R code for var-cov matrix given variances and correlations
...a vector of p variances (ordered varA, varB, ...,
varp) and a vector of all possible correlations (ordered corAB,
corAC, ..., corp-1,p)?
I know that the covariance between 2 variables is equal to the
product of their correlation and their standard deviations:
corAB * varA^.5 * varB^.5
and so:
covAB <- function(corAB, varA, varB) {
corAB * varA^.5 * varB^.5
}
If the vector of variances were
var.vec <- c(14, 12, 7)
and the vector of correlations were
cor.vec <- c(.4, .2, .5),
then the vector of covariances would be:
> covAB(c(.4, .2, .5),c(14, 14, 12), c(12, 7, 7))
[1] 5...