Page 1 of 1

Correlation between random parameters

Posted: 21 Oct 2020, 16:50
by Andy
Dear Stephane Hess,

In the manual, it is stated that the correlation of random parameters can be calculated using apollo_unconditionals. I wonder if there is an example that shows the code for calculating the correlations.

Kind regards
Andy

Re: Correlation between random parameters

Posted: 21 Oct 2020, 18:37
by stephanehess
Hi

yes, this is easy. Using example 15, you could do:

Code: Select all

> unconditionals=apollo_unconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed

> draws=do.call(cbind,lapply(unconditionals,as.vector))
> cor(draws)
          b_tt      b_tc      b_hw      b_ch
b_tt 1.0000000 0.6140231 0.4796923 0.5666015
b_tc 0.6140231 1.0000000 0.3210298 0.3833275
b_hw 0.4796923 0.3210298 1.0000000 0.6651674
b_ch 0.5666015 0.3833275 0.6651674 1.0000000
Hope this helps

Stephane

Re: Correlation between random parameters

Posted: 22 Oct 2020, 11:48
by Andy
Dear Stephane,

Thank you very much. This is an elegant solution and helps a lot.

Best regards
Andy