Error check on "pspd" function from SPD package
Once again, it's just a matter of reading the documentation. 1. rugarch "prefers" xts 2. spd "requires" numeric:
From the documentation of pspd:
########################### x,q [pspd,dspd] - a numeric vector of quantiles. ########################### So I don't see any problem as the following works just fine: library(rugarch) library(spd) library(xts) data(sp500ret) # in the "rugarch" package sp = xts(sp500ret[,1], as.Date(rownames(sp500ret))) # standard GARCH model: spec = ugarchspec(mean.model=list(armaOrder=c(0,0)),distribution.model="std") tempgarch = ugarchfit(spec=spec,data=sp,solver="hybrid") # fitting the SPD: std.resid.sp = as.numeric(residuals(tempgarch,standardize=T)) fit.sp = spdfit(std.resid.sp, upper=0.9, lower=0.1, tailfit="GPD", type="mle", kernelfit="information="observed") sp.unif.variates = pspd(std.resid.sp, fit.sp, linear=T) -A
On 14/10/2015 02:20, Gareth McEwan wrote:
Hi all
I used the "pspd" function from the SPD package last year and I'm running
the code again, but it seems to throw an error now.
I checked with data from the "rugarch" package and the error is still
thrown.
data(sp500ret) # in the "rugarch" package
sp = sp500ret
class(sp) # is a "data.frame" class
sp=as.ts(sp) # I tried with and without this step
# standard GARCH model:
spec = ugarchspec(variance.model=list(model="sGARCH",garchOrder=c(1,1),
submodel=NULL,external.regressors=NULL,variance.targeting=F),
mean.model=list(armaOrder=c(0,0),include.mean=T,external.regressors=NULL),
distribution.model="std")
tempgarch = ugarchfit(spec=spec,data=sp,solver="hybrid")
# fitting the SPD:
(1)
std.resid.sp = residuals(tempgarch,standardize=T)
class(std.resid.sp) # "xts" "zoo"
(2)
stdResid.sp = as.ts(std.resid.sp) # NOTE: I tried (1) with and (2)
without this step
class(stdResid.sp) # "ts"
# the problem:
(1)
fit.sp = spdfit(std.resid.sp, upper=0.9, lower=0.1, tailfit="GPD",
type="mle", kernelfit="normal",
information="observed", title=NULL, description=NULL)
sp.unif.variates = pspd(std.resid.sp, fit.sp, linear=T)
Error in UseMethod("pspd") :
no applicable method for 'pspd' applied to an object of class "c('xts',
'zoo')"
(2)
fit.sp = spdfit(stdResid.sp, upper=0.9, lower=0.1, tailfit="GPD",
type="mle", kernelfit="normal",
information="observed", title=NULL, description=NULL)
sp.unif.variates = pspd(stdResid.sp, fit.sp, linear=T)
Error in UseMethod("pspd") :
no applicable method for 'pspd' applied to an object of class "ts"
From sessionInfo(), I have SPD package version as: spd_2.0-1 (i.e., it
seems to be up to date).
I don't think Can anyone help out with a solution?
Many thanks
Gareth
Additional:
packageDescription("spd")
Package: spd
Type: Package
Title: Semi Parametric Distribution
Version: 2.0-1
Date: 2015-07-02
...
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.