Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

Is there any function for plotting the evolution of portfolio weights over time in r?. I have a matrix of portfolio weights from an equal weighting strategy at rebalancing times and want to plot weights of the stocks over time on a single plot.

for example:you want to backtest equal weight strategy where you allocate weights equally at each rebalancing dates for each stock. I have a matrix of weights:

             A       B            C       D              E           F

2001-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2002-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2003-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2004-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2005-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2006-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2007-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2008-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2009-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2010-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2011-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

I want to plot the stocks(A,B,..) on a single plot where the y axis will be the allocatons and x axis the time ie plotting a transition map for weights over time using R

Regards

share|improve this question

closed as off-topic by Richard, olaker Jun 30 at 10:54

  • This question does not appear to be about quantitative finance within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Could you please provide more information like e.g. code, an example matrix with the weights etc.? –  vonjd Jun 30 at 9:13
    
I think this is off-topic because in short you ask how to plot multvariate time series - right? Look at the xts package cran.r-project.org/web/packages/xts/index.html and get to know time formats in R. –  Richard Jun 30 at 10:29
2  
This is a simple programming question. –  Richard Jun 30 at 10:30
    
Although the question has been closed you can still upvote my answer and accept it if it was helpful - Thank you :-) –  vonjd Jun 30 at 14:03
    
Thank you, I was able to figure out what I really needed, I wanted stacked Area Graph to plot the weights over time. I used the ggplot after changing my time series object to long format.@vonjd –  user3481555 Jun 30 at 14:31

1 Answer 1

You can use the zoo package:

library(zoo)
W <- matrix(rep(0.03225806,66),nrow=11)
T <- seq(as.Date("2001-12-01"), as.Date("2011-12-01 "), "years")
M <- read.zoo(data.frame(T,W))
colnames(M) <- c(LETTERS[1:6])
plot.zoo(M)
plot.zoo(M,plot.type = "single")
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.