29.constant_correlation_R_example - #CONSTANT CORRELATION...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #CONSTANT CORRELATION MODEL - EXAMPLE: #Read the data: data1 <- read.table("http://www.stat.ucla.edu/~nchristo/statistics_c183_c283/stocks_10.txt", header=TRUE) #Compute the average correlation: rho <- (sum(cor(data1[1:10]))-10)/90 #Initialize the vectors: col1 <- rep(0,10) col2 <- rep(0,10) col3 <- rep(0,10) #Initialize the var-covar matrix: y <- rep(0,100) mat <- matrix(y, ncol=10, nrow=10) #Compute necessary quantities: Rbar <- mean(data1[1:10]) Rbar_f <- Rbar-0.0003 sigma <- sd(data1[1:10]) Ratio <- Rbar_f/sigma #Initial table: xx <- (cbind(Rbar, Rbar_f, sigma, Ratio)) #Order the table based on the excess return to sigma ratio: aaa <- xx[order(-Ratio),] #Create the last 3 columns of the table: for(i in(1:10)) { col1[i] <- rho/(1-rho+i*rho) col2[i] <- sum(aaa[,4][1:i]) } #Compute the Ci: for(i in (1:10)) { col3[i] <- col1[i]*col2[i] } #Create the entire table until now: xxx <- cbind(aaa, col1, col2, col3) #SHORT SALES ALLOWED: #Compute the Zi: z <- (1/((1-rho)*xxx[,3]))*(xxx[,4]-xxx[,7][nrow(xxx)]) #Compute the xi: x <- z/sum(z) #The final table: aaaa <- cbind(xxx, z, x) #SHORT SALES NOT ALLOWED:...
View Full Document

This note was uploaded on 06/02/2011 for the course STATS 183 taught by Professor Nicolas during the Spring '11 term at UCLA.

Page1 / 2

29.constant_correlation_R_example - #CONSTANT CORRELATION...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online