# Estimation of ranks of log-returns via copula

I have successfully chosen and estimate a copula for the ranks of the log-returns of my actions. My question is, since I have worked with the ranks instead of directly the log-returns (in order to be in $[0,1]$) how can I simulate new data for the log-returns from my copula?

To be more clear, here is the code commented:

library(copula)
library(quantmod)
#stocks chosen: Microsoft, General Electric
stocks<-c("MSFT","GE")
start="1996-01-01"
end="2000-12-31"
ALL<-NULL
dailyLogReturns<-NULL
cours<-NULL
for(i in stocks){
#get quotes from Yahoo
temp<-getSymbols(i,from=start,to=end,auto.assign=FALSE)
#adjusted quotes are used due to split actions in the past
#calculate daily log return for adjusted quotes
}
colnames(cours)<-stocks
colnames(dailyLogReturns)<-stocks
#ALL is the ranks of the log-returns, in [0,1]
ALL<-pobs(dailyLogReturns)

#Here is the graph of the daily log-returns
plot(dailyLogReturns) #Here is the graph of the ranks of the daily log-returns
plot(ALL) #Estimate the copula
#here i only show the Student, others have been tried without success.
#degres of freedom have been chosen independently
tc<-tCopula(param=c(0),dim=2,dispstr="un",df=7, df.fixed=TRUE)
ftc <- fitCopula(tc,ALL,method="mpl")

#Goodness of fit for the copula, p-value is about 40%
time.start=Sys.time()
GOF<-gofCopula(tc, ALL, estim.method="mpl", simulation="mult")
Sys.time()-time.start
(GOF\$p.value>0.05)

#New data sample from the copula
Copula.data<-rCopula(1000,tCopula(0.417,df=7))
plot.new()
par(oma=c(1,1,1,1),mar=c(1,1,1,1))
plot(Copula.data,main="",xlab="",ylab="",col="red",pch="*");points(ALL,col="blue",pch="*")

#Here is the plot: new data from copula (red) vs initial data (blue) ## So, what have I tried?

I used the quantile function based on 1000 observations of daily log-returns to calibrate and 263 observations for back-testing

nb.calibration<-1000
nb.backtesting<-nrow(dailyLogReturns)-nb.calibration
a<-matrix(0,nb.backtesting,nb.calibration)
b<-matrix(0,nb.backtesting,nb.calibration)
for(i in 1:nb.backtesting){
j=1+i;k=nb.calibration+i
a[i,]=dailyLogReturns[j:k,1]
b[i,]=dailyLogReturns[j:k,2]
rmtc<-quantile(a[i,],Copula.data[,1])+quantile(b[i,],Copula.data[,2])
}

plot(rmtc,type='l')
lines(dailyLogReturns[,1],col='red')
lines(dailyLogReturns[,2],col='blue')
#Here is the plot obtained: new data from the copula (black), Microsoft (blue), GE (red) ## Finally: Am I doing the right thing, is that correct ?

• Good question. what progress have you made so far? do you still need some assistance? – user12348 May 15 '14 at 2:38