7
$\begingroup$

Using the package PerformanceAnalytics in R, I am trying to calculate the return of an equal-weighted portfolio that contains 30 assets. However, these assets do not have the same starting point in time, resulting in missing values for several assets from the beginning of the sample period. By default, PerformanceAnalytics ascribes a value of "0" to missing values, resulting in assets being assigned a positive weight in the portfolio, although these did not have any return data available.

Is there a possibility to have PerformanceAnalytics ignore the missing values and rebalance the portfolio once a new asset becomes available?

In advance, thank you for your helpful comments.

$\endgroup$

2 Answers 2

3
$\begingroup$

You can use Bayesian methods. Missing data is not an intrinsic problem for Bayesian methods, however, you do need to understand why the data is missing before you use Bayesian methods. In your case, it is because the firms did not exist. That is rather fortunate as this makes your case rather simple. It is a different problem if, for example, there was some reason data was missing such as you may see in other social science data such as embarrassment. Then you have a headache.

You need to develop prior distributions for the location of the center of location and for the scale parameter. Let us imagine that they start sequentially so that $X_1$ is the first series to begin, $X_2$ the second and $X_{30}$ the last. You would set a prior for the first until you were one observation before observing $X_2$. You would treat your posterior density from $X_1$ as the prior for $X_2$. I would weaken the scale parameter to cover the probability that the parameters for $X_2$ are not the same as $X_1$. Repeat until all series have begun.

For interior missing observations, such as day without a trade, you would estimate the distribution of possible values from prior observations and marginalize it out so that you would not lose information from the missing observations.

The alternative of using the mean value distorts the scale parameter and distorts any inference.

The third alternative, waiting until they all share a time series, wastes information.

See: http://www.bias-project.org.uk/papers/NonTechnicalMissingTalkSlides.pdf

If you have never used Bayesian methods, send me a question and I will provide some additional information.

$\endgroup$
1
$\begingroup$

You've two options:

  • Just use dates for which data is available for all assets

    1. Transform the price vectors to xts format

      test <- xts([returnvector1], order.by=[column with date])
      
    2. Merge the individual price vectors to one large return matrix

      PriceMat <- merge(test1, test2, test3,..., by=["Date"], all=FALSE)
      
    3. Transform price matrix to returns matrix library(quantmod)

      RetMat <- apply(PriceMat,2,Delt,type=geometric)
      

    It should work like this. I'm so sorry but I haven't the chance to check the code.

  • Fill with mean value

    You could first transform the price vectors to return vectors, and merge them afterwards (merge(retvec1, retvec2, all=TRUE)). The matrix you will get now, will have many NA values. Find those NAs overwrite them with mean-returns for the individual asset

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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