[R-SIG-Finance] financial series: waveslim, brainwaver, wavetresh and fractal

stvienna wiener stvienna at gmail.com
Wed Jul 15 18:24:10 CEST 2009


Hi,


thank you again. It seems I got another function in "waveslim" working
to find change points.
The function is called "testing.hov". The problem was there is not
example provided.
I think my code works now.

So very happy at the moment!

Regards,
Steve


P.S.: In case someone is interested in the code or sees any errors:

 ## Finding Change-Points

  # ! ZERO GUARANTEE that this is useful or correct !

  # For more info look at the book in chaper 7.3 / page 247:
  # Gencay, Selcuk, Whitcher (2001) An Introduction to Wavelets
  #  and Other Filtering Methods in Finance and Economics

  # load lib
  library(waveslim)
  # if not installed, run:   install.packages("waveslim")

  # ibm stock data, calculate returns (used in finance)
  data(ibm)
  ibm.returns <- diff(log(ibm))

  # pad series with zeros to get length 512 (for wavelet-transformation)
  lenibm <- length(ibm.returns)
  ibmnew <- 1:512
  ibmnew[1:512] <- 0
  ibmnew[1:lenibm] <- ibm.returns[1:lenibm]


  J <- 4 # wavelet decomposition up to scale 4

  # not sure if this is a good choice:
  wf <- "la8" # Daubechies orthonormal Wavelet of length 8


  # Locate Changepoint in ibm series
  # find significant changpoints considering the wavelet-variance of the series

  # (calculated at different scales, at scale number one there are 2
changepoints,
  # higher scales have no significant changepoints)

  changepoints <- testing.hov(ibmnew, wf, J=4, debug=TRUE)

  # plot series
  ts.plot(ibmnew)

  # draw lines at change points
  changepoint1 <- changepoints[1,4]
  changepoint2 <- changepoints[2,4]
  abline(v=c(changepoint1),lty=3, col="red")
  abline(v=c(changepoint2),lty=3, col="red")

  # you should see now a time series with two
  # red lines approx. at time 243 and 378



2009/7/15 spencerg <spencer.graves at prodsyse.com>:
> Hello, Steve:
>
>     I see two options:
>
>          1.  Send an email to the package authors / mainteners to ask about
> the status.  I found an email address using "RSiteSearch('WaveCGH')".  If
> that email fails, you could try to find them via Google.
>
>          2.  You cited a web page that stated that, "Package ‘WaveCGH’ was
> removed from the CRAN repository."  That web page also says, "Formerly
> available versions can be obtained from the archive." If you click on the
> word "archive", it should take you to a web page from which you can download
> "WaveCGH_2.01.tar.gz".  This is a source file for the package.  With this,
> you can try "R CMD INSTALL WaveCGH_2.01.tar.gz" at a commands prompt.  This
> will work under Windows IF you have Rtools installed, and I believe it will
> work under Linux.  From within R, I believe
> "install.packages('WaveCGH_2.01.tar.gz')" may also work.  If that fails, you
> could try another post to this list.
>
>     Hope this helps.     Spencer Graves
>
>
> stvienna wiener wrote:
>>
>> Hello Spencer,
>>
>>
>> thank you for your reply.
>>
>> I tried to install the package "WaveCGH" today, however I got an error.
>>
>>
>>>
>>> install.packages("WaveCGH")
>>>
>>
>> In getDependencies(pkgs, dependencies, available, lib) :
>>  package ‘WaveCGH’ is not available
>>
>>
>> Its somehow strange, because on the R-Website:
>> http://cran.r-project.org/web/packages/WaveCGH/
>>
>> It is written:
>> "Package ‘WaveCGH’ was removed from the CRAN repository."
>>
>> So I think the possibilities are:
>> a) the package was remove from CRAN
>> b) there are some dependencies. But I installed the newest R version!
>> c) I spelled the package wrong (e.g. small/capital letters )
>>
>>
>> Do you have maybe an idea?
>>
>>
>> Currently I am planning to use the following packages:
>>  library(R.utils)
>>
>>  library(tseries)
>>  library(wmtsa)        #Wavelets
>>  library(waveslim)     #Wavelet Correlation
>>  library(brainwaver)   #Wavelet Correlation
>>
>>  library(QRMlib)       # time series plotting
>>
>>   library(wavethresh)  # wavelet thresholding
>>   library(CVThresh)    # wavelet thresholding
>>
>>
>> Any suggestions welcome ;-)
>>
>> Regards,
>> Steve
>>
>>
>>
>> 2009/7/12 spencerg <spencer.graves at prodsyse.com>:
>>
>>>
>>> I can't help you directly, but have you tried "RSiteSearch.function" in
>>> the
>>> "RSiteSearch" package?  Consider the following:
>>>
>>> library(RSiteSearch)
>>>
>>> fcp <- RSiteSearch.function('fractal changepoint')
>>> fcps <- RSiteSearch.function('fractal changepoints')
>>>
>>> wcp <- RSiteSearch.function('wavelet changepoint')
>>> wcps <- RSiteSearch.function('wavelet changepoints')
>>> HTML(wcp)
>>>
>>>
>>>    This sequence returned 1 match for the third query, and HTML(wcp)
>>> displayed that match in a web browser with a link to, in this case, the
>>> index page for the "WaveCGH" package.
>>>
>>>    Hope this helps.     Spencer Graves
>>> stvienna wiener wrote:
>>>
>>>>
>>>> Greetings to all!
>>>>
>>>>
>>>> # Short-Version
>>>> I am looking for advanced R packages similar to "waveslim",
>>>> "brainwaver", "wavethresh", "fractal", etc.
>>>> in order to analyze financial times series (e.g. stock prices).
>>>>
>>>>
>>>> Currently I am writing code to show/demonstrate the use of wavelets
>>>> and fractal dimension
>>>> to analyze financial time series (its a school project for my master
>>>> degree in CS).
>>>>
>>>> The purpose is, for example, to find a correlation between IBM stock
>>>> prices and the dow jones index. Or to find a changepoint in
>>>> stock prices, correlating to unusual events e.g Yahoo stock prices in
>>>> 2008
>>>> while
>>>> there was an acquisition attempt.
>>>>
>>>> I have been using the "brainwaver" package to calculate correlations
>>>> of us stock prices to the dow jones.
>>>> It seems to work, but I am not 100% sure. (could provide so code but
>>>> its just fragments at the moment)
>>>>
>>>> So my questions at the moment would be:
>>>> 1)  Is there a specific R package that would be interesting and
>>>> helpful that I missed?
>>>> 2)  Is there a package to find "changepoints" in time series with
>>>> wavelets or fractal-approach?
>>>> I know there is a function in "waveslim" to find a changepoint in the
>>>> wavelet-variance,
>>>> but I could not yet get it working.
>>>> If not is there a way by other methods e.g. bayesian interference?
>>>>
>>>>
>>>> As references I was looking at the task views of finance, econometrics
>>>> and time series.
>>>>
>>>> As well as the following to very helpful books (aside of the standard
>>>> wavelet literature):
>>>>
>>>> (2001) An Introduction to Wavelets and Other Filtering Methods in
>>>> Finance and Economics.
>>>> Wavelet Methods in Statistics with R [ would be looking for a newer
>>>> reference ... .. ]
>>>> (2008) Wavelet Methods in Statistics with R
>>>>
>>>>
>>>> THANK you very much for any help or pointers!!
>>>>
>>>>
>>>> With the best regards to all,
>>>> Steve
>>>>
>>>> _______________________________________________
>>>> R-SIG-Finance at stat.math.ethz.ch mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>>> -- Subscriber-posting only.
>>>> -- If you want to post, subscribe first.
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



More information about the R-SIG-Finance mailing list