# creating a time series
trunc = 50000
cks <- arfima.coefs(d = 0.25, trunc = trunc)
eps <- rnorm(trunc+1000)
x <- sapply(1:1000, function(t) sum(cks*rev(eps[t:(t+trunc)])))
# kernel density function
dfun <- kdens(x)
# plot
curve(dfun, from = min(x), to = max(x))
Run the code above in your browser using DataLab