Learn R Programming

pvar (version 1.0.6)

PvarExtraFun_dev: Extra functions for p-variation that are under development.

Description

Some useful functions for objects of class pvar. Those functions now under development. It is known that those functions not correct therefor it should not be used by users (at least up until now).

Usage

Add2Pvar(pv1, pv2, JoinIfPossible = TRUE, dname = NULL)

AddPvar(..., JoinIfPossible = TRUE, dname = "data")

Arguments

...
pvar objects that should be added.
JoinIfPossible
logical. If TRUE (the default) the ending points of diferent vectors pvar$x will be treated as one point in result vector. Points will be joint only if they has the same value.
dname
The name of data vector of new pvar object.
pv1, pv2
a object of pvar.

Value

  • a object of the class pvar.

Details

The initial idea was to write the function that adds pvar object (with recalculations). The purpose is to avoid complete recalculation. It is meant to use the information already available. Unfortunately, the way functions was tritten is no correct, no optimal. It should be reconsider.

See Also

pvar, MergePvar.

Examples

Run this code
#### in this case it is OK:
	set.seed(20)
	XX = BBT(rnorm(1000))
	pv = pvar(XX, p = 2)
	pv1 = pvar(XX[1:round(length(XX)/2)], p = 2)
	pv2 = pvar(XX[round(length(XX)/2):length(XX)], p = 2)
	
	pvJ = AddPvar(pv1, pv2);pvJ
	Sum_p(pvJ$x[pvJ$Partition],pvJ$p)
	pv
	pvJ == pv	

	
	op = par(mfrow = c(2, 1))
		plot(pv)
		plot(pvJ, xlim=range(pv$TimeLabel), ylim=range(pv$x))
	par(op)
	
#### in this case it is NOT OK:
	set.seed(30)
	XX = BBT(rnorm(1000))
	pv = pvar(XX, p = 2)
	pv1 = pvar(XX[1:round(length(XX)/2)], p = 2)
	pv2 = pvar(XX[round(length(XX)/2):length(XX)], p = 2)
	
	pvJ = AddPvar(pv1, pv2);pvJ
	Sum_p(pvJ$x[pvJ$Partition],pvJ$p)
	pv
	pvJ == pv	
	
	op = par(mfrow = c(2, 1))
		plot(pv)
		plot(pvJ, xlim=range(pv$TimeLabel), ylim=range(pv$x))
	par(op)

Run the code above in your browser using DataLab