Closed gcoder1990 closed 2 years ago
You can obtain the distribution's parameters using the parameters()
function. More details can be found in the distributional package documentation (https://github.com/mitchelloharawild/distributional/)
You can obtain the distribution's parameters using the
parameters()
function. More details can be found in the distributional package documentation (https://github.com/mitchelloharawild/distributional/)
Thanks you for your answer Mitchell.
However, do you have any idea as to why x[[1]]$mu
might be returning NULL
for me? Shouldn't it be returning the mean?
Thank you and sorry, this issue seems so simple yet I cannot get it to appropriately run as expected.
I came across the answer: loading the fpp3
package loads tidyverse
along with other libraries that override the manner in which the operators $
and [[
operate.
I restarted R and ran the following code and was able to access the elements mu
and sigma
x <- structure(list(structure(list(mu = 758.880005, sigma = 11.1895832820955), class = c("dist_normal", "dist_default"))), vars = "Close", class = c("distribution", "vctrs_vctr", "list"))
x[[1]]$mu
#> [1] 758.88
The distributional package provides a [[.distribution
method which doesn't drop the distribution class.
If you'd like to peek into the object, you should use vctrs::vec_data()
.
Reading the documentation, it is not clear to me how to handle objects.
When producing forecasts, the forecast distribution is stored as an object in the resulting fable. These objects seemed to be handled by the package
distributional
, but their structure still elludes me.To be more specific, if x is the first element of the column distribution, when I apply str(x) I get the following output:
str(x)
It is apparently a list, but I am failing miserably at extracting its components. I have tried multiple things, but only
unlist
has worked for me:Please what would be the right way to do this without having to use unlist?
The output of
dput(x)
is:With this you should be able to reproduce the object as follows: