I have a time series of returns like this:
ret <- rnorm(50, -0.8 , 0.8)
I fit a GARCH model with rugarch
package:
library(rugarch)
comtspec <- ugarchspec(mean.model=list(
armaOrder=c(1,0)), distribution="std",
variance.model=list(model="eGARCH"))
fit <- ugarchfit(spec=comtspec, ret)
hisPDF <- ugarchdistribution(fit, n.sim = 200, n.start = 1, m.sim = 20,
recursive = TRUE, recursive.length = 6000,
recursive.window = 1000,
solver = "solnp")
And I plot the section number 1 output (Parameter Density Plots) from the results:
plot(hisPDF)
This gives me a graph like this:
I want to use the density function in the plot (The red circle for example) as a function to integrate and find the moments etc. but I don't know how. Can anyone help me with this>
All the coefficients from the simulation are stored in:
coefs <- hisPDF@dist[[1]]$simcoef
The autoregressive coefficient(ar) is the 2nd column:
ar <- coefs[,2]
Now if you want to create the density plot as the package do, you need:
d <- density(ar1)
plot(d)
However, if you want the summary statistics from the distribution, you do not need to integrate the density, you just need to
summary(ar1)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.17477 -0.13441 -0.08838 -0.07304 -0.03163 0.05786
Note that the values will be different because you are using a random generator for simulation without specifying a random.seed.