[R-SIG-Finance] error in plot() with fGarch object from saved .RData file

Brian G. Peterson brian at braverock.com
Tue Jul 28 22:06:16 CEST 2009


Yohan Chalabi wrote:
>>>>> "BGP" == "Brian G. Peterson" <brian at braverock.com>
>>>>> on Tue, 28 Jul 2009 14:08:41 -0500
>>>>>           
>
>    BGP> On Windows, R saves your workspace automagically on quitting
>    BGP> in a file
>    BGP> in the working directory called .RData
>    BGP>
>    BGP> if I have a garchFit object 'gf' it will plot correctly
>    BGP> immediately
>    BGP> after fitting.
>    BGP>
>    BGP> However, it will fail after reloading:
>    BGP>
>    BGP> > plot(gf)
>    BGP> Error in as.double(y) :
>    BGP> cannot coerce type 'S4' to vector of type 'double'
>
> Hi Brian,
>
> I suspect that you did not load 'fGarch' before trying to plot your
> saved object 'gf'. You are thus missing plot,fGARCH-method and related
> functions.
>
> If you do not want your coworker to load the whole package, you could
> include the missing method and functions in the saved workspace.
>   
Yohan,

Thanks.  I also suspected this, and made sure that

require(fGarch')

was called before I tried to plot.  Also, as I said, I can call the 
private .plot.garch.#() functions directly.

 > class(gf)
[1] "fGARCH"
attr(,"package")
[1] "fGarch"

looks OK

Does anybody know how to debug S4 method dispatch (sorry this is not 
strictly finance, but fGarch clearly is)?

  - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list