Last data update: 2014.03.03

R: Standard utility to perform nonlinear PSD fit
standardfitR Documentation

Standard utility to perform nonlinear PSD fit

Description

Standard utility to perform nonlinear PSD fit

Usage

standardfit(d, r, hist, trace, iter, plotqq, weights, merge_tails)

Arguments

d

A PSD S3 object representing initial guess of the PSD parameters

r

Input log-return series

hist

Input histogram

trace

TRUE/FALSE: turn trace on/off

iter

Maximum number of iterations

plotqq

TRUE/FALSE: Plot intermediate charts oor not

weights

Specify the weights of each component in the nonlinear fit, defaults are 1.

merge_tails

Specify the numbers of data points to merge in both tails when processing histogram

Value

dist

A PSD S3 object representing best nonlinear fit

psdout

The output of optmix/psg function. This is for debugging purpose only.

See Also

LIHNPSD_standardfit_fn

Examples

  # Load the daily log-return data of DJIA 
  data(szd_logr)

  # Prepare the input data set
  merge_tails <- c(1,3)
  dt <- LIHNPSD_prepare_data(szd_logr, breaks=68, merge_tails=merge_tails)

  # Prepare the input PSD 
  dist <- list( sigma= 0.0036, alpha= 0.9, gamma= 0.0, beta= -0.014 )
  class(dist) <- "LIHNPSD"
  dist <- rawmean(dist)
  dist$location <- 0.00014

  # Invoke the nonlinear fit (This will take some time!)
  #fit <- standardfit(dist, dt$logr, dt$h, trace=1, iter=10,
  #       plotqq=1, weights=list(m3=5,m4=1,qq_df=4), merge_tails=merge_tails )
  
  # The final PSD
  #dist <- fit$dist

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LIHNPSD)
Loading required package: sn
Loading required package: stats4

Attaching package: 'sn'

The following object is masked from 'package:stats':

    sd

Loading required package: moments
Loading required package: BB
Loading required package: Bolstad2
Loading required package: optimx
Loading required package: Rmpfr
Loading required package: gmp

Attaching package: 'gmp'

The following objects are masked from 'package:base':

    %*%, apply, crossprod, matrix, tcrossprod

C code of R package 'Rmpfr': GMP using 64 bits per limb


Attaching package: 'Rmpfr'

The following object is masked from 'package:sn':

    zeta

The following objects are masked from 'package:stats':

    dbinom, dnorm, dpois, pnorm

The following objects are masked from 'package:base':

    cbind, pmax, pmin, rbind


Attaching package: 'LIHNPSD'

The following object is masked from 'package:stats':

    density

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LIHNPSD/standardfit.Rd_%03d_medium.png", width=480, height=480)
> ### Name: standardfit
> ### Title: Standard utility to perform nonlinear PSD fit
> ### Aliases: standardfit
> 
> ### ** Examples
> 
>   # Load the daily log-return data of DJIA 
>   data(szd_logr)
> 
>   # Prepare the input data set
>   merge_tails <- c(1,3)
>   dt <- LIHNPSD_prepare_data(szd_logr, breaks=68, merge_tails=merge_tails)
> 
>   # Prepare the input PSD 
>   dist <- list( sigma= 0.0036, alpha= 0.9, gamma= 0.0, beta= -0.014 )
>   class(dist) <- "LIHNPSD"
>   dist <- rawmean(dist)
>   dist$location <- 0.00014
> 
>   # Invoke the nonlinear fit (This will take some time!)
>   #fit <- standardfit(dist, dt$logr, dt$h, trace=1, iter=10,
>   #       plotqq=1, weights=list(m3=5,m4=1,qq_df=4), merge_tails=merge_tails )
>   
>   # The final PSD
>   #dist <- fit$dist
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>