Learn R Programming

pvar (version 1.0.6)

pvar-package: p-variation calculation and it's application

Description

This is a package about the p-variation.

Arguments

Details

ll{ Package: pvar Type: Package Version: 1.0.6 Stage: development Date: 2012-09-28 License: GPL-2 } This package is about p-variation. It deals only of p-variation of a finite sample data values. To make it clear lets star with the definitions. Originally p-variation is defined for a functions. For a function $f:[0,1] \rightarrow R$ and $0 < p < \infty$ p-variation is defined as $$v_p(f) = \sup \left{ \sum_{i=1}^m |f(t_i) - f(t_{i-1})|^p : 0=t_0pvar and PvarBreakTest. The main function in this package is pvar. It calculates the p-variation and the partition. And the function PvarBreakTest is one of the examples of p-variation applications. It performs structural break test of vector x that exams whether there are multiple shifts in mean inside vector x. The test statistics distribution if drown from Monte-Carlo simulations of 140 millions iterations. Therefore test's critical value and p-value are not exact, but onyly approximate . All other functions are loaded only for supporting and illustrating purposes.

References

~~ Literature or other references for background information ~~

See Also

The main function is pvar - it finds p-variation and the partition that maximises Sum_p function. Other important functions is PvarBreakTest it performs structural break test of vector x by calculating p-variations of BBT(x) (see BBT). The critical value and the approximate p-value of the test might by found by functions PvarQuantile and PvarPvalue.

Examples

Run this code
set.seed(1)

######### pvar ########
x = rbridge(1, 1000)

### simple run:
pv = pvar(x, 2)
print(pv)
summary(pv)
plot(pv)

### partition points are those that maximises Sum_p function
Sum_p(x[pv$Partition], 2)

### lets take only the partition points:
pv2 = pvar(x[pv$Partition], TimeLabel=pv$TimeLabel[pv$Partition], 2)

op <- par(mfrow = c(2, 1))
	plot(pv, main="pvar with original data")
	plot(pv2, main="the same pvar without meaningless points")
par(op)

######### PvarBreakTest ########
x = c(rnorm(250,0),rnorm(250,0.3), rnorm(250,0), rnorm(250,0.3))

# Run test
PVBT = PvarBreakTest(x); PVBT
PVBTSummary = summary(PVBT); PVBTSummary

# the plot of the test
plot(PVBT)

# the suggestion of break points. True points are 250, 500 and 750
BreakPoints(PVBT)


##################################
# the statistic maigth by find with pvar
Y = BBT(x)
pv = pvar(Y, p = 4)
pv

# critical value
PvarQuantile(n=length(x), prob = c(0.95))
# apricimal p-value
PvarPvalue(n=length(x), stat=pv$value)

PVBT

Run the code above in your browser using DataLab