• Statistical modelling for nonstationary time series was developed in the 1990s
  • Extreme value theory or extreme value analysis (EVA) is a branch of statistics dealing with the extreme deviations from the median of probability distributions. It seeks to assess, from a given ordered sample of a given random variable, the probability of events that are more extreme than any previously observed. Extreme value analysis is widely used in many disciplines, such as structural engineering, finance, economics,
  • R packages related to univariate and multivariate extreme analysis which contains different estimators for the EVI, extreme quantile, models, and important plots.
  • Synonyms: mean/average/expectation/outcome
  • Fit a polynomial to a set of XY data. One way to do that is to highlight the XY data and insert a scatter graph then you can simply add a trendline select polynomial (fourth order). Problem with this is that these values aren't linked into the spreadsheet and can't be used for any further calculation so you have to do a copy and paste. If this XY data got updated then these values would change but the values in the spreadsheet wouldn't. Instead use a modified version of the LINEST function instead. Remember to raise the X data to a power of one two three and four because this is a fourth order polynomial. Use curly brackets for this (open curly brackets 1 comma 2 comma 3 comma 4 close the curly brackets) close the overall brackets. Because this is an array function highlight all the cells that the function is going to read its values out to (press f2 and then press control shift and enter). Fit a polynomial to data in Excel on YouTube
Most likely

  • Coming back from Mars. Billion people died. Ebola or car accident?
  • Person x died today. What is more likely, ebola or car accident?

Calculate log returns distribution

Confidence Interval for a Mean

See https://www.statisticshowto.com/how-to-do-a-t-test-in-excel/

To compute a confidence interval for a mean, we use the following formula: Confidence Interval = x+/-tn-1, 1-α/2*(s/√n) where:

  • x: sample mean
  • t: the t-critical value
  • s: sample standard deviation
  • n: sample size

Example

  • Sample size n = 30
  • Sample mean weight x = 200
  • Sample standard deviation s = 12

The code below demonstrates how to compute a 95% confidence interval for the true population mean weight of the above data. n <- 30 xbar <- 200 s <- 12

Let’s calculate the margin of error margin <- qt(0.975,df=n-1)*s/sqrt(n)

We can now determine the lower and upper confidence interval boundaries.

lowerinterval <- xbar – margin 195.5191
upperinterval <- xbar + margin 204.4809

The genuine population mean weight of data has a 95% confidence interval of [195.5191, 204.4809].

If Average of sample ~ Average of population then skewness is low
Geometric Average

The geometric average of the same numbers is quite different. This is how to figure geometric average with a finance calculator:

  1. First add 1 to each number in the sequence. This is to avoid problems with negative numbers.
  2. Multiple each number in the sequence.
  3. Raise the answer to the power of one divided by the count of the numbers in the sequence.
  4. Subtract one from the result.
Asset price simulation using fractals and other approaches.

FractalRock: Simulating stock market prices and returns can be accomplished using a number of techniques. Most commonly, geometric brownian motion (aka a random walk) is used to simulate stock prices. Using this technique results in a normal distribution of price returns. As an alternative technique, it is possible to generate price series using fractals. The advantage is that price returns tend to have volatility that clusters, similar to actual returns.

The basic principle driving fractal generation of time series is that data is generated iteratively based on increasing levels of resolution. The initial series is defined by a so-called initiator pattern and then generators are used to replace each segment of the initial pattern. Regular, repeatable patterns can be produced by using the same seed and generators. By using a set of generators, non-repeatable time series can be produced. This technique is the basis of the fractal time series process in this package.

Usage: As random generators, most of the functions in this package follow the R convention of using r as a prefix to denote a random number generator. The available generators include:

  • rprices
  • rintraday

Stochastic processes All price generators use a stochastic process to generate the sequence of random numbers.

Fractal time series Mandelbrot not only pioneered fractals but also used them to investigate volatility and risk in financial markets.

Geometric brownian motion, GBM is another name for a random walk. mygbm<-function(x) gbm(x, 40, .03/1440)

Ornstein-Uhlenbeck. An OU process is typically used to simulate interest rates.

Daily price simulation Any process can be used to generate prices. The rprices function attaches dates to the random sequence so it can be analyzed as an asset price series.

mygbm<-function(x) gbm(x, 40, .03/1440)
ps<-rprices(mygbm, obs=100)

Intraday price simulation. Generating intraday prices involves specifying a stochastic process along with some parameters indicating how many points to generating and how to map the points in the series to time. The trading_hours function knows about exchange holidays and trading hours to give a realistic price series.

th<-function(x) trading_hours(x,'cme')
seed<-rintraday(mygbm, 60, th)

head(seed)
              close2015-02-2340.000002015-02-2439.952022015-02-2540.033722015-02-2640.139782015-02-2740.174722015-03-0240.04889

An end date can be specified instead of the number of observations. These definitions are typed via lambda.r, so it's not necessary to name either of these parameters, although for clarity you may choose to do so.

seed<-rintraday(mygbm, as.Date('2015-03-05'), th)
range(index(seed))

[1] "2015-02-23""2015-03-05"

To specify an explicit date range, use this signature: seed<-rintraday(mygbm, start='2015-01-01', end='2015-03-01', th)
range(index(seed))

[1] "2015-01-01""2015-02-27"

Correlated random numbers FractalRock now supports generating correlated random numbers. This usage involves simulating a seed series and then generating a set of correlated series.

First we create the trading hours generator, followed by a call to rintraday to generate the seed series.

th<-function(x) trading_hours(x,'cme')
seed<-rintraday(mygbm, obs=60, th)

Now we specify the correlation matrix.

cmat<-matrix(c(1,0,0, .8,1,0, .6,.4,1), ncol=3)

cmat[,1] [,2] [,3]
[1,]    10.80.6[2,]    01.00.4[3,]    00.01.0

Finally, we generate the correlated price series.

z<-rintraday(seed, cmat)“

cor(z)
          [,1]      [,2]      [,3]
[1,] 1.00000000.81284550.6432900[2,] 0.81284551.00000000.3788305[3,] 0.64329000.37883051.0000000

Complete OHLC bars can be generated for correlated series as well. The OHLC option specifies the standard deviation for the HLC series. Instead of an xts object, a list of xts objects are returned, one for each time series.

th<-function(x) trading_hours(x,'cme')
seed<-rintraday(mygbm, obs=60, th)
cmat<-matrix(c(1,0,0, .8,1,0, .6,.4,1), ncol=3)
z<-rintraday(seed, cmat, ohlc=1, volume=100)

head(z2)
              closeopenlowhighvolume2015-02-2340.0391140.1896739.1164940.344371112015-02-2439.9456240.0391139.1868140.17525942015-02-2540.0500239.9456238.6171740.390371032015-02-2640.1092040.0500239.4167141.464931092015-02-2740.1932940.1092039.8351340.58183582015-03-0240.0490840.1932939.7288541.37340128

Iterative 

From <https://github.com/zatonovo/fractalrock>

Built with LogoFlowershow