Description Usage Arguments Details Value Note Author(s) Examples

View source: R/unconditional.sort.R

Calculates out-of-sample mean sub-portfolio returns and the composition of each sub-portfolio using the unconditional portfolio sorting method.

1 |

`Fa` |
xts-object containing data for the first dimension of sort |

`Fb` |
xts-object containing data for the second dimension of sort (optional) |

`Fc` |
xts-object containing data for the third dimension of sort (optional) |

`R.Forward` |
xts-object containing forward returns |

`dimA` |
vector of break points between 0 and 1 |

`dimB` |
vector of break points between 0 and 1 (optional) |

`dimC` |
vector of break points between 0 and 1 (optional) |

`type` |
pass-through parameter to the |

The unconditional sort function sorts assets based on each factor (Fa to Fc) from low to high independently at each time *t* and forms sub-portfolios based on the intersection between them. Based on the sorted assets in each sub-portfolio at time *t*, mean out-of-sample sub-portfolio returns are computed for time *t+1*. The function outputs out-of-sample returns for each sub-portfolio in columns and a list of the sub-portfolio constituents at each rebalancing point.

`returns` |
Out-of-sample sub-portfolio returns |

`portfolio` |
List of the sub-portfolio constituents over time |

The function implicitly handles NA/NaN or Inf values at each rebalancing point (at time *t*) by excluding them from the `quantile`

function. Furthermore, if there are any NA, NaN or Inf values in the R.Forward object when computing out-of-sample returns, these are also excluded. The function outputs returns in columns. For example, if a double sort is conducted with both Fa and Fb including 3 breakpoints (a 3v3) sort, column 1 will contain out-of-sample returns for the 'Low-Low' sub-portfolio, column 4 will contain out-of-sample returns for the 'Mid-Low' sub-portfolio whilst column 9 will contain the 'High-High' sub-portfolio returns.

Jonathan Spohnholtz and Alexander Dickerson

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
# Load the included data
library(portsort)
data(Factors)
# Specifiy the sort dimension - in this case, a double sort on lagged returns and Bitcoin volumes
# with 4 breakpoints (a 4v4 sort)
dimA = c(0,0.25,0.5,0.75,1)
dimB = c(0,0.25,0.5,0.75,1)
# Specify the factors for the double sort
# Lagged returns, lagged volumes are stored in the Factors list
R.Forward = Factors[[1]]; R.Lag = Factors[[2]]; V.Lag = Factors[[3]]
# Subset the data from late 2017
R.Forward = R.Forward["2017-12-01/"]
R.Lag = R.Lag["2017-11-30/2018-09-05"]
V.Lag = V.Lag["2017-11-30/2018-09-05"]
Fa = R.Lag
Fb = V.Lag
# Conduct an unconditional sort
sort.output <- conditional.sort(Fa,Fb,Fc=NULL,R.Forward = R.Forward,dimA = dimA,dimB = dimB)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.