0
$\begingroup$

I'm not sure how feasible this is. I'm aware of how to generate correlated random numbers using a cholesky decomposition. However, say I have a fixed data set in increasing order (e.g. Price series: $10, $ 20, $ 30....$50). Now, I want to generated another series - of correlated quantities that follow the same order of increasing prices (so in the extreme case of 100% correl, Quantities have the exact same values - 10, 20, 30...50. But what would this look like if the correl were less than 100%). The idea is to see the impact on Total Revenue (P*Q) curve under different correlation assumptions. Cholesky did not work - as the Q series does not follow a specific order. I also tried using a regression say Q = a + bP; so if I changed b by changing the underlying correl..but that doesn't quite work (b = correl * stdev Q/stdev P; so I'll need to generate a new series that has the specified correl and stdev; it feels circular). In any case - this question itself might be daft...if so, please feel free to throw the eggs. But, if there's something possible - I'd love to know. thanks!

$\endgroup$
  • 1
    $\begingroup$ I posted an answer to this but deleted it as i don't think it addressed the major concern which was only visible to me after reading a few times. Personally I think this question a bit unclear and ambiguous in some of the definitions and other users will probably benefit if the question is reworked $\endgroup$ – Attack68 Sep 17 '17 at 21:47
  • $\begingroup$ @Attack68 - thanks, I'll try to make it a little more clear then. Here goes: 1. Simple case - I have a price and quantity series that are 100% correlated. So price series is 10 $/ton, 20, 30, 40, 50. The quantity series is 10tons, 20, 30, 40.I can use this to calculate Total Revenue = P*Q. Now say I want to keep the price series fixed, but generate the quantity series based on a different level of correlation (say 60% correlated to the static price series). (This is to see the impact of changing correls on Total Revenue.). Is it possible to generate this new quantity series? better? $\endgroup$ – Chet Sep 17 '17 at 22:30
  • $\begingroup$ Ok i'm interpreting your price series as not a time series of one commodity but a set of prices for five different commodities. The problem stated in your terms reduces to: generate a stochastic Q vector centred about {10,20,30,40,50} which is presumably just Q=const.+X for X a random vector with specified covariance matrix. Use Cholesky to generate X and add to the constant. I have re-published my original answer which expands a little. Hopefully with a bit of back and forth we might get to the required answer of the problem! $\endgroup$ – Attack68 Sep 18 '17 at 6:28
2
$\begingroup$

For a small vector, you could compute all the permutations of the elements and calculate their correlation with the original vector. You could then pick those permutations that lead to correlations within your desired range.

In R, for instance:

library("e1071")
P <- seq(10, 50, by = 10)
perm <- permutations(length(P))
rho <- apply(perm, 1, function(r) cor(P, P[r], method = "spearman"))

The vector rho gives the rank correlation for every row in the matrix perm.

head(data.frame(perm, rho))

##   X1 X2 X3 X4 X5 rho
## 1  1  2  3  4  5 1.0
## 2  2  1  3  4  5 0.9
## 3  2  3  1  4  5 0.7
## 4  1  3  2  4  5 0.9
## 5  3  1  2  4  5 0.7
## 6  3  2  1  4  5 0.6

For larger vectors and if sampling with replacement is allowed, I would probably go for some variant of the inversion method. In R, an implementation is in function resampleC in the NMOF package.

$\endgroup$
1
$\begingroup$

Instead of five elements lets reduce to two for simplicity, and call prices, $P$ and quantities, $Q$.

Suggest $P_1$ and $P_2$ have covariance matrix $\Sigma$. You might say $Q_1 = P_1 + X_1$ and $Q_2 = P_2 + X_2$, where $X_1$ and $X_2$ are your stochastic elements for quantities, and we let them be independent with non-identical variances. (note: if $\mathbf{P}=[10, 20]$ and $\mathbf{X}=[0, 0]$ then you return your simple scenario $\mathbf{Q}=[10, 20]$).

Now we have four random quantities to sample, $P_1, P_2, Q_1, Q_2$.

Written in matrix vector notation (with $\mathbf{Y,Z}$ added in for shorthand):

$$(\mathbf{Y}=)\begin{bmatrix}\mathbf{P} \\ \mathbf{Q}\end{bmatrix} = \begin{bmatrix}1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \end{bmatrix} \begin{bmatrix}\mathbf{P} \\ \mathbf{X}\end{bmatrix} (=\mathbf{AZ})$$

Then $$Cov(\mathbf{Y,Y}) = \mathbf{A} Cov(\mathbf{Z,Z}) \mathbf{A^T}$$

where, $$Cov(\mathbf{Z,Z})=\begin{bmatrix} \Sigma_{1,1} &\Sigma_{1,2} & 0 & 0 \\ \Sigma_{1,2} & \Sigma_{2,2} & 0 & 0 \\ 0 & 0 & \sigma_{X_1}^2 & 0 \\ 0 & 0 & 0 & \sigma_{X_2}^2 \end{bmatrix}$$ You can now reduce the covariance of $\mathbf{Y}$ to lower triangular by Cholesky decomposition and sample in the usual way. If you want to define the Q's differently say letting $Q_2=(P_2-P_1)+conts.$ then you just need to rework the equations, similarly if you want the X's to be correlated with each other.

This doesn't address the issue of ordering, but one could choose after the process to sort the P's and their corresponding Q's to give an ordered structure. One might also choose to define P as a constant vector plus random disturbance for which the equations could then be slightly re-worked.

$\endgroup$
  • $\begingroup$ thanks sir, I'll try this out this week and let you know how it goes.Thanks! $\endgroup$ – Chet Sep 18 '17 at 16:26
  • $\begingroup$ @Chet did you ask the original question? If so, please merge your accounts. $\endgroup$ – Bob Jansen Sep 18 '17 at 18:15
  • $\begingroup$ Thank you both - I still have not been able to try this out...but intend to soon. I don't know if there's a way to upload a spreadsheet or google doc on this site....would make things a lot easier. $\endgroup$ – Chet Sep 20 '17 at 22:37
  • $\begingroup$ @Attack68 I don't think that we need to treat the P's as a set of commodities for 5 different series. The P is just the Y axis on any demand curve, and is static.(:ingrimayne.com/econ/DemandSupply/Demand3.html); the first graph on this page for example. Q changes based on correl specified. So 1) I won't need P1 and P2, and 2) I'll need Q1 and Q2, such that Correl(P,Q1) = 90% (example) and Correl(P,Q2) = 60%. The original correl(P,Q) = 100%.(as shown in the link). I'll still try your method though. I'll make a link on google docs later today if that might help. $\endgroup$ – Chet Sep 22 '17 at 18:06
  • $\begingroup$ @Attack68: I made one error above; it's a supply curve, not demand curve (hence the positive correlation). Here's a link to the google sheet link. Notes1 - 9 show what I'm trying to do here....and I don't think it's possible. Please let me know if you guys are able to access the google sheet. Thanks!! $\endgroup$ – Chet Sep 23 '17 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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