Title: | An Adaptive Lifting Scheme Algorithm |
---|---|
Description: | Adaptive wavelet lifting transforms for signal denoising using optimal local neighbourhood regression, from Nunes et al. (2006) <doi:10.1007/s11222-006-6560-y>. |
Authors: | Matt Nunes [aut, cre], Marina Knight [aut], Guy Nason [ctb, ths] |
Maintainer: | Matt Nunes <[email protected]> |
License: | GPL |
Version: | 1.4-5 |
Built: | 2024-12-13 06:36:56 UTC |
Source: | CRAN |
This function performs the prediction lifting step over neighbourhoods and interpolation schemes.
AdaptNeigh(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
AdaptNeigh(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. Note that the value to this input is not important, since the procedure checks the neighbourhoods structure in the minimisation step anyway, but is for standardisation of arguments to the non-adaptive prediction schemes. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. (Note that this is actually a dummy argument, since it is not necessary for the computation of the detail coefficient in |
neighbours |
the number of neighbours to be considered in the computation of predicted values and detail coefficients. |
The procedure performs adaptive regression (through AdaptPred
) over the three types of regression and also over the 3*neighbours configurations of neighbours. The combination (type of regression, configuration of neighbours) is chosen which gives the smallest detail coefficient (in absolute value).
results. This is a ten item list giving the regression information chosen from the detail coefficient minimisation (i.e, the information supplied to AdaptNeigh
by AdaptPred
):
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of columns |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
int |
if TRUE, an intercept was used in the regression. |
scheme |
a character vector denoting the type of regression used in the prediction ("Linear", "Quad" or "Cubic"). |
details |
a vector of the detail coefficients from which |
minindex |
the index into details (results[[9]]) which produces the minimum value. |
newinfo. A six item list containing extra information to be used in the main transform procedure (fwtnp
) obtained from the minimisation in AdaptNeigh
:
clo |
boolean value telling the configuration of the neighbours which produce the overall minimum detail coefficient. |
totalminindex |
the index into mindetails (below) indicating the overall minimum detail coefficient produced by the procedure. |
nbrs |
the indices into X of the neighbours used in the best prediction scheme. |
index |
the indices into pointsin of the neighbours used in the best prediction. |
mindetails |
a vector of 3*neighbours entries giving the minimum details produced by each call of |
minindices |
vector of 3*neighbours entries giving the index (out of 6) of the schemes which produce the best predictions by each call of |
Matt Nunes ([email protected]), Marina Knight
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform the adaptive lifting step # an<-AdaptNeigh(order(tx),tx,ty,out$nbrs,173,FALSE,2) # an[[1]][[7]] an[[2]][[3]] #shows best prediction when removing point 173, with the neighbours used
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform the adaptive lifting step # an<-AdaptNeigh(order(tx),tx,ty,out$nbrs,173,FALSE,2) # an[[1]][[7]] an[[2]][[3]] #shows best prediction when removing point 173, with the neighbours used
This function performs the prediction lifting step over neighbourhoods and interpolation schemes, for multiple point data.
AdaptNeighmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
AdaptNeighmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
coefflist |
the list of detail and multiple scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. |
g |
the group structure of the multiple point data. |
The procedure performs adaptive regression (through AdaptPred
) over the three types of regression and also over the 3*neighbours configurations of neighbours. The combination (type of regression, configuration of neighbours) is chosen which gives the smallest detail coefficient (in absolute value).
results. This is a ten item list giving the regression information chosen from the detail coefficient minimisation (i.e, the information supplied to AdaptNeigh
by AdaptPred
):
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of columns |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
int |
if TRUE, an intercept was used in the regression. |
scheme |
a character vector denoting the type of regression used in the prediction ("Linear", "Quad" or "Cubic"). |
details |
a vector of the detail coefficients from which |
minindex |
the index into details (results[[9]]) which produces the minimum value. |
newinfo. A six item list containing extra information to be used in the main transform procedure (fwtnp
) obtained from the minimisation in AdaptNeigh
:
clo |
boolean value telling the configuration of the neighbours which produce the overall minimum detail coefficient. |
totalminindex |
the index into mindetails (below) indicating the overall minimum detail coefficient produced by the procedure. |
nbrs |
the indices into X of the neighbours used in the best prediction scheme. |
index |
the indices into pointsin of the neighbours used in the best prediction. |
mindetails |
a vector of 3*neighbours entries giving the minimum details produced by each call of |
minindices |
vector of 3*neighbours entries giving the index (out of 6) of the schemes which produce the best predictions by each call of |
Matt Nunes ([email protected]), Marina Knight
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs AdaptNeighmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs AdaptNeighmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
This function performs the prediction lifting step over intercept and regression order.
AdaptPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
AdaptPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. Note that the value to this input is not important, since the procedure checks the neighbourhoods structure in the minimisation step anyway, but is for standardisation of arguments to the non-adaptive prediction schemes. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. (Note that this is actually a dummy argument, since it is not necessary for the computation of the detail coefficient in |
neighbours |
the number of neighbours to be considered in the computation of predicted values and detail coefficients. |
The procedure performs adaptive regression (through AdaptPred) over the three types of regression and also over intercept. The combination (type of regression, intercept) is chosen which gives the smallest detail coefficient (in absolute value).
results. This is a ten item list giving the regression information chosen from the detail coefficient minimisation:
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of columns |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
int |
if TRUE, an intercept was used in the regression. |
scheme |
a character vector denoting the type of regression used in the prediction ("Linear", "Quad" or "Cubic"). |
details |
a vector of the detail coefficients from which |
minindex |
the index into details (results[[9]]) which produces the minimum value. |
Matt Nunes ([email protected]), Marina Knight
AdaptNeigh
, CubicPred
, fwtnp
, LinearPred
, QuadPred
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform the adaptive lifting step # ap<-AdaptPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # #the detail coefficient: ap[[3]] #and let's check the scheme used: ap[[4]] ap[[5]]
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform the adaptive lifting step # ap<-AdaptPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # #the detail coefficient: ap[[3]] #and let's check the scheme used: ap[[4]] ap[[5]]
This function performs the prediction lifting step over intercept and regression order, for multiple point data.
AdaptPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
AdaptPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
coefflist |
the list of detail and multiple scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. |
g |
the group structure of the multiple point data. |
The procedure performs adaptive regression (through AdaptPred) over the three types of regression and also over intercept. The combination (type of regression, intercept) is chosen which gives the smallest detail coefficient (in absolute value).
results.This is a ten item list giving the regression information chosen from the detail coefficient minimisation:
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of columns |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
int |
if TRUE, an intercept was used in the regression. |
scheme |
a character vector denoting the type of regression used in the prediction ("Linear", "Quad" or "Cubic"). |
details |
a vector of the detail coefficients from which |
minindex |
the index into details (results[[9]]) which produces the minimum value. |
Matt Nunes ([email protected]), Marina Knight
AdaptNeighmp
, CubicPredmp
, fwtnpmp
, LinearPredmp
, QuadPredmp
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs AdaptPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs AdaptPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
This function produces new grid values to cope with data with repeated grid values according to the method chosen to deal with it.
adjustx(x, f, type = "mean")
adjustx(x, f, type = "mean")
x |
a vector of the original (repeated) gridpoints. |
f |
the vector of function values associated to the grid vector X. |
type |
The method used to cope with the multiple points. "mean" averages all function values with the same grid value. The "jitter" option adds a small amount to all but one of each repeated grid value, and associates the function values to these new gridpoints. In this way, the each gridpoint value corresponds uniquely to the function values. |
The function compares x to unique(x)
to find the occurences of repeated grid values, and stores the information in groups. In the "jitter" case, this is then used to modify the original gridpoints by adding an epsilon to the repeated values. In the case of type="mean", the new gridpoints are, in fact unique(x)
, and the information is used to average the groups of original function values to construct sepf.
sepx |
the vector of new gridpoints. |
sepf |
the function values associated to sepx. |
groups |
a list of indices into x showing where the original repeated grid values occured. |
Matt Nunes ([email protected]), Marina Knight
#read in the motorcycle crash data # data(motorcycledata) # dim(motorcycledata) #check data. # times<-motorcycledata$time accel<-motorcycledata$accel a<-adjustx(times,accel,"mean") # #note the repeated values in the original grid data # #display new data vectors a$sepx # a$sepf # #and now the new adjusted data has length 94. #
#read in the motorcycle crash data # data(motorcycledata) # dim(motorcycledata) #check data. # times<-motorcycledata$time accel<-motorcycledata$accel a<-adjustx(times,accel,"mean") # #note the repeated values in the original grid data # #display new data vectors a$sepx # a$sepf # #and now the new adjusted data has length 94. #
Combines filter matrices to produce a refinement matrix A for a wavelet transform.
Amatdual(steps, pointsin, removelist, nbrs, weights, alpha)
Amatdual(steps, pointsin, removelist, nbrs, weights, alpha)
steps |
a value indicating which refinement matrix to construct. It refers to the number of points already removed during the transform. |
pointsin |
The indices of gridpoints still to be removed. |
removelist |
a vector of indices into envX of the lifted coefficients during the transform (in the order of removal). |
nbrs |
indices of the neighbours used in the last step of the decomposition. |
weights |
the prediction weights obtained from the regression in the prediction step of the transform. |
alpha |
the update weights used to update lengths and coeff. |
The function uses the prediction and update weights to construct the filter matrices Hdual and Gdual. Combining these two matrices results in the refinement matrix Adual.
Adual |
the refinement matrix for the particular step of the transform. |
Hdual |
the high-pass filter matrix for the current step of the transform. |
Gdual |
the low-pass filter matrix for the current step of the transform. |
o |
the indices of nbrs into the vector of pointsin and the steps removed points of the transform. |
alpha |
the update weights used to update lengths and coeff. |
weights |
the prediction weights obtained from the regression in the prediction step of the transform. |
This function has been left in the package for completeness. However, the transform matrix is (optionally) computed within the forward lifting
transform function fwtnp
.
Matt Nunes ([email protected]), Marina Knight
# x<-runif(256) y<-make.signal2("doppler",x=x) a<-fwtnp(x,y,LocalPred=AdaptNeigh,neighbours=2) # Adual<-Amatdual(90,a$pointsin,a$removelist,a$neighbrs[[90]], a$gamlist[[90]],a$alphalist[[90]]) # Adual # #the 90th refinement matrix for the transform above. #
# x<-runif(256) y<-make.signal2("doppler",x=x) a<-fwtnp(x,y,LocalPred=AdaptNeigh,neighbours=2) # Adual<-Amatdual(90,a$pointsin,a$removelist,a$neighbrs[[90]], a$gamlist[[90]],a$alphalist[[90]]) # Adual # #the 90th refinement matrix for the transform above. #
This function splits the coefficients into levels according to increasing quantiles of the removed interval lengths.
artlev(y, rem)
artlev(y, rem)
y |
a vector of the removed interval lengths (in the order of removelist). |
rem |
vector of indices of the removed points (from the output of the forward transform). |
The function finds the median of the removed interval lengths, and takes all pointsin indices with removed interval lengths at most this value as the first artificial level. These indices are now not considered in later groups. The cut-off value, q, is now increased to the 75th percentile, and the indices at most this value are grouped into the second level. The procedure is continued with successive percentiles (1+q)/2 until all indices are grouped. At each stage, the level size is checked to ensure it has at least 10 elements, and if not, the level is taken together with the next level (i.e. the present percentile is ignored, and increased to the q value).
p |
a list of the grouped indices of removelist (in decreasing group size) indicating thresholding groups. |
Matt Nunes ([email protected]), Marina Knight
#create test signal data # x<-runif(100) y<-make.signal2("blocks",x=x) # #perform forward transform... # out<-fwtnp(x,y,LocalPred=AdaptNeigh,neighbours=2) # al<-artlev(out$lengthsremove,out$removelist) # # # the indices of removelist split into levels: al #
#create test signal data # x<-runif(100) y<-make.signal2("blocks",x=x) # #perform forward transform... # out<-fwtnp(x,y,LocalPred=AdaptNeigh,neighbours=2) # al<-artlev(out$lengthsremove,out$removelist) # # # the indices of removelist split into levels: al #
This function returns a given vector as a column (with dimension).
as.column(x)
as.column(x)
x |
any vector or array. |
x can either be a vector with no dimension attributes (a list of values), a vector with dimensions, or a matrix/array. If x is a matrix/array, the function gives x if ncol(x)
is less than or equal to nrow(x)
, or its transpose if ncol(x)
is greater than or equal to nrow(x)
. For any input, the input is given non-null dimensions.
y |
a vector identical to x, but given as a column. |
Matt Nunes ([email protected]), Marina Knight
vector<-1:8 # vector # #...vector has no dimension attributes # as.column(vector) # #...gives output dimension of (8,1) # A<-matrix(c(6,2,2,10,6,17),3,2) # # as.column(A) # #the function has no effect on F # F<-t(A) F #now has dimension (2,3)... # as.column(A) # #the output is made to have more rows than columns
vector<-1:8 # vector # #...vector has no dimension attributes # as.column(vector) # #...gives output dimension of (8,1) # A<-matrix(c(6,2,2,10,6,17),3,2) # # as.column(A) # #the function has no effect on F # F<-t(A) F #now has dimension (2,3)... # as.column(A) # #the output is made to have more rows than columns
This function returns a given vector as a row (with dimension).
as.row(x)
as.row(x)
x |
any vector or array |
x can either be a vector with no dimension attributes (a list of values), a vector with dimensions, or a matrix/array. If x is a matrix/array, the function gives x if ncol(x)
is greater than or equal to nrow(x)
, or its transpose if ncol(x)
is less than or equal to nrow(x)
. For any input, the input is given non-null dimensions.
y |
a vector identical to x, but given as a row. |
Matt Nunes ([email protected]), Marina Knight
X<-0:5 # X # as.row(X) # #puts input into row (matrix) # Y<-matrix(0:5,6,1) # Y # as.row(Y) # #input forced into a row. #
X<-0:5 # X # as.row(X) # #puts input into row (matrix) # Y<-matrix(0:5,6,1) # Y # as.row(Y) # #input forced into a row. #
This function plots all mother and father wavelets associated with a given wavelet transform.
basisfns(x, f, pred, neigh, int, clo, keep, plot.f = FALSE, plot.bas = FALSE, separate = FALSE)
basisfns(x, f, pred, neigh, int, clo, keep, plot.f = FALSE, plot.bas = FALSE, separate = FALSE)
x |
a gridpoint vector. |
f |
the vector of associated function values. |
pred |
The type of regression to be performed. Possible options are LinearPred, QuadPred, CubicPred, AdaptPred and AdaptNeigh. |
neigh |
The number of neighbours over which the regression is performed at each step. If closest is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If closest is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
plot.f |
a boolean value indicating whether to plot the original function or not. If so, the signal is plotted with vertical coloured lines, showing which prediction method was used on the different parts of the signal. The plot also shows which gridpoints correspond to scaling functions. |
plot.bas |
subset of |
separate |
a boolean argument indicating if the basis functions should be plotted on a single graphsheet. |
The procedure constructs W, the matrix representation of the forward transform specified in the arguments to the function, and then uses the inverse matrix to calculate the vectors of basis function values: to work out the basis function values, one inverts the transform with a delta vector, with a one in the position corresponding to the basis function required. Since this is equivalent to pre-multiplying the delta vector by the matrix representation for the inverse transform , the basis function values are precisely the columns of
. The procedure then plots the basis functions (each on a separate graphsheet, if chosen), colour coded according to the prediction scheme used or whether it is a scaling function.
out |
the output from the forward transform which is specified in the arguments to this function |
$
pointsin |
the vector of indices of points still to be removed. |
schhist |
a character string vector of the prediction scheme used for the prediction of each gridpoint (in the order of x). |
inthist |
vector of boolean values indicating whether an intercept was used in the prediction steps during the transform (in the order of x). |
basmat |
a matrix of wavelet basis function values. The row i represents the function values corresponding to the grid for the basis function associated to the gridpoint |
If plot.bas=T, since the function produces one graph for each gridpoint, R or Splus is likely to exceed the total number of open devices for large datasets.
Matt Nunes ([email protected]), Marina Knight
#create test signal data # x<-runif(100) y<-make.signal2("blocks",x=x) # #perform procedure... # a<-basisfns(x,y,AdaptNeigh,2,TRUE,TRUE,2,FALSE,c(1,14,15),FALSE) # #this produces plots of three basis functions all on one graph.
#create test signal data # x<-runif(100) y<-make.signal2("blocks",x=x) # #perform procedure... # a<-basisfns(x,y,AdaptNeigh,2,TRUE,TRUE,2,FALSE,c(1,14,15),FALSE) # #this produces plots of three basis functions all on one graph.
This function uses a specified norm to compute the condition number of a matrix representation of a wavelet transform.
condno(W, type)
condno(W, type)
W |
a matrix which represents a wavelet transform. |
type |
a character string denoting which norm to use when computing the condition number. Possible values are "l1", or one of the standard norm types, "F" (Frobenius norm), "i" (infinity norm), "m" (max modulus of a matrix) or "1" (1-norm). |
The function computes the condition number as condno = .
condno |
the condition number of the matrix W. |
The matrix W must be invertible.
Matt Nunes ([email protected]), Marina Knight
#create test signal data # x<-runif(100) y<-make.signal2("blocks",x=x) # a<-fwtnp(x,y,LocalPred=AdaptNeigh,neigh=2,do.W=TRUE,varonly=FALSE) # #computes the transition matrix for the specified options # W<-a$W # condno(W,"F") # condno(W,"l1") # condno(W,"1") #
#create test signal data # x<-runif(100) y<-make.signal2("blocks",x=x) # a<-fwtnp(x,y,LocalPred=AdaptNeigh,neigh=2,do.W=TRUE,varonly=FALSE) # #computes the transition matrix for the specified options # W<-a$W # condno(W,"F") # condno(W,"l1") # condno(W,"1") #
This function performs the prediction lifting step using a cubic regression curve given a configuration of neighbours.
CubicPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
CubicPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
The procedure performs cubic regression using the given neighbours using an intercept if chosen. The regression coefficients (weights) are used to predict the new function value at the removed point. If there are not enough neighbours to generate a cubic regression curve, the order of prediction is decreased until it is possible (i.e. to QuadPred
, then LinearPred
).
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of columns |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
Matt Nunes ([email protected]), Marina Knight
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform cubic prediction based on the neighbours (without intercept) # cp<-CubicPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # cp$bhat # #the coefficients which define the cubic regression curve # cp$pred # #the predicted value from the regression curve #
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform cubic prediction based on the neighbours (without intercept) # cp<-CubicPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # cp$bhat # #the coefficients which define the cubic regression curve # cp$pred # #the predicted value from the regression curve #
This function performs the prediction lifting step using a cubic regression curve given a configuration of neighbours, for multiple point data.
CubicPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
CubicPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
coefflist |
the list of detail and multiple scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. Note that this is taken to standardise the input when LocalPredmp is called. |
g |
the group structure of the multiple point data. Note that this is taken to standardise the input when LocalPredmp is called. |
The procedure performs cubic regression using the given neighbours using an intercept if chosen. The regression coefficients (weights) are used to predict the new function value at the removed point.
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of the column X[newnbrs] augmented with a column of ones if an intercept is used. Refer to any reference on linear regression for more details. |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
Matt Nunes ([email protected]), Marina Knight
fwtnpmp
, LinearPredmp
, QuadPredmp
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs CubicPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs CubicPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
Denoises the inputted signal using artificial levels noise variance estimation and bayesian thresholding.
denoise(x, f, pred, neigh, int, clo, keep, rule = "median", returnall=FALSE)
denoise(x, f, pred, neigh, int, clo, keep, rule = "median", returnall=FALSE)
x |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to x. Must be of the same length as x. |
pred |
The type of regression to be performed. Possible options are |
neigh |
The number of neighbours over which the regression is performed at each step. If clo is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If clo is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
rule |
The type of bayesian thresholding used in the procedure. Possible values are "mean", "median" (posterior mean or median thresholding) or "hard |
returnall |
Indicates whether the function should return useful variables or just the denoised datapoints. |
The function uses the transform matrix to normalise the detail coefficients produced from the forward transform according to the correlation structure, so that they can be used in the bayesian thresholding procedure EbayesThresh. The coefficients are divided into artificial levels, and the first (largest)level is used to estimate the noise variance of the coefficients. EbayesThresh is then used to threshold the coefficients. The resulting new coefficients are then unnormalised and the transform inverted to obtain an estimate of the true (unnoisy) signal.
If returnall=FALSE, the estimate of the function after denoising. If returnall=TRUE, a list with components:
fhat |
the estimate of the function after denoising. |
w |
the matrix associated to the wavelet transform. |
indsd |
the individual coefficient variances introduced by the transform. |
al |
the artificial levels used to estimate the noise variance. |
sd |
the standard deviation of the noise. |
Matt Nunes ([email protected]), Marina Knight
x1<-runif(256) y1<-make.signal2("doppler",x=x1) n1<-rnorm(256,0,.1) z1<-y1+n1 # est1<-denoise(x1,z1,AdaptNeigh,1,TRUE,TRUE,2) sum(abs(y1-est1)) # #the error between the true signal and the denoised version.
x1<-runif(256) y1<-make.signal2("doppler",x=x1) n1<-rnorm(256,0,.1) z1<-y1+n1 # est1<-denoise(x1,z1,AdaptNeigh,1,TRUE,TRUE,2) sum(abs(y1-est1)) # #the error between the true signal and the denoised version.
Denoises the inputted signal using artificial levels noise variance estimation and bayesian thresholding, using heteroscedastic (estimated) noise variances.
denoisehetero(x, f, pred, neigh, int, clo, keep, rule = "median", returnall=FALSE)
denoisehetero(x, f, pred, neigh, int, clo, keep, rule = "median", returnall=FALSE)
x |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to x. Must be of the same length as x. |
pred |
The type of regression to be performed. Possible options are |
neigh |
The number of neighbours over which the regression is performed at each step. If clo is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If clo is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
rule |
The type of bayesian thresholding used in the procedure. Possible values are "mean", "median" (posterior mean or median thresholding) or "hard or |
returnall |
Indicates whether the function returns useful variables or just the denoised datapoints. |
The function uses the transform matrix to normalise the detail coefficients produced from the forward transform, so that they can be used in the bayesian thresholding procedure EbayesThresh. The coefficients are divided into artificial levels, and the first (largest)level is used to estimate the noise variances of the coefficients, based on the MAD of those coefficients falling in a sliding window around each gridpoint. EbayesThresh is then used to threshold the coefficients. The resulting new coefficients are then unnormalised and the transform inverted to obtain an estimate of the true (unnoisy) signal.
If returnall=FALSE, the estimate of the function after denoising. If returnall=TRUE, a list with components:
fhat |
the estimate of the function after denoising. |
fhat1 |
the estimate of the function after denoising, using the alternate variance estimate of MAD, centered at zero. |
fhat2 |
the estimate of the function after denoising, using the alternate variance estimate of the median of the absolute values of the detail coefficients. |
w |
the matrix associated to the wavelet transform. |
indsd |
the individual coefficient variances introduced by the transform. |
al |
the artificial levels used to estimate the noise variance. |
sd |
the standard deviation of the noise. |
Matt Nunes ([email protected]), Marina Knight
x1<-runif(256) y1<-make.signal2("doppler",x=x1) n1<-rnorm(256,0,.1) z1<-y1+n1 # est1<-denoisehetero(x1,z1,AdaptNeigh,1,TRUE,TRUE,2) traceback() sum(abs(y1-est1)) # #the error between the true signal and the denoised version.
x1<-runif(256) y1<-make.signal2("doppler",x=x1) n1<-rnorm(256,0,.1) z1<-y1+n1 # est1<-denoisehetero(x1,z1,AdaptNeigh,1,TRUE,TRUE,2) traceback() sum(abs(y1-est1)) # #the error between the true signal and the denoised version.
Denoises the multiple observation inputted signal using artificial levels noise variance estimation and bayesian thresholding, using heteroscedastic (estimated) noise variances.
denoiseheteromp(x, f, pred, neigh, int, clo, keep, rule = "median", mpdet="ave",returnall=FALSE)
denoiseheteromp(x, f, pred, neigh, int, clo, keep, rule = "median", mpdet="ave",returnall=FALSE)
x |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to x. Must be of the same length as x. |
pred |
The type of regression to be performed. Possible options are |
neigh |
The number of neighbours over which the regression is performed at each step. If clo is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If clo is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
rule |
The type of bayesian thresholding used in the procedure. Possible values are "mean", "median" (posterior mean or median thresholding) or "hard or |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. |
returnall |
Indicates whether the function returns useful variables or just the denoised datapoints. |
The function uses the transform matrix to normalise the detail coefficients produced from the forward transform, so that they can be used in the bayesian thresholding procedure EbayesThresh. The coefficients are divided into artificial levels, and the first (largest)level is used to estimate the noise variances of the coefficients, based on those coefficients falling in a sliding window around each gridpoint. EbayesThresh is then used to threshold the coefficients. The resulting new coefficients are then unnormalised and the transform inverted to obtain an estimate of the true (unnoisy) signal.
If returnall=FALSE, the estimate of the function after denoising. If returnall=TRUE, a list with components:
fhat |
the estimate of the function after denoising. |
fhat1 |
the estimate of the function after denoising, using the alternate variance estimate of MAD, centered at zero. |
fhat2 |
the estimate of the function after denoising, using the alternate variance estimate of the median of the absolute values of the detail coefficients. |
indsd |
the individual coefficient variances introduced by the transform. |
al |
the artificial levels used to estimate the noise variance. |
sd |
the standard deviation of the noise. |
Matt Nunes ([email protected]), Marina Knight
data(motorcycledata) # times<-motorcycledata$time accel<-motorcycledata$accel est1<-denoiseheteromp(times,accel,AdaptNeighmp,1,TRUE,TRUE,2, "median","ave") # #the estimate of the underlying curve.
data(motorcycledata) # times<-motorcycledata$time accel<-motorcycledata$accel est1<-denoiseheteromp(times,accel,AdaptNeighmp,1,TRUE,TRUE,2, "median","ave") # #the estimate of the underlying curve.
Denoises the inputted signal using artificial levels noise variance estimation and bayesian thresholding, assuming noise variances known up to proportionality constants.
denoiseheteroprop(x, f, pred, neigh, int, clo, keep, rule = "median",gamvec,returnall=FALSE)
denoiseheteroprop(x, f, pred, neigh, int, clo, keep, rule = "median",gamvec,returnall=FALSE)
x |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to x. Must be of the same length as x. |
pred |
The type of regression to be performed. Possible options are |
neigh |
The number of neighbours over which the regression is performed at each step. If clo is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If clo is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
rule |
The type of bayesian thresholding used in the procedure. Possible values are "mean", "median" (posterior mean or median thresholding) or "hard or |
gamvec |
A vector of proportions of the noise standard deviations (in the order of x). |
returnall |
Indicates whether the function returns useful variables or just the denoised datapoints. |
The function uses the transform matrix to normalise the detail coefficients produced from the forward transform, so that they can be used in the bayesian thresholding procedure EbayesThresh. The normalising factors are calculated assuming that the noise associated to the ith gridpoint is . The coefficients are divided into artificial levels, and the first (largest)level is used to estimate the noise variance of the coefficients. EbayesThresh is then used to threshold the coefficients. The resulting new coefficients are then unnormalised and the transform inverted to obtain an estimate of the true (unnoisy) signal.
If returnall=FALSE, the estimate of the function after denoising. If returnall=TRUE, a list with components:
fhat |
the estimate of the function after denoising. |
w |
the matrix associated to the wavelet transform. |
indsd |
the individual coefficient variances introduced by the transform. |
al |
the artificial levels used to estimate the noise variance. |
sd |
the standard deviation of the noise. |
Matt Nunes ([email protected]), Marina Knight
x1<-runif(256) y1<-make.signal2("doppler",x=x1) n1<-rnorm(256,0,.1) z1<-y1+n1 gvec<-c(rep(.4,times=100),rep(.7,times=100),rep(.3,times=56)) # est1<-denoiseheteroprop(x1,z1,AdaptNeigh,1,TRUE,TRUE,2,"median",gvec) sum(abs(y1-est1)) # #the error between the true signal and the denoised version.
x1<-runif(256) y1<-make.signal2("doppler",x=x1) n1<-rnorm(256,0,.1) z1<-y1+n1 gvec<-c(rep(.4,times=100),rep(.7,times=100),rep(.3,times=56)) # est1<-denoiseheteroprop(x1,z1,AdaptNeigh,1,TRUE,TRUE,2,"median",gvec) sum(abs(y1-est1)) # #the error between the true signal and the denoised version.
This function adds a random uniform vector of the same length as the input to modify the input.
dojitter(x, amount = 0)
dojitter(x, amount = 0)
x |
a vector to be jittered (e.g. a gridpoint vector). |
amount |
a value of how much to jitter the vector x. |
The function creates length(x)
samples from a uniform[-amount,amount], and adds these to the original vector x. If amount=0, the new vector jx is the same as the original vector.
jx |
the jittered version of x |
Matt Nunes ([email protected]), Marina Knight
#create grid vector # xgrid<-seq(0,1,length=51) # xgrid # #a regularly-spaced grid # dojitter(xgrid,.01) # #a jittered grid. #
#create grid vector # xgrid<-seq(0,1,length=51) # xgrid # #a regularly-spaced grid # dojitter(xgrid,.01) # #a jittered grid. #
This function finds the minimum inversion steps to perform to fully reconstruct (a subset of) data
findadds(rem, neighbrs, po, index = 1:(length(rem) + length(po)))
findadds(rem, neighbrs, po, index = 1:(length(rem) + length(po)))
rem |
the |
neighbrs |
A list of neighbour indices corresponding to lifting
steps in a decomposition. See |
po |
The |
index |
a vector of indices into the original data, indicating which points should be fully reconstructed during inversion. |
This function gives a computational shortcut to get datapoint
information in certain inversion cases. In some circumstances,when
inverting, you might only be interested in the inverted coefficients for
a subset of timepoints. In this case, it is not necessary to do a full
inversion to look at the desired coefficients; the function uses the
neighbourhood and removal order of the forward transform information and
notes: 1) when the desired points were lifted (if at all) and 2) when
the desired points were used as neighbours in prediction (if applicable).
The number of inversion steps needed for each index individually is then
taken as the maximum for these two conditions to be met. Inverting the
transform with this number will yield the correct inverted coefficient.
Note that to get the correct coefficients for all index
, the number of
inversion steps is max(adds)
.
adds
: a vector corresponding to index
, each element
of which is
the number of inversion steps needed for that datapoint to be fully
reconstructed.
Matt Nunes ([email protected])
#create data: x<-runif(256) f<-make.signal2("bumps",x=x) #do forward transform: fwd<-fwtnp(x,f) #I want to invert enough so that points 1:3 are reconstructed. adds<-findadds(fwd$removelist,fwd$neighbrs,fwd$pointsin,1:3) adds #now reconstruct... fhat<-invtnp(fwd,f,nadd=max(adds)) #...and check that the desired points are the same: f[1:3] fhat[1:3]
#create data: x<-runif(256) f<-make.signal2("bumps",x=x) #do forward transform: fwd<-fwtnp(x,f) #I want to invert enough so that points 1:3 are reconstructed. adds<-findadds(fwd$removelist,fwd$neighbrs,fwd$pointsin,1:3) adds #now reconstruct... fhat<-invtnp(fwd,f,nadd=max(adds)) #...and check that the desired points are the same: f[1:3] fhat[1:3]
Performs the lifting transform on a signal with grid input and corresponding function values f. There is a unique correspondence between the grid values and the function values. Can also cope with length vector input instead of gridpoint vector input.
fwtnp(input, f, nkeep = 2, intercept = TRUE, initboundhandl = "reflect", neighbours = 1, closest = FALSE, LocalPred = LinearPred, do.W=FALSE, varonly=FALSE)
fwtnp(input, f, nkeep = 2, intercept = TRUE, initboundhandl = "reflect", neighbours = 1, closest = FALSE, LocalPred = LinearPred, do.W=FALSE, varonly=FALSE)
input |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to input. Must be of the same length as input. |
nkeep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
intercept |
Indicates whether or not the regression curve includes an intercept. |
initboundhandl |
variable specifying how to handle the boundary at the start of the transform. Possible values are |
neighbours |
The number of neighbours over which the regression is performed at each step. If closest is false, then this in fact denotes the number of neighbours on each side of the removed point. |
closest |
Refers to the configuration of the chosen neighbours. If closest is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
LocalPred |
The type of regression to be performed. Possible options are |
do.W |
A boolean indicating whether the transform matrix should be computed and returned. |
varonly |
A boolean indicating whether only the coefficient
variances should be returned (if |
Given points on a line, input, each with a corresponding envf value this algorithm computes a lifting transform of the (input,f) data. If lengths are inputted (inputtype="lengths"), then the gridpoints are taken to be the left endpoints of the intervals defined by the lengths inputted.
Step One. Order the grid values so that corresponding intervals can be constructed.
Step Two. Compute "integrals" for each point. For each point its integral is the length of the interval associated to the gridpoint.
Step Three. Identify the point to remove as that with the smallest integral. Generally, we remove points in order of smallest to largest integral. The integrals of neighbours of removed points change at each step.
Step Four(a). The neighbours of the removed point are identified using the specified neighbour configuration. The value of f at the removed point is predicted using the specified regression curve over the neighbours, unless an adaptive procedure is chosen. In this case, the algorithm adjusts itself. The difference between the removed point's f value and the prediction is computed: this is the wavelet coefficient for the removed point. The difference replaces the function value in the vector coeff at the removed point's location. In this way wavelet coefficients gradually overwrite (scaling) function values in coeff.
Step Four(b). The integrals and the scaling function values (other coeff values) of neighbours of the removed point are updated. The values of the rest of the scaling coefficients are unaffected.
Step Five. Return to step 3 but in the identification of a point to remove the updated integrals are used.
The algorithm continues until as many points as desired are removed. If
do.W=TRUE
, the predict and update lifting steps are used to
propogate coefficient contributions to the transform matrix W
.
If varonly=TRUE
, only the (detail and scaling) coefficient
variances are returned. After each lifting step, the
coefficient variance is computed and the transform matrix
row corresponding to the lifted coefficient is deleted for the
next stage (minimal storage efficiency). The transform matrix is not
returned (i.e. W=NULL
).
x |
data vector of the grid used in the transform. |
coeff |
vector of detail and scaling coefficients in the wavelet decomposition of the signal. |
origlengths |
vector of initial interval lengths corresponding to the gridpoints. |
lengths |
vector of (updated) interval lengths at the end of the transform. This is of length nkeep. |
lengthsremove |
vector of interval lengths corresponding to the points removed during the transform (in removelist). |
pointsin |
indices into X of the scaling coefficients in the wavelet decomposition. These are the indices of the X values which remain after all points in removelist have been predicted and removed. This has length nkeep. |
removelist |
a vector of indices into X of the lifted coefficients during the transform (in the order of removal). |
neighbrs |
a list of indices into X. Each list entry gives the indices of the neighbours of the removed point used at that particular step of the transform. |
neighbours |
the user-specified number of neighbours used in the prediction step of the transform. |
gamlist |
a list of all the prediction weights used at each step of the transform. |
alphalist |
a list of the update coefficients used in the update step of the decomposition. |
schemehist |
a vector of character strings indicating the type of regression used at each step of the transform. |
interhist |
a boolean vector indicating whether or not an intercept was used in the regression curve at each step. |
clolist |
a boolean vector showing whether or not the neighbours were symmetrical |
Matt Nunes ([email protected]), Marina.Knight
AdaptNeigh
, AdaptPred
, CubicPred
, fwtnpmp
, invtnp
, LinearPred
, QuadPred
# # Generate some one-dimensional data: 100 observations. # input <- runif(100) f <- input^2 - 3*input # # Compute fwtnp function on this data # out <- fwtnp(input,f,LocalPred=AdaptPred,neighbours=2,closest=TRUE) # # That's it. #
# # Generate some one-dimensional data: 100 observations. # input <- runif(100) f <- input^2 - 3*input # # Compute fwtnp function on this data # out <- fwtnp(input,f,LocalPred=AdaptPred,neighbours=2,closest=TRUE) # # That's it. #
Performs the lifting transform on a signal with grid input and corresponding function values f, where f has multiple points, that is, more than one function value for (some of) the grid values.
fwtnpmp(input, f, nkeep = 2, intercept = TRUE, initboundhandl = "reflect", neighbours = 1, closest = FALSE, LocalPred = LinearPredmp, mpdet="ave")
fwtnpmp(input, f, nkeep = 2, intercept = TRUE, initboundhandl = "reflect", neighbours = 1, closest = FALSE, LocalPred = LinearPredmp, mpdet="ave")
input |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to input. Must be of the same length as input. |
nkeep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
intercept |
Indicates whether or not the regression curve includes an intercept. |
initboundhandl |
variable specifying how to handle the boundary at the start of the transform. Possible values are |
neighbours |
The number of neighbours over which the regression is performed at each step. If closest is false, then this in fact denotes the number of neighbours on each side of the removed point. |
closest |
Refers to the configuration of the chosen neighbours. If closest is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
LocalPred |
The type of regression to be performed. Possible options are |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. |
Given points on a line, input, with multiple f values, this algorithm computes a lifting transform of the (input,f) data.
Step One. Order the grid values so that corresponding intervals can be constructed, using the average function value at multiple points.
Step Two. Compute "integrals" for each point. For each point its integral is the length of the interval associated to the gridpoint.
Step Three. Identify the point to remove as that with the smallest integral. Generally, we remove points in order of smallest to largest integral. The integrals of neighbours of removed points change at each step.
Step Four(a). The neighbours of the removed point are identified using the specified neighbour configuration. The values of f at the removed point are predicted using the specified regression curve over the neighbours, unless an adaptive procedure is chosen. In this case, the algorithm adjusts itself. If the removed point has multiple point neighbours, the extra points are used in the regression. The difference between the removed point(s) f value and the prediction is computed: these are the wavelet coefficient for the removed point. When the removed point is itself a multiple point, this will produce multiple detail coefficients at that point. mpdet says how the final detail coefficient for that point is recorded (either averaged or the minimum). The detail replaces the function value in the vector coeff at the removed point's location. In this way wavelet coefficients gradually overwrite (scaling) function values in coeff.
Step Four(b). The integrals and the scaling function values (other coeff and coefflist values) of neighbours of the removed point are updated. The values of the rest of the scaling coefficients are unaffected.
Step Five. Return to step 3 but in the identification of a point to remove the updated integrals are used.
The algorithm continues until as many points as desired are removed.
x |
data vector of the grid used in the transform. |
coeff |
vector of detail and scaling coefficients in the wavelet decomposition of the signal. |
coefflist |
list of detail and scaling coefficients. Should be the same as coeff, apart from possible multiple points at the scaling function values. |
origlengths |
vector of initial interval lengths corresponding to the gridpoints. |
lengths |
vector of (updated) interval lengths at the end of the transform. This is of length nkeep. |
lengthsremove |
vector of interval lengths corresponding to the points removed during the transform (in removelist). |
pointsin |
indices into X of the scaling coefficients in the wavelet decomposition. These are the indices of the X values which remain after all points in removelist have been predicted and removed. This has length nkeep. |
removelist |
a vector of indices into X of the lifted coefficients during the transform (in the order of removal). |
neighbrs |
a list of indices into X. Each list entry gives the indices of the neighbours of the removed point used at that particular step of the transform. |
neighbours |
the user-specified number of neighbours used in the prediction step of the transform. |
gamlist |
a list of all the prediction weights used at each step of the transform. |
alphalist |
a list of the update coefficients used in the update step of the decomposition. |
schemehist |
a vector of character strings indicating the type of regression used at each step of the transform. |
interhist |
a boolean vector indicating whether or not an intercept was used in the regression curve at each step. |
clolist |
a boolean vector showing whether or not the neighbours were symmetrical |
g |
a list desscribing the group structure (indices) of the initial function values. |
mp |
a boolean vector of which of the groups are actually multiple points. |
Matt Nunes ([email protected]), Marina.Knight
AdaptNeighmp
, AdaptPredmp
, CubicPredmp
, fwtnp
, invtnpmp
, LinearPredmp
, QuadPredmp
#read in multiple point data... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel out<-fwtnpmp(times,accel,LocalPred=AdaptPredmp,neighbours=2) out$coeff #these are the detail coefficients of the transform.
#read in multiple point data... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel out<-fwtnpmp(times,accel,LocalPred=AdaptPredmp,neighbours=2) out$coeff #these are the detail coefficients of the transform.
This function uses the user's neighbourhood configuration input to find the neighbours of the lifted datapoint to be used in the prediction step of the transform.
getnbrs(X, remove, pointsin, neighbours, closest)
getnbrs(X, remove, pointsin, neighbours, closest)
X |
The vector of gridpoints. |
remove |
the index (into X) of the point to be removed. |
pointsin |
The indices of gridpoints still to be removed. |
neighbours |
the number of neighbours to find for use in prediction. |
closest |
Boolean argument: If FALSE, the neighbours selected are the ones on both sides of the removed point. |
The function uses the value of neighbours and closest to choose the neighbours to return. If closest is FALSE, pointsin is used to find neighbours indices on both sides of the index of the removed point (remove). If closest is TRUE, then the function uses the gridpoint vector (X) to calculate distances from the removed point to neighbours neighbours on each side of the removed point (if they exist) and then uses this information to choose the closest neighbours ones, recording where they lie in relation to the removed point, and accordingly their index can be obtained. If the removed point is on the boundary, then by choice, we take only one neighbour.
nbrs |
the indices of the neighbours corresponding to the specified configuration. |
index |
the indices into pointsin of the neighbours |
Matt Nunes ([email protected]), Marina Knight
x1<-runif(20) # x1 # y1<-make.signal2("bumps",x=x1) # y1 # order(x1) # # shows where the points lie in relation to each other. # neigh<-getnbrs(x1,3,order(x1),4,TRUE) # neigh$nbrs # # these are the indices of the 4 closest neighbours to point 3. #
x1<-runif(20) # x1 # y1<-make.signal2("bumps",x=x1) # y1 # order(x1) # # shows where the points lie in relation to each other. # neigh<-getnbrs(x1,3,order(x1),4,TRUE) # neigh$nbrs # # these are the indices of the 4 closest neighbours to point 3. #
Estimates individual wavelet coefficient variances using a sliding window approach.
heterovar(y, detail, al)
heterovar(y, detail, al)
y |
a vector of the gridpoints of removelist after executing the forward transform, in the order of the gridpoint vector. |
detail |
the vector of detail coefficients after the forward transform has been performed, in the order of the gridpoint vector. |
al |
The list of indices into removelist divided into artificial levels. |
The function works out the interval endpoints for each gridpoint in removelist, based on an initial window length of one fifth of the range of y, and then adjusts them so that they lie within the range of y. The indices of the removelist points inside these intervals are then compared against the indices of the first artificial level for the data. These new indices are then used to compute the individual coefficient variances, based on the detail values of the new indices. If any of the window indices list entries contains less than four values, then the initial window length is increased by 5% and the process redone, until each window contains at least four coefficients.
ep1 |
a two-column matrix with the (true) endpoints of the windows from which to calculate the coefficient variances (according to the specified window length). |
ep2 |
a two-column matrix with the endpoints of the windows from which to calculate the coefficient variances (adjusted to be of the window length and within the range of y). |
idlist |
a list of indices into y showing the points each interval contains. |
newidlist |
a list of indices into y showing the points each interval contains, which are also in the first artificial level. |
dlist |
a list of detail coefficients which correspond to the indices in newidlist. |
varvec |
a vector of median absolute deviation values (from the median) for the coefficients in dlist. |
varvec1 |
a vector of median absolute deviation values (from the median), centered at zero, for the coefficients in dlist. |
varvec2 |
a vector of median absolute deviation values (from the median), centered at zero, for the coefficients in dlist. |
Matt Nunes ([email protected]), Marina Knight
x1<-runif(256) # y1<-make.signal2("doppler",x=x1) # fwd<-fwtnp(x1,y1,LocalPred=AdaptNeigh,neighbours=2) # y<-fwd$lengthsremove rem<-fwd$removelist al<-artlev(y,rem) # yrem<-x1[sort(rem)] detail<-fwd$coeff[sort(rem)] # h<-heterovar(yrem,detail,al) # h$varvec[1:10] # #the first ten coefficient variances to be used in the normalisation of the detail #coefficients
x1<-runif(256) # y1<-make.signal2("doppler",x=x1) # fwd<-fwtnp(x1,y1,LocalPred=AdaptNeigh,neighbours=2) # y<-fwd$lengthsremove rem<-fwd$removelist al<-artlev(y,rem) # yrem<-x1[sort(rem)] detail<-fwd$coeff[sort(rem)] # h<-heterovar(yrem,detail,al) # h$varvec[1:10] # #the first ten coefficient variances to be used in the normalisation of the detail #coefficients
This function constructs the intervals around the grid values to be used as scaling integrals during the transform
intervals(X, initboundhandl)
intervals(X, initboundhandl)
X |
The vector of gridpoints. |
initboundhandl |
the interval construction at the boundary. Takes the value |
The function constructs the intervals by sorting the observed gridpoints. The endpoints of the intervals are found as the midpoints between consecutive (sorted) gridpoints. In this way the intervals are not necessarily centered around the gridpoints. The first and last intervals are then modified according to initboundhandl (see above). These intervals represent the support of the initial scaling functions associated to each gridpoint.
intervals |
a vector of length ( |
order |
|
Matt Nunes ([email protected]), Marina Knight
x2<-runif(50) x2 # intervals(x2,"reflect") # #check that the gridpoints are between the interval vector entries... #
x2<-runif(50) x2 # intervals(x2,"reflect") # #check that the gridpoints are between the interval vector entries... #
Performs the inverse lifting transform on a detail and scaling coefficient vector with grid X and corresponding coefficients coeff. There is a unique correspondence between the grid values and the function values.
invtnp(X, coeff, lengths, lengthsremove, pointsin, removelist, neighbrs, schemehist, interhist, nadd = length(X) - 2, intercept = TRUE, neighbours = 1, closest = FALSE, LocalPred = LinearPred)
invtnp(X, coeff, lengths, lengthsremove, pointsin, removelist, neighbrs, schemehist, interhist, nadd = length(X) - 2, intercept = TRUE, neighbours = 1, closest = FALSE, LocalPred = LinearPred)
X |
data vector of the grid used in the transform. |
coeff |
vector of detail and scaling coefficients in the wavelet decomposition of the signal. |
lengths |
vector of interval lengths to be used in the update step of the transform. This is of length pointsin. |
lengthsremove |
vector of interval lengths corresponding to the points removed during the forward transform. |
pointsin |
indices into X of the scaling coefficients in the wavelet decomposition. |
removelist |
a vector of indices into X of the lifted coefficients during the transform (in the order of removal). |
neighbrs |
a list of indices into X. Each list entry gives the indices of the neighbours of the removed point used at that particular step of the forward transform. |
schemehist |
a vector of character strings indicating the type of regression used at each step of the forward transform. This is NULL apart from when AdaptNeigh is to be used in the transform. |
interhist |
a boolean vector indicating whether or not an intercept was used in the regression curve at each step of the forward transform. This is NULL apart from when AdaptNeigh is to be used in the transform. |
nadd |
The number of steps to perform of the inverse transform. This corresponds to ( |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. |
closest |
a boolean value showing whether or not the neighbours were symmetrical (FALSE) about the removed point during the transform. |
LocalPred |
The type of regression to be performed. Possible options are |
This algorithm reconstructs an estimate of a function/signal from information about detail and scaling coefficients in its wavelet decomposition. Step One. Extract information about the first point to be added in the transform from the last entries in removelist, lengthsremove and neighbrs. Use this information to discover the correct placement of this point in relation to the indices in pointsin.
Step Two. Using the information about the prediction scheme used in the "forward" transform, use the corresponding version of LocalPred to obtain prediction weights and value for the lifted point.
Step Three. "Undo" the update step of the transform, and then the prediction step of the transform. The vector of scaling and detail coefficients, as well as the interval lengths are modified accordingly.
Step Four. Remove the added point from removelist. Update pointsin and lengths to contain the added point.
Step Five. Return to step 1 but in the identification of the next point to add, the second to last entries in (the original) removelist, lengthsremove and neighbrs are used to indentify the point and then place it in pointsin.
The algorithm continues like this until as many points as desired are added.
X |
data vector of the grid used in the transform. |
coeff |
vector of signal function values after inversion. |
lengths |
vector of interval lengths at the start of the transform. This should be the same as |
lengthsremove |
vector of interval lengths corresponding to the points added during the transform. |
pointsin |
indices into X of the scaling coefficients in the wavelet decomposition. These are the indices of the X values which remain after all points in removelist have been added. For a straight forward-inverse transform implementation, this should be |
removelist |
a vector of indices into X of the lifted coefficients during the transform (in the reverse order of how they were added). |
Matt Nunes ([email protected]), Marina Knight
AdaptNeigh
, AdaptPred
, CubicPred
, fwtnp
, invtnpmp
, LinearPred
, QuadPred
, UndoPointsUpdate
# # Generate some one-dimensional data: 500 observations. x2<-runif(500) f2<-make.signal2("bumps",x=x2) # # perform the forward transform... out<-fwtnp(x2,f2,LocalPred=AdaptPred) # # and now invert using the information from out... # fhat<-invtnp(x2,out$coeff,out$lengths,out$lengthsremove,out$pointsin,out$removelist, out$neighbrs,out$schemehist,out$interhist,LocalPred=AdaptPred) # # Now compare the original signal with the reconstruction. sum(abs(f2-fhat$coeff)) #
# # Generate some one-dimensional data: 500 observations. x2<-runif(500) f2<-make.signal2("bumps",x=x2) # # perform the forward transform... out<-fwtnp(x2,f2,LocalPred=AdaptPred) # # and now invert using the information from out... # fhat<-invtnp(x2,out$coeff,out$lengths,out$lengthsremove,out$pointsin,out$removelist, out$neighbrs,out$schemehist,out$interhist,LocalPred=AdaptPred) # # Now compare the original signal with the reconstruction. sum(abs(f2-fhat$coeff)) #
Performs the inverse lifting transform on a detail and scaling coefficient vector with grid X and corresponding coefficients coeff, based on multiple point information.
invtnpmp(X, coefflist, coeff, lengths, lengthsremove, pointsin, removelist, neighbrs, newneighbrs, schemehist, interhist, nadd = length(X) - 2, intercept = TRUE, neighbours = 1, closest = FALSE, LocalPred = LinearPredmp, mpdet)
invtnpmp(X, coefflist, coeff, lengths, lengthsremove, pointsin, removelist, neighbrs, newneighbrs, schemehist, interhist, nadd = length(X) - 2, intercept = TRUE, neighbours = 1, closest = FALSE, LocalPred = LinearPredmp, mpdet)
X |
data vector of the grid used in the transform. |
coefflist |
list of detail and multiple scaling coefficients. |
coeff |
vector of detail and scaling coefficients in the wavelet decomposition of the signal. |
lengths |
vector of interval lengths to be used in the update step of the transform. This is of length pointsin. |
lengthsremove |
vector of interval lengths corresponding to the points removed during the forward transform. |
pointsin |
indices into X of the scaling coefficients in the wavelet decomposition. |
removelist |
a vector of indices into X of the lifted coefficients during the transform (in the order of removal). |
neighbrs |
a list of indices into X. Each list entry gives the indices of the neighbours of the removed point used at that particular step of the forward transform. |
newneighbrs |
a list of indices into X. Each list entry gives the indices of the multiple neighbours of the removed point used at that particular step of the forward transform. |
schemehist |
a vector of character strings indicating the type of regression used at each step of the forward transform. This is NULL apart from when AdaptNeigh is to be used in the transform. |
interhist |
a boolean vector indicating whether or not an intercept was used in the regression curve at each step of the forward transform. This is NULL apart from when AdaptNeigh is to be used in the transform. |
nadd |
The number of steps to perform of the inverse transform. This corresponds to ( |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. |
closest |
a boolean value showing whether or not the neighbours were symmetrical (FALSE) about the removed point during the transform. |
LocalPred |
The type of regression to be performed. Possible options are |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. |
This algorithm reconstructs an estimate of a function/signal from information about detail and scaling coefficients in its wavelet decomposition, using the multiple point structure information to estimate the spread of original points. Step One. Extract information about the first point to be added in the transform from the last entries in removelist, lengthsremove and neighbrs. Use this information to discover the correct placement of this point in relation to the indices in pointsin.
Step Two. Using the information about the prediction scheme used in the "forward" transform, use the corresponding version of LocalPred to obtain prediction weights and value for the lifted point.
Step Three. "Undo" the update step of the transform, and then the prediction step of the transform. The vector of scaling and detail coefficients, as well as the interval lengths are modified accordingly.
Step Four. Remove the added point from removelist. Update pointsin and lengths to contain the added point.
Step Five. Return to step 1 but in the identification of the next point to add, the second to last entries in (the original) removelist, lengthsremove and neighbrs are used to indentify the point and then place it in pointsin.
The algorithm continues like this until as many points as desired are added.
X |
data vector of the grid used in the transform. |
coeff |
vector of signal function values after inversion. |
lengths |
vector of interval lengths at the start of the transform. This should be the same as |
lengthsremove |
vector of interval lengths corresponding to the points added during the transform. |
pointsin |
indices into X of the scaling coefficients in the wavelet decomposition. These are the indices of the X values which remain after all points in removelist have been added. For a straight forward-inverse transform implementation, this should be |
removelist |
a vector of indices into X of the lifted coefficients during the transform (in the reverse order of how they were added). |
Matt Nunes ([email protected]), Marina Knight
AdaptNeighmp
, AdaptPredmp
, CubicPredmp
, fwtnpmp
, invtnp
, LinearPredmp
, QuadPredmp
,
UndoPointsUpdatemp
#read in multiple point data... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel shortf<-adjustx(times,accel)$sepf out<-fwtnpmp(times,accel,LocalPred=CubicPredmp,neighbours=2) inv<-invtnpmp(times, out$coefflist, out$coeff, out$lengths, out$lengthsremove, out$pointsin, out$removelist,out$neighbrs,out$newneighbrs,out$schemehist,out$interhist, neighbours = 2, LocalPred = CubicPredmp) sum(abs(shortf-inv$coeff))
#read in multiple point data... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel shortf<-adjustx(times,accel)$sepf out<-fwtnpmp(times,accel,LocalPred=CubicPredmp,neighbours=2) inv<-invtnpmp(times, out$coefflist, out$coeff, out$lengths, out$lengthsremove, out$pointsin, out$removelist,out$neighbrs,out$newneighbrs,out$schemehist,out$interhist, neighbours = 2, LocalPred = CubicPredmp) sum(abs(shortf-inv$coeff))
This function constructs the vector of interval lengths from a vector of interval endpoints.
lengthintervals(X, I, type = "midpoints", neighbours, closest)
lengthintervals(X, I, type = "midpoints", neighbours, closest)
X |
The vector of gridpoints. |
I |
a vector of interval endpoints. This is of length |
type |
a character string, either |
neighbours |
the number of neighbours to be used in the prediction step of the transform. This is only used if closest=TRUE, since it specifies how many distances to average over when type="average". |
closest |
indicates whether the neighbourhood structure to be used in the transform is symmetrical or not. When combined with type="average", enables the option of average closest neighbour distance as the associated interval lengths to the gridpoints. |
The function computes the interval lengths by finding the differences between the consecutive entries of the supplied interval vector I. In the case of the choice of average closest neighbour distance interval association, the method uses the function getnbrs
to find the initial neighbours of each gridpoint to compute the average distances.
lengths |
a vector of |
initialnbrs |
a matrix with columns |
initialindex |
If closest=TRUE and type="average", a matrix of dimension |
Matt Nunes ([email protected]), Marina Knight
input<-runif(10) #gridpoint vector # I<-intervals(input,"reflect") #create the interval endpoint vector using the input # lengthintervals(input,I,"average",3,TRUE) # #computes 'intervals' based on 3 closest neighbour distance averages #
input<-runif(10) #gridpoint vector # I<-intervals(input,"reflect") #create the interval endpoint vector using the input # lengthintervals(input,I,"average",3,TRUE) # #computes 'intervals' based on 3 closest neighbour distance averages #
This function performs the prediction lifting step using a linear regression curve given a configuration of neighbours.
LinearPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
LinearPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
The procedure performs linear regression using the given neighbours using an intercept if chosen. The regression coefficients (weights) are used to predict the new function value at the removed point.
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of the column X[nbrs] augmented with a column of ones if an intercept is used. Refer to any reference on linear regression for more details. |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
Matt Nunes ([email protected]), Marina Knight
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform linear regression based on the neighbours (without intercept) # lp<-LinearPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # # lp # #the regression curve details
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform linear regression based on the neighbours (without intercept) # lp<-LinearPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # # lp # #the regression curve details
This function performs the prediction lifting step using a linear regression curve given a configuration of neighbours, for multiple point data.
LinearPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
LinearPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
coefflist |
the list of detail and multiple scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. Note that this is taken to standardise the input when LocalPredmp is called. |
g |
the group structure of the multiple point data. Note that this is taken to standardise the input when LocalPredmp is called. |
The procedure performs linear regression using the given neighbours using an intercept if chosen. The regression coefficients (weights) are used to predict the new function value at the removed point.
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of the column X[newnbrs] augmented with a column of ones if an intercept is used. Refer to any reference on linear regression for more details. |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
The Matrix is needed for this function.
Matt Nunes ([email protected]), Marina Knight
CubicPredmp
, fwtnpmp
, QuadPredmp
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs LinearPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs LinearPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
This function computes signal function values based on a grid input.
make.signal2(name, x, snr = Inf, ...)
make.signal2(name, x, snr = Inf, ...)
name |
a character string of the test signal to create. |
x |
a vector of gridpoints. |
snr |
optional argument to scale the function values according to a signal-to-noise ratio. |
... |
any additional arguments. |
This function is based on the make.signal
function included in the S-Plus wavelets module, except that the x vector can be irregular. As well as the signals included for the original version (e.g. the Donoho/Johnstone test signals), a piecewise polynomial can be sampled.
z |
the signal function values. |
The test signals have domain [0,1], so the grid vector x must have values within this interval.
Matt Nunes ([email protected]), Marina Knight
#create grid vector # xgrid<-rnorm(50) xgrid # pp<-make.signal2("ppoly",x=xgrid) # #piecewise polynomial data vector # plot(sort(xgrid),pp[order(xgrid)],type="l") #
#create grid vector # xgrid<-rnorm(50) xgrid # pp<-make.signal2("ppoly",x=xgrid) # #piecewise polynomial data vector # plot(sort(xgrid),pp[order(xgrid)],type="l") #
Works out two alternative condition numbers for the transform associated to the prediction scheme given in the arguments to the function.
matcond(x, f, Pred, neigh, int, clo, keep)
matcond(x, f, Pred, neigh, int, clo, keep)
x |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to x. Must be of the same length as x. |
Pred |
The type of regression to be performed. Possible options are |
neigh |
The number of neighbours over which the regression is performed at each step. If clo is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If clo is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
The function uses the transform matrices to work out their norms and singular value decompositions. Condition numbers are calculated by and
svd$d[1]/svd$d[nrow(T_j)]
respectively.
cno |
the condition numbers for the augmented transform matrices, calculated using the Frobenius norm (see condno). |
v |
the condition numbers for the augmented transform matrices, calculated using the ratio between the largest to the smallest singular values in the singular value decomposition of the augmented matrices. |
a |
the transform matrix information for the transform (output from fwtnp). |
Matt Nunes ([email protected]), Marina Knight
x1<-runif(256) y1<-make.signal2("doppler",x=x1) # m<-matcond(x1,y1,AdaptNeigh,2,TRUE,TRUE,2) # m$cno # m$v # shows the two different condition number measures for the matrix associated # to the transform performed. #
x1<-runif(256) y1<-make.signal2("doppler",x=x1) # m<-matcond(x1,y1,AdaptNeigh,2,TRUE,TRUE,2) # m$cno # m$v # shows the two different condition number measures for the matrix associated # to the transform performed. #
This function jitters grid values by a proportion of the regular distance between consecutive gridpoints and then alters it to lie in [0,1].
modjitter(x, amount)
modjitter(x, amount)
x |
a vector to be jittered (e.g. a gridpoint vector). |
amount |
a value of how much to jitter the vector (expressed as a proportion of the regular gridpoint distance, d). |
The function uses dojitter to jitter the gridpoint vector by (amount*d
) . The endpoints are fixed to be zero and one, and the corresponding jx values to x[2]
and x[length(x)-1]
are randomised again in the intervals [0,x[2]+amount*d]
and [x[length(x)-1]-amount*d,1]
respectively.
jx |
the jittered version of x |
Matt Nunes ([email protected]), Marina Knight
#create grid vector # xgrid<-seq(0,1,length=51) # xgrid # #a regularly-spaced grid on [0,1] # modjitter(xgrid,1) # #jitters xgrid with a maximum change of .02, keeping endpoints of zero and one
#create grid vector # xgrid<-seq(0,1,length=51) # xgrid # #a regularly-spaced grid on [0,1] # modjitter(xgrid,1) # #jitters xgrid with a maximum change of .02, keeping endpoints of zero and one
This table gives the results of 133 simulations showing the effects of motorcycle crashes on victims heads: time after a simulated impact with motorcycles and head acceleration of a PTMO (post mortem human test object) were recorded.
data(motorcycledata)
data(motorcycledata)
A 133 by 2 data frame.
Hardle, W. (1990) Applied Nonparametric Regression. Cambridge University Press.
This function performs the update lifting step using a given configuration of neighbours and boundary handling.
PointsUpdate(X, coeff, nbrs, index, remove, pointsin, weights, lengths)
PointsUpdate(X, coeff, nbrs, index, remove, pointsin, weights, lengths)
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the lifting step. |
index |
the indices into pointsin of nbrs, the neighbours of remove. |
remove |
the index (into X) of the point to be removed. |
pointsin |
The indices of gridpoints still to be removed. |
weights |
the prediction weights obtained from the regression in the prediction step of the transform. |
lengths |
the vector of interval lengths at the present step of the transform (to be updated). |
The procedure performs a minimum norm update lifting step. Firstly the interval lengths are updated using the coefficients obtained. Secondly, the scaling and detail coefficient vector is modified using the new interval lengths.
coeff |
vector of (modified) detail and scaling coefficients to be used in the next step of the transform. |
lengths |
the vector of interval lengths after the update step of the transform. |
r |
the index into pointsin of remove. |
N |
length(pointsin). |
weights |
The regression coefficients used in prediction. |
alpha |
the update weights used to update lengths and coeff. |
Matt Nunes ([email protected]), Marina Knight
AdaptNeigh
, AdaptPred
, CubicPred
, fwtnp
, LinearPred
, QuadPred
, UndoPointsUpdate
# # Generate some blocks data: 100 observations. # x <- runif(100) y <-make.signal2("blocks",x=x) # #find initial interval lengths... # I<-intervals(x,"reflect") lengths<-lengthintervals(x,I,neighbours=2,closest=FALSE) # #perform prediction step... p<-AdaptNeigh(order(x),x,y,32,5,TRUE,2) # # u<-PointsUpdate(x,p$results[[6]],p$newinfo[[2]],p$newinfo[[3]],5,order(x),p$results[[4]],lengths) # #and here are the updated coefficients... u$coeff #
# # Generate some blocks data: 100 observations. # x <- runif(100) y <-make.signal2("blocks",x=x) # #find initial interval lengths... # I<-intervals(x,"reflect") lengths<-lengthintervals(x,I,neighbours=2,closest=FALSE) # #perform prediction step... p<-AdaptNeigh(order(x),x,y,32,5,TRUE,2) # # u<-PointsUpdate(x,p$results[[6]],p$newinfo[[2]],p$newinfo[[3]],5,order(x),p$results[[4]],lengths) # #and here are the updated coefficients... u$coeff #
This function performs the update lifting step using a given configuration of neighbours and boundary handling.
PointsUpdatemp(X, coeff, nbrs, newnbrs, index, remove, pointsin, weights, lengths)
PointsUpdatemp(X, coeff, nbrs, newnbrs, index, remove, pointsin, weights, lengths)
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the lifting step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
index |
the indices into pointsin of nbrs, the neighbours of remove. |
remove |
the index (into X) of the point to be removed. |
pointsin |
The indices of gridpoints still to be removed. |
weights |
the prediction weights obtained from the regression in the prediction step of the transform. |
lengths |
the vector of interval lengths at the present step of the transform (to be updated). |
The procedure performs a minimum norm update lifting step. Firstly the interval lengths are updated using the coefficients obtained. Secondly, the scaling and detail coefficient list is modified using the new interval lengths.
coeff |
vector of (modified) detail and scaling coefficients to be used in the next step of the transform. |
lengths |
the vector of interval lengths after the update step of the transform. |
r |
the index into pointsin of remove. |
N |
length(pointsin). |
weights |
The regression coefficients used in prediction. |
alpha |
the update weights used to update lengths and coeff. |
Matt Nunes ([email protected]), Marina Knight
AdaptNeighmp
, AdaptPredmp
, CubicPredmp
, fwtnpmp
, LinearPredmp
,
QuadPredmp
, UndoPointsUpdatemp
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } I<-intervals(X,"reflect") lengths<-lengthintervals(X,I,neighbours=2,closest=TRUE) #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs p<-AdaptNeighmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g) nbrs<-p$newinfo[[3]] nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } newnbrs coefflist[[31]]<-p$results[[6]][31] u<-PointsUpdatemp(X,coefflist,p$newinfo[[2]],newnbrs,p$newinfo[[3]],31, order(X),p$results[[4]],lengths) # #and here is the updated coefficient list... u$coeff
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } I<-intervals(X,"reflect") lengths<-lengthintervals(X,I,neighbours=2,closest=TRUE) #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs p<-AdaptNeighmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g) nbrs<-p$newinfo[[3]] nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } newnbrs coefflist[[31]]<-p$results[[6]][31] u<-PointsUpdatemp(X,coefflist,p$newinfo[[2]],newnbrs,p$newinfo[[3]],31, order(X),p$results[[4]],lengths) # #and here is the updated coefficient list... u$coeff
Posterior mean calculations for Bayesian thresholding.
This function replaces one in the EbayesThresh package, which perform Bayesian thresholding. For more information, see help by Silverman (see references below).
Johnstone, I.M. and Silverman, B.W. (2002) EbayesThresh: R and S-PLUS software for Empirical Bayes thresholding (Submitted for publication).
Johnstone, I.M. and Silverman, B.W. (2004) Needles and hay in haystacks: Empirical Bayes estimates of possibly sparse sequences. Ann. Statist., 32, 1594–1649.
denoise
,denoisehetero
, denoiseheteromp
, denoiseheteroprop
This function performs the prediction lifting step using a quadratic regression curve given a configuration of neighbours.
QuadPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
QuadPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
The procedure performs quadratic regression using the given neighbours using an intercept if chosen. The regression coefficients (weights) are used to predict the new function value at the removed point. If there are not enough neighbours to generate a quadratic regression curve, the order of prediction is decreased down to LinearPred
.
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of columns |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
Matt Nunes ([email protected]), Marina Knight
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform quadratic prediction based on the neighbours (without intercept) # qp<-QuadPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # # qp[3:5] # #the regression curve details
# # Generate some doppler data: 500 observations. # tx <- runif(500) ty<-make.signal2("doppler",x=tx) # # Compute the neighbours of point 173 (2 neighbours on each side) # out<-getnbrs(tx,173,order(tx),2,FALSE) # # Perform quadratic prediction based on the neighbours (without intercept) # qp<-QuadPred(order(tx),tx,ty,out$nbrs,173,FALSE,2) # # qp[3:5] # #the regression curve details
This function performs the prediction lifting step using a quadratic regression curve given a configuration of neighbours, for multiple point data.
QuadPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
QuadPredmp(pointsin, X, coefflist, coeff, nbrs, newnbrs, remove, intercept, neighbours, mpdet, g)
pointsin |
The indices of gridpoints still to be removed. |
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
coefflist |
the list of detail and multiple scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the prediction step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
remove |
the index (into X) of the point to be removed. |
intercept |
Boolean value for whether or not an intercept is used in the prediction step of the transform. |
neighbours |
the number of neighbours in the computation of the predicted value. This is not actually used specifically in |
mpdet |
how the mutiple point detail coefficients are computed. Possible values are "ave", in which the multiple detail coefficients produced when performing the multiple predictions are averaged, or "min", where the overall minimum detail coefficient is taken. Note that this is taken to standardise the input when LocalPredmp is called. |
g |
the group structure of the multiple point data. Note that this is taken to standardise the input when LocalPredmp is called. |
The procedure performs quadratic regression using the given neighbours using an intercept if chosen. The regression coefficients (weights) are used to predict the new function value at the removed point.
Xneigh |
matrix of X values corresponding to the neighbours of the removed point. The matrix consists of the column X[newnbrs] augmented with a column of ones if an intercept is used. Refer to any reference on linear regression for more details. |
mm |
the matrix from which the prediction is made. In terms of Xneigh, it is |
bhat |
The regression coefficients used in prediction. |
weights |
the prediction weights for the neighbours. |
pred |
the predicted function value obtained from the regression. |
coeff |
vector of (modified) detail and scaling coefficients to be used in the update step of the transform. |
Matt Nunes ([email protected]), Marina Knight
CubicPredmp
, fwtnpmp
, LinearPredmp
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs QuadPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs QuadPredmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g)
This function calculates matrix inverses for symmetric matrices.
Rmatsolve(m)
Rmatsolve(m)
m |
a (symmetric) matrix. |
This function uses the eigenvalue decomposition of a matrix m to work out its inverse. The function is used here since standard matrix inverse algorithms do not cope well with matrices which are near singular (this often happens in the regression stages of the forward transforms.
inv |
the matrix inverse of m. |
Matt Nunes ([email protected]), Marina Knight
# #create a 4x4 matrix m<-matrix(runif(16),4,4) temp<-crossprod(m) #i.e. temp is t(m)%*%m inv<-Rmatsolve(temp)
# #create a 4x4 matrix m<-matrix(runif(16),4,4) temp<-crossprod(m) #i.e. temp is t(m)%*%m inv<-Rmatsolve(temp)
Works out the transform matrix for a particular prediction scheme and neighbourhood structure.
transmatdual(x, f, Pred = AdaptNeigh, neigh = 1, int = TRUE, clo = TRUE, keep = 2,varonly=FALSE)
transmatdual(x, f, Pred = AdaptNeigh, neigh = 1, int = TRUE, clo = TRUE, keep = 2,varonly=FALSE)
x |
A vector of grid values. Can be of any length, not necessarily equally spaced. |
f |
A vector of function values corresponding to x. Must be of the same length as x. |
Pred |
The type of regression to be performed. Possible options are |
neigh |
The number of neighbours over which the regression is performed at each step. If clo is false, then this in fact denotes the number of neighbours on each side of the removed point. |
int |
Indicates whether or not the regression curve includes an intercept. |
clo |
Refers to the configuration of the chosen neighbours. If clo is false, the neighbours will be chosen symmetrically around the removed point. Otherwise, the closest neighbours will be chosen. |
keep |
The number of scaling coefficients to be kept in the final representation of the initial signal. This must be at least two. |
varonly |
A boolean variable indicating whether only the
coefficient variances should be returned, i.e. just the diagonal of
the transform matrix |
The function uses Amatdual
to form the refinement matrices , from which the augmented matrices
are constructed. This process is iterated, to find the transform matrix (the top level augmented matrix). The rows and columns of this matrix are then reordered to be in the order of
out$coeff
, i.e. so that the columns correspond to .
out |
the output from the forward transform. |
Wnew |
the matrix associated to the wavelet transform. |
x |
the original gridpoint vector. |
This function has been left in the package for completeness. However, the transform matrix is (optionally) computed within the forward lifting
transform function fwtnp
.
Matt Nunes ([email protected]), Marina Knight
x1<-runif(10) y1<-make.signal2("doppler",x=x1) # a<-transmatdual(x1,y1,AdaptNeigh,2,TRUE,TRUE,2) # a$Wnew # #the transform matrix for this adaptive lifting scheme
x1<-runif(10) y1<-make.signal2("doppler",x=x1) # a<-transmatdual(x1,y1,AdaptNeigh,2,TRUE,TRUE,2) # a$Wnew # #the transform matrix for this adaptive lifting scheme
This function undoes the update lifting step in the inverse transform.
UndoPointsUpdate(X, coeff, nbrs, index, remove, r, N, pointsin, gamweights, lengths, lengthrem)
UndoPointsUpdate(X, coeff, nbrs, index, remove, r, N, pointsin, gamweights, lengths, lengthrem)
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the lifting step. |
index |
the indices into pointsin of nbrs, the neighbours of remove, the point to be added. |
remove |
the index (into X) of the point to be added. |
r |
the index into pointsin of the added point, remove. |
N |
length(pointsin). |
pointsin |
The indices of gridpoints still to be added. |
gamweights |
the prediction weights obtained from the regression in the prediction step of the transform. |
lengths |
the vector of interval lengths at the present step of the transform. |
lengthrem |
the interval length associated to the point to be added. |
This procedure uses minimum norm update coefficients to invert the update step of the transform. The prediction weights are used to change the interval lengthsm before the update weights are used to modify coeff.
coeff |
vector of (modified) detail and scaling coefficients to be used later in the transform. |
lengths |
vector of interval lengths after inverting the update step of the transform. |
alpha |
the weights used to modify lengths and coeff. |
Matt Nunes ([email protected]), Marina Knight
AdaptNeigh
, AdaptPred
, CubicPred
, invtnp
, LinearPred
, PointsUpdate
,
QuadPred
# # Generate some blocks data: 100 observations. # x <- runif(100) y <-make.signal2("blocks",x=x) # #find initial interval lengths... # I<-intervals(x,"reflect") lengths<-lengthintervals(x,I,neighbours=2,closest=FALSE) # #perform prediction step... p<-AdaptNeigh(order(x),x,y,32,5,TRUE,2) # # u<-PointsUpdate(x,p$results[[6]],p$newinfo[[2]],p$newinfo[[3]],5,order(x),p$results[[4]], lengths) # p2<-setdiff(order(x),5) a<-which(order(x)==5) l2<-lengths[setdiff(1:100, a)] # #remove the lifted coefficient # #now undo the update step... # undo<-UndoPointsUpdate(x,u$coeff,p$newinfo[[2]],p$newinfo[[3]],5,a,99,p2, p$results[[4]],l2,lengths[a]) #
# # Generate some blocks data: 100 observations. # x <- runif(100) y <-make.signal2("blocks",x=x) # #find initial interval lengths... # I<-intervals(x,"reflect") lengths<-lengthintervals(x,I,neighbours=2,closest=FALSE) # #perform prediction step... p<-AdaptNeigh(order(x),x,y,32,5,TRUE,2) # # u<-PointsUpdate(x,p$results[[6]],p$newinfo[[2]],p$newinfo[[3]],5,order(x),p$results[[4]], lengths) # p2<-setdiff(order(x),5) a<-which(order(x)==5) l2<-lengths[setdiff(1:100, a)] # #remove the lifted coefficient # #now undo the update step... # undo<-UndoPointsUpdate(x,u$coeff,p$newinfo[[2]],p$newinfo[[3]],5,a,99,p2, p$results[[4]],l2,lengths[a]) #
This function undoes the update lifting step in the multiple observation inverse transform.
UndoPointsUpdatemp(X, coeff, nbrs, newnbrs, index, remove, r, N, pointsin, gamweights, lengths, lengthrem)
UndoPointsUpdatemp(X, coeff, nbrs, newnbrs, index, remove, r, N, pointsin, gamweights, lengths, lengthrem)
X |
the vector of grid values. |
coeff |
the vector of detail and scaling coefficients at that step of the transform. |
nbrs |
the indices (into X) of the neighbours to be used in the lifting step. |
newnbrs |
as nbrs, but repeated according to the multiple point structure of the grid. |
index |
the indices into pointsin of nbrs, the neighbours of remove, the point to be added. |
remove |
the index (into X) of the point to be added. |
r |
the index into pointsin of the added point, remove. |
N |
length(pointsin). |
pointsin |
The indices of gridpoints still to be added. |
gamweights |
the prediction weights obtained from the regression in the prediction step of the transform. |
lengths |
the vector of interval lengths at the present step of the transform. |
lengthrem |
the interval length associated to the point to be added. |
This procedure uses minimum norm update coefficients to invert the update step of the transform. The prediction weights are used to change the interval lengthsm before the update weights are used to modify coefflist.
coeff |
vector of (modified) detail and scaling coefficients to be used later in the transform. |
lengths |
vector of interval lengths after inverting the update step of the transform. |
alpha |
the weights used to modify lengths and coeff. |
Matt Nunes ([email protected]), Marina Knight
AdaptNeighmp
, AdaptPredmp
, CubicPredmp
, invtnpmp
, LinearPredmp
, PointsUpdatemp
, QuadPredmp
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } I<-intervals(X,"reflect") lengths<-lengthintervals(X,I,neighbours=2,closest=TRUE) #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs p<-AdaptNeighmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g) nbrs<-p$newinfo[[3]] newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } coefflist[[31]]<-p$results[[6]][31] u<-PointsUpdatemp(X,coefflist,p$newinfo[[2]],newnbrs,p$newinfo[[3]],31,order(X),p$results[[4]], lengths) p2<-setdiff(order(X),31) a<-which(order(X)==31) l2<-lengths[setdiff(1:length(X), a)] # #remove the lifted coefficient # #now undo the update step... # undo<-UndoPointsUpdatemp(X,coeff,newnbrs,p$newinfo[[2]],p$newinfo[[3]],31, a,length(X)-1,p2,p$results[[4]],l2,lengths[a]) #
#read in data with multiple values... data(motorcycledata) times<-motorcycledata$time accel<-motorcycledata$accel short<-adjustx(times,accel,"mean") X<-short$sepx coeff<-short$sepx g<-short$g coefflist<-list() for (i in 1:length(g)){ coefflist[[i]]<-accel[g[[i]]] } I<-intervals(X,"reflect") lengths<-lengthintervals(X,I,neighbours=2,closest=TRUE) #work out neighbours of point to be removed (31) out<-getnbrs(X,31,order(X),2,TRUE) nbrs<-out$n nbrs newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } #work out repeated neighbours using g... newnbrs p<-AdaptNeighmp(order(X),X,coefflist,coeff,nbrs,newnbrs,31,TRUE,2,"ave",g) nbrs<-p$newinfo[[3]] newnbrs<-NULL for (i in 1:length(nbrs)){ newnbrs<-c(newnbrs,rep(nbrs[i],times=length(g[[nbrs[i]]]))) } coefflist[[31]]<-p$results[[6]][31] u<-PointsUpdatemp(X,coefflist,p$newinfo[[2]],newnbrs,p$newinfo[[3]],31,order(X),p$results[[4]], lengths) p2<-setdiff(order(X),31) a<-which(order(X)==31) l2<-lengths[setdiff(1:length(X), a)] # #remove the lifted coefficient # #now undo the update step... # undo<-UndoPointsUpdatemp(X,coeff,newnbrs,p$newinfo[[2]],p$newinfo[[3]],31, a,length(X)-1,p2,p$results[[4]],l2,lengths[a]) #