29
The aws Package July 7, 2007 Version 1.3-3.1 Date 2007-06-28 Title Adaptive Weights Smoothing Author Joerg Polzehl <[email protected]> Maintainer Joerg Polzehl <[email protected]> Description The library contains R-functions to perform the adaptive weights smoothing (AWS) procedure described in Polzehl und Spokoiny (2000), Adaptive weights smoothing with applications to image restoration. Journal of the Royal Statistical Society, Ser. B, 62, 2, 335–354 and its generalizations to local polynomial models as described in Polzehl und Spokoiny (2003), Varying coefficient regression modeling by adaptive weights smoothing, WIAS-Preprint 818 and to local likelihood models as described in Polzehl und Spokoiny (2002). Local likelihood modelling by adaptive weights smoothing, WIAS-Preprint 787. The functions awsuni, awsbi and awstri are superseded by functions aws and laws and will be removed in later versions. License GPL version 2 or newer This library is Copyright (C) 2002-2007 Weierstrass Institute for Applied Analysis and Stochastics. URL http://wias-berlin.de/project-areas/stat/projects/adaptive-image-processing.html R topics documented: aws ............................................. 2 awsbi ............................................ 8 awsdens ........................................... 10 awsh ............................................. 13 awstindex .......................................... 17 awstri ............................................ 19 awsuni ............................................ 20 getnubi ........................................... 22 getnutri ........................................... 23 laws ............................................. 24 Index 29 1

The aws Package - btr0x2.rz.uni-bayreuth.debtr0x2.rz.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/aws.pdfx x is either NULL, in this case y is assumed to be observed on a grid,

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

The aws PackageJuly 7, 2007

Version 1.3-3.1

Date 2007-06-28

Title Adaptive Weights Smoothing

Author Joerg Polzehl <[email protected]>

Maintainer Joerg Polzehl <[email protected]>

Description The library contains R-functions to perform the adaptive weights smoothing (AWS)procedure described in Polzehl und Spokoiny (2000), Adaptive weights smoothing withapplications to image restoration. Journal of the Royal Statistical Society, Ser. B, 62, 2, 335–354and its generalizations to local polynomial models as described in Polzehl und Spokoiny (2003),Varying coefficient regression modeling by adaptive weights smoothing, WIAS-Preprint 818 andto local likelihood models as described in Polzehl und Spokoiny (2002). Local likelihoodmodelling by adaptive weights smoothing, WIAS-Preprint 787. The functions awsuni, awsbi andawstri are superseded by functions aws and laws and will be removed in later versions.

License GPL version 2 or newer This library is Copyright (C) 2002-2007 Weierstrass Institute forApplied Analysis and Stochastics.

URL http://wias-berlin.de/project-areas/stat/projects/adaptive-image-processing.html

R topics documented:aws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2awsbi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8awsdens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10awsh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13awstindex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17awstri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19awsuni . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20getnubi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22getnutri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Index 29

1

2 aws

aws Local polynomial Adaptive Weights Smoothing for regression with ad-ditive errors

Description

This function implements a local polynomial Adaptive Weights Smoothing procedure for regressionproblems with additive errors as described in Polzehl & Spokoiny (2003). This function superseedesfunctions awsuni, awsbi and awstri.

Usage

aws(y, x = NULL, p = 0, sigma2 = NULL, qlambda = NULL, eta = 0.5,tau = NULL, lkern = "Triangle", hinit = NULL, hincr = NULL,hmax = 10, NN = FALSE, u = NULL, graph = FALSE, demo = FALSE,symmetric = NULL, wghts= NULL)

Arguments

y y contains the observed values (regression function plus errors). In case ofx=NULL (second parameter) y is assumed to be observed on a one, two orthree-dimensional grid. The dimension of y determines if one, two or three-dimensional AWS is used.

x x is either NULL, in this case y is assumed to be observed on a grid, or isa matrix, with rows corresponding to variables, containing the design pointswhere y is observed.

p p is the degree of the polynomial model to use. For univariate regression p canbe an nonnegative integer less or equal than 5, for bivariate regression on a gridp can be either 0, 1 or 2, for three dimensional AWS only p=0 is implemented.

sigma2 sigma2 can be used to provide an estimate for the error variance. If is.null(sigma2)a variance estimate is generated from the data.

qlambda qlambda determines the scale parameter qlambda for the stochastic penalty.The scaling parameter in the stochastic penalty lambda is choosen as the qlambda-quantile of a Chi-square-distribution with number of parameters in the polyno-mial model as degrees of freedom. If is.null(qlambda) a standard valuedepending on p is choosen.

eta eta is a memory parameter used to stabilize the procedure. eta has to bebetween 0 and 1, with eta=.5 being the default.

tau tau is used in case of a the scale parameter polynomial degree p!=0 only. It isthe scale parameter in the extention penalty used to prevent from leverage prob-lems. The default value for tau depends on p and on the number of parametersin the local model.

lkern lkern determines the location kernel to be used. Options are "Uniform","Triangle", "Quadratic", "Cubic" and "Exponential". Default is"Triangle". The Kernel operates on the squared distance, so "Triangle"

aws 3

corresponds to the use of an Epanechnikov kernel in kernel smoothing. "Exponential"requires larger values of hmax and therefore more iterations to reach compara-ble results.

hinit hinit Initial bandwidth for the location penalty. Appropriate value is choosenin case of hinit=NULL

hincr hincr hincr^(1/d), with d the dimensionality of the design, is used as afactor to increase the bandwidth between iterations. Defauts to hincr=1.25

hmax hmax Maximal bandwidth to be used. Determines the number of iterations andis used as the stopping rule.

NN If NN=TRUE use nearest neighbor-rules instead of distances in the location term.

u u used to supply values of the true regression function for test purposes to cal-culate Mean Squared Error (MSE) and Mean Absolute Error (MAE)

graph graph if TRUE results are displayed after each iteration step.

demo demo if TRUE after each iteration step results are displayed and the processwaits for user interaction.

symmetric If symmetric==TRUE the stochastic penalty is symmetrized, i.e. (sij +sji)/lambda is used instead of sij/lambda. See references for details.symmetric==FALSE is forced if p!=0

wghts Specifies wghts for distance evaluation on a bi- or trivariate grid. Allows foranisotropic local neighborhoods. If wghts=NULL isotropic neighborhoods areused.

Details

This function implements an adaptive weights smoothing (AWS) procedure for local polynomialmodels with additive errors. The approach generalizes the original AWS procedure from Polzehland Spokoiny (2000).

Adaptive weights smoothing is an iterative data adaptive smoothing technique that is designed forsmoothing in regression problems with discontinuous regression function. The basic assumptionis that the regression function can be approximated by a simple local, e.g. local constant or localpolynomial, model. The estimate of the regression function, i.e. the conditional expectation ofy given x is computed as a weighted maximum likelihood estimate, with weights choosen in acompletely data adaptive way. The procedure is edge preserving. If the assumed local model isglobally valid, almost all weights used will be 1, i.e. the resulting estimate almost is the globalestimate.

Currently implemented are the following models (specified by parameter p and attributes of x andy) are implemented:

p=0, x=NULL local constant univariate, bivariate or three-variate AWS on a grid specified by thedimensionality of y. Measurement unit for hinit and hmax is 1 (number grid points withindistance h)

p=0, !is.null(x) local constant AWS for arbitrary design given in x. If x is a matrix, then the rowscorrespond to components (variables). If NN==TRUE distances in the location penalty arereplaced by nearest- neighbor-rules.

4 aws

p=1 or 2, x=NULL local linear univariate and bivariate AWS on a grid grid specified by the di-mensionality of y. Measurement unit for hinit and hmax is 1 (number grid points withindistance h)

p=1, !is.null(x) local linear AWS for arbitrary design given in x. If x is a matrix, then the rowscorrespond to components (variables). If NN==TRUE distances in the location penalty arereplaced by nearest- neighbor-rules.

p>2, univariate univariate local polynomial AWS for arbitrary univariate design given in x. y hasto be a vector. If x is provided it has to be a vector of the same length as y. If is.null(x)an equidistant design (grid) with grid-step 1 is assumed.

The essential parameter in the procedure is qlambda. This parameter has an interpretation as asignificance level of a test for equivalence of two local parameter estimates. Optimal values mainlydepend on the choosen p and the value of symmetric (determines the use of an asymmetric or asymmetrized test). The optimal values only slightly depend on the model parameters, i.e. the defaultparameters should work in most situations. Larger values of qlambda may lead to oversmoothing,small values of qlambda lead to a random segmentation of homogeneous regions. A good valueof qlambda can be obtained by the propagation condition, requiring that in case of global validityof the local model the estimate for large hmax should be equal to the global estimate.

The numerical complexity of the procedure is mainly determined by hmax. The number of itera-tions is d*log(hmax/hinit)/log(hincr) with d being the dimension of y. Comlexity ineach iteration step is Const*hakt*n with hakt being the actual bandwith in the iteration stepand n the number of design points. hmax determines the maximal possible variance reduction.

Value

theta Parameter estimates, first dimension corresponds to parameter components

y values provided in y

x values provided in x

call actual function call

Note

This function supersedes functions awsuni, awsbi, and awstri

Author(s)

Joerg Polzehl, 〈[email protected]〉, http://www.wias-berlin.de/project-areas/stat/projects/adaptive-image-processing.html

References

Polzehl, J. and Spokoiny, V. (2003). Varying coefficient regression modeling by adaptive weightssmoothing, WIAS-Preprint 818.

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp.335-354

aws 5

See Also

SEE ALSO laws, awsuni, awsbi, awstri

Examples

######################################################### univariate examples########################################################## Blocks data (Example 6 from Fan & Gijbels (1996)#

mofx6 <- function(x){xj <- c(10,13,15,23,25,40,44,65,76,78,81)/100hj <- c(40,-50,30,-40,50,-42,21,43,-31,21,-42)*.37Kern <- function(x) (1-sign(x))/2apply(Kern(outer(xj,x,"-"))*hj,2,sum)}

## sigma==1 step by step with graphics#

fx6 <- mofx6(seq(0,1,1/2047))y <- rnorm(fx6,fx6,1)tmp <- aws(y,p=0,hmax=100,graph=TRUE)par(mfrow=c(1,1),mar=c(3,3,2.5,.5),mgp=c(2,1,0))plot(seq(0,1,1/2047),y)lines(seq(0,1,1/2047),tmp$theta,col=3,lwd=2)lines(seq(0,1,1/2047),fx6,col=2)

## sigma==3 without graphics (much faster)#

y <- rnorm(fx6,fx6,3)tmp <- aws(y,hmax=500)par(mfrow=c(1,1),mar=c(3,3,2.5,.5),mgp=c(2,1,0))plot(seq(0,1,1/2047),y)lines(seq(0,1,1/2047),tmp$theta,col=3,lwd=2)lines(seq(0,1,1/2047),fx6,col=2)rm(mofx6,fx6,y,tmp)

## second example from Polzehl and Spokoiny (2002)#

f2 <- function(x) sin(2*pi*1.2/(x+.2))n <- 1000x <- seq(0,1,length=n)fx2 <- f2(x)set.seed(1)sigma <- .25y <- rnorm(x,fx2,sigma)

# increase hmax to 2 for good resultsex1p0 <- aws(y,x,p=0,hmax=.1)$theta[1,]ex1p1 <- aws(y,x,p=1,hmax=.1)$theta[1,]

6 aws

ex1p2 <- aws(y,x,p=2,hmax=.1)$theta[1,]ex1p3 <- aws(y,x,p=3,hmax=.1)$theta[1,]par(mfrow=c(2,2),mar=c(2.5,2.5,2.5,.5),mgp=c(1.5,.5,0))plot(x,y)lines(x,fx2,col=2)lines(x,ex1p0,col=3,lwd=2)title("local constant AWS")plot(x,y)lines(x,fx2,col=2)lines(x,ex1p1,col=3,lwd=2)title("local linear AWS")plot(x,y)lines(x,fx2,col=2)lines(x,ex1p2,col=3,lwd=2)title("local quadratic AWS")plot(x,y)lines(x,fx2,col=2)title("local cubic AWS")lines(x,ex1p3,col=3,lwd=2)rm(f2,fx2,x,sigma,y,ex1p0,ex1p1,ex1p2,ex1p3)

######################################################### bivariate examples########################################################## Local constant image from Polzehl and Spokoiny (2000)#

xy <- rbind(rep(0:255,256),rep(0:255,rep(256,256)))indw <- c(1:12,29:48,73:100,133:168,209:256)w0 <- matrix(rep(FALSE,256*256),ncol=256)w0[indw,] <- TRUEw0[,indw] <- !w0[,indw]w0 <- w0-.5

w0[((xy[1,]-129)^2+(xy[2,]-129)^2)<=10000&((xy[1,]-129)^2+(xy[2,]-129)^2)>=4900] <- 0w0[abs(xy[1,]-xy[2,])<=20&((xy[1,]-129)^2+(xy[2,]-129)^2)<4900] <- 0w0[((xy[1,]-225)^2+2*(xy[2,]-30)^2)-(xy[1,]-225)*(xy[2,]-30)<=625] <- 0

w0[((xy[1,]-225)^2+2*(xy[2,]-30)^2)-(xy[1,]-225)*(xy[2,]-30)<=625&xy[2,]>27&xy[2,]<31] <- -.5

w0[((xy[1,]-225)^2+2*(xy[2,]-30)^2)-(xy[1,]-225)*(xy[2,]-30)<=625&xy[1,]>223&xy[1,]<227] <- .5w0[((xy[2,]-225)^2+2*(xy[1,]-30)^2)+(xy[2,]-225)*(xy[1,]-30)<=625] <- 0

w0[((xy[2,]-225)^2+2*(xy[1,]-30)^2)+(xy[2,]-225)*(xy[1,]-30)<=625&xy[1,]>27&xy[1,]<31] <- -.5

w0[((xy[2,]-225)^2+2*(xy[1,]-30)^2)+(xy[2,]-225)*(xy[1,]-30)<=625&xy[2,]>223&xy[2,]<227] <- .5w0[((xy[2,]-225)^2+(xy[1,]-225)^2)+1*(xy[2,]-225)*(xy[1,]-225)<=400] <- 0w0[((xy[2,]-30)^2+(xy[1,]-30)^2)<=256] <- 0rm(xy,indw)set.seed(1)sigma <- .5y <- w0+rnorm(w0,0,sigma)

aws 7

# run some steps interactively (increase hmax)tmp <- aws(y,graph=TRUE,hmax=2,demo=TRUE)

# now without graphics and larger hmax# increase hmax for better results

tmp <- aws(y,hmax=5)par(mfrow=c(1,3))image(y,col=gray((0:255)/255))image(tmp$theta,zlim=range(y),col=gray((0:255)/255))image(w0,zlim=range(y),col=gray((0:255)/255))rm(y,w0,tmp,sigma)

## piecewise smooth image from Polzehl and Spokoiny (2003)#

x <- (0:99)/99fbi <- function(x,y) (x^2+y^3)*sign(x^2-1*x*y-.75*y^3)z0 <- outer(2*(x-.5),2*(x-.25),FUN=fbi)z <- z0+rnorm(z0,0,.5)par(mfrow=c(1,3),mar=c(3,3,3,.5),mgp=c(2,1,0))set.seed(1)persp(x,x,z0,phi=15,theta=150,d=5,r=2,expand=1.5,col="white")title("True function")persp(x,x,z,phi=15,theta=150,d=5,r=2,expand=1.5,col="white")title("Observed values")image(x,x,z,col=gray((0:255)/255))title("Observed values")

## local constant#

ex1p0 <- aws(z,hmax=3,symmetric=FALSE)$theta # use hmax=5 or larger## local linear#

ex1p1 <- aws(z,p=1,hmax=3)$theta[1,,] # use hmax=12 or larger## local quadratic#

ex1p2 <- aws(z,p=2,hmax=3)$theta[1,,] # use hmax=20 or larger## display results#

par(mfrow=c(2,2),mar=c(0.25,.5,.5,.5),mgp=c(.5,.5,0))persp(x,x,z,phi=15,theta=150,d=5,r=2,expand=1,xlab="",ylab="",zlab="",box=FALSE)title("original data",line=-3)persp(x,x,ex1p0,phi=15,theta=150,d=5,r=2,expand=1,xlab="",ylab="",zlab="",box=FALSE)title("local constant AWS",line=-3)persp(x,x,ex1p1,phi=15,theta=150,d=5,r=2,expand=1,xlab="",ylab="",zlab="",box=FALSE)title("local linear AWS (small hmax)",line=-3)persp(x,x,ex1p2,phi=15,theta=150,d=5,r=2,expand=1,xlab="",ylab="",zlab="",box=FALSE)title("local quadratic AWS (small hmax)",line=-3)rm(x,fbi,z0,ex1p0,ex1p1,ex1p2)

########################################################

8 awsbi

# three-variate examples########################################################## Local constant image from Polzehl and Spokoiny (2000)#

xy <- rbind(rep(0:30,31),rep(0:30,rep(31,31)))w3 <- array(0,c(31,31,31))w3[4:28,4:28,4:28] <- 1dim(w3) <- c(961,31)w3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=144,16] <- 0for(i in 1:12) {

r2 <- 144-i*iw3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=r2,16+c(-i,i)] <- 0

}dim(w3) <- c(31,31,31)w3[10:22,10:22,10:22] <- 1dim(w3) <- c(961,31)w3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=36,16] <- 0for(i in 1:6) {

r2 <- 36-i*iw3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=r2,16+c(-i,i)] <- 0

}dim(w3) <- c(31,31,31)rm(xy)sigma <- .5set.seed(1)y <- w3+rnorm(w3,0,sigma)

# increase hmax for reasonable results (hmax >=5)tmp <- aws(y,hmax=2)par(mfrow=c(1,3))for(i in 14:18){image(y[,,i],col=gray((0:255)/255))image(tmp$theta[,,i],zlim=range(y),col=gray((0:255)/255))image(w3[,,i],zlim=range(y),col=gray((0:255)/255))

# readline()}rm(w3,y,tmp,sigma)

awsbi Two-dimensional Adaptive Weights Smoothing

Description

Performes two dimensional Adaptive Weigths Smoothing (depreciated version, use aws instead)

Usage

awsbi(y, lambda=3, gamma=1.3, eta =4, s2hat = NULL, kstar = length(radii),rmax=max(radii), radii = c((1:8)/2,4.4,5.,(6:10),(6:10)*2),

awsbi 9

graph = FALSE, u0 = NULL, control="dyadic", demomode=FALSE,colors=gray((0:255)/255))

Arguments

y matrix of observed values

lambda main smoothing parameter (should be approximately 3)

gamma allow for increase of variances during iteration by factor gamma (!! gamma>=1)

eta main control parameter (should be approximately 4)

s2hat initial variance estimate (if available, can be either a number (homogeneouscase), a matrix of same dimension as y (inhomogeneous variance) or NULL (ahomogeneous variance estimate will be generated in this case)

kstar maximal number of iterations to perform, actual number may be smaller de-pending on parameters radii and rmax

radii radii of circular neighbourhoods used

rmax maximal radius of neighborhood to be used, may change kstar

graph logical, if TRUE progress (for each iteration) is illustrated grahically, if FALSEthe program runs until the final estimate is obtained (much faster !!!)

u0 allows for submission of "true" values for illustration and test purposes; only ifgraph=TRUE, MSE and MAE are reported for each iteration step

control the control step is performed in either a dyadic sceme ("dyadic") or using allprevious estimates (otherwise)

demomode if TRUE the function will wait for user input after each iteration; only if graph=TRUE

colors color sceme to be used for images

Value

A list with components

yhat estimates of the regression function (matrix corresponding to the y’s)

shat estimated standard deviations of yhat (conditional on the chosen weights)

nu maximal number of design points in neighborhood used

args main arguments supplied to awsbi

Note

The function assumes that the data are given on a 2D-grid corresponding to the dimensionality of y.This function is superseded by function aws and will be removed in the next mayor version of thepackage.

Author(s)

Joerg Polzehl 〈[email protected]

10 awsdens

References

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp. 335-354

See Also

aws, awsuni,awstri

Examples

xy<-rbind(rep(0:255,256),rep(0:255,rep(256,256)))indw<-c(1:12,29:48,73:100,133:168,209:256)w0<-matrix(rep(0,256*256),ncol=256)w0[indw,]<-1w0[,indw]<-!w0[,indw]w0<-w0-.5w0[((xy[1,]-129)^2+(xy[2,]-129)^2)<=10000&((xy[1,]-129)^2+(xy[2,]-129)^2)>=4900]<- 0w0[abs(xy[1,]-xy[2,])<=20&((xy[1,]-129)^2+(xy[2,]-129)^2)<4900]<- 0w0[((xy[1,]-225)^2+2*(xy[2,]-30)^2)-(xy[1,]-225)*(xy[2,]-30)<=625]<- 0w0[((xy[1,]-225)^2+2*(xy[2,]-30)^2)-(xy[1,]-225)*(xy[2,]-30)<=625&xy[2,]>27&xy[2,]<31]<- -.5w0[((xy[1,]-225)^2+2*(xy[2,]-30)^2)-(xy[1,]-225)*(xy[2,]-30)<=625&xy[1,]>223&xy[1,]<227]<- .5w0[((xy[2,]-225)^2+2*(xy[1,]-30)^2)+(xy[2,]-225)*(xy[1,]-30)<=625]<- 0w0[((xy[2,]-225)^2+2*(xy[1,]-30)^2)+(xy[2,]-225)*(xy[1,]-30)<=625&xy[1,]>27&xy[1,]<31]<- -.5w0[((xy[2,]-225)^2+2*(xy[1,]-30)^2)+(xy[2,]-225)*(xy[1,]-30)<=625&xy[2,]>223&xy[2,]<227]<- .5w0[((xy[2,]-225)^2+(xy[1,]-225)^2)+1*(xy[2,]-225)*(xy[1,]-225)<=400]<- 0w0[((xy[2,]-30)^2+(xy[1,]-30)^2)<=256]<-0sigma<-.25y<-w0+rnorm(w0,0,sigma)# increase rmax for better resultsyhat<-awsbi(y,rmax=3)par(mfrow=c(1,3))image(y,col=gray((0:255)/255))title("Noisy image")image(yhat$yhat,zlim=range(y),col=gray((0:255)/255))title("AWS reconstruction")image(w0,zlim=range(y),col=gray((0:255)/255))title("Original image")rm(y,w0,yhat,xy)

awsdens local constant density estimation

Description

This function uses adaptive weights smoothing for density estimation. The estimate is constructedusing poisson regression and the structural assumption of a local constant density. Implementationis for 1D, 2D and 3D problems, although it applications may be interesting only in 2D and 3D.

awsdens 11

Usage

awsdens(y, ngrid = NULL, nempty = NULL, qlambda = NULL, eta = 0.5,lkern = "Triangle", fu = NULL, hinit = 1, hincr = 1.2,

hmax = NULL, graph = FALSE, demo = FALSE, symmetric = TRUE)

Arguments

y y contains the observed random variables or vectors. In case of random vectorsy is supposed to be an observation matrix with columns containing the observedvectors

ngrid ngrid determines the size of the grid used for binning. If ngrid is a vectorits components are supposed to determine the number of intervals for the corre-sponding component of y; if it is a scalar rep(ngrid,dim(y)[1]) is used.If is.null(ngrid) a default of 2*n^{1/d}, with dim(y)=c(d,n), ischosen, i.e. a grid with 2^d*n bins.

nempty determines the width of a boundary region of the grid containing only emptybins. nempty defaults to 0.1*ngrid. The grid generated is equispaced withprod(ngrid) bins and grid-coordinates (nempty+1)[i] and (ngrid+1-nempty)[i] determined by min(y[i,]) and max(y[i,]).

qlambda qlambda determines the scale parameter qlambda for the stochastic penalty.The scaling parameter in the stochastic penalty lambda is choosen as the qlambda-quantile of a Chi-square-distribution with number of parameters in the polyno-mial model as degrees of freedom. If qlambda=NULL a standard value de-pending on model and symmetric is choosen.

eta eta is a memory parameter used to stabilize the procedure. eta has to bebetween 0 and 1, with eta=.5 being the default.

lkern lkern determines the location kernel to be used. Options are "Uniform","Triangle", "Quadratic", "Cubic" and "Exponential". Default is"Triangle". The Kernel operates on the squared distance, so "Triangle"corresponds to the use of an Epanechnikov kernel in kernel smoothing. "Exponential"requires larger values of hmax and therefore more iterations to reach compara-ble results.

fu fu can be used to specify a function to calculate the values of the true densityon the grid. This may be used for test purposes to calculate Mean Squared Error(MSE) and Mean Absolute Error (MAE)

hinit hinit Initial bandwidth for the location penalty. Appropriate value is choosenin case of hinit==NULL

hincr hincr hincr^(1/d), with d the dimensionality of the design, is used as afactor to increase the bandwidth between iterations. Defauts to hincr=1.2

hmax hmax Maximal bandwidth to be used. Determines the number of iterations andis used as the stopping rule.

graph graph if TRUE results are displayed after each iteration step.demo demo if TRUE after each iteration step results are displayed and the process

waits for user interaction.symmetric If symmetric==TRUE the stochastic penalty is symmetrized, i.e. (sij +

sji)/lambda is used instead of sij/lambda. See references for details.

12 awsdens

Details

The density estimate ist constructed using an approach proposed by Lindsay (1974a,b). 1, 2 or3-dimensional binning is used to produce counts, i.e. numbers of observations, per bin, with binsdefined by a regular grid. THe bin-counts are then considered as poisson random variables withintensity depending on the location within the grid. Adaptive Weights Smoothing for poisson re-gression models, i.e. function laws with parameter model="Poisson", is used to construct alocation dependent intensity estimate which is then transformed into a density estimate, see Section6 in Polzehl and Spokoiny (2002b) for details.

Value

The returned object is a list with components

bin Bin counts

dens density values for the bin. Values correspond to the grid-centers determined bycomponent xgrid

xgrid list with components containing the coordinates of bin-centers. The dim(y)[1]components of xgrid correspond to the components of the grid-coordinates.

call actual function call

Author(s)

Joerg Polzehl, 〈[email protected]

References

Polzehl, J. and Spokoiny, V. (2002). Local likelihood modelling by adaptive weights smoothing,WIAS-Preprint 787

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp.335-354

Lindsay, J. (1974a). Comparison of probabbility distributions, J. Royal Statist. Soc. Ser. B 36,38-47.

Lindsay, J. (1974b). Construction and comparison of statistical models, J. Royal Statist. Soc. Ser.B 36, 418-425.

See Also

SEE ALSO aws, laws

awsh 13

Examples

###### univariate density estimation###f0 <- function(x) 1.5*(x>=0)-(x>=.25)+(x>=.75)-1.5*(x>1)set.seed(1)m <- 1000x1 <- runif(m)ind <- (runif(m)<f0(x1)/1.5)n <- 200y <- x1[ind][1:n]tmp0 <- awsdens(y,440,20,hmax=2000)plot(tmp0$xgrid[[1]],tmp0$dens,type="l",lwd=2,

ylim =range(0,1.5,tmp0$dens),xlab="x",ylab="Density")lines(tmp0$xgrid[[1]],f0(tmp0$xgrid[[1]]),lty=3,col=2,lwd=2)title("Estimated and true density (n=200)")###### bivariate density estimation###f1 <- function(x,y) 7.5*pmax(x*(1-x^2-y^2),0)*(x>0)*(y>0)set.seed(1)m <- 10000x1 <- runif(m)x2 <- runif(m)fx12 <- f1(x1,x2)ind <- (runif(m)<f1(x1,x2)/.385/7.5)n <- 2500y <- rbind(x1[ind],x2[ind])[,1:n]tmp <- awsdens(y,120,10,hmax=5)image(tmp$xgrid[[1]],tmp$xgrid[[2]],tmp$dens,xlab="x1",ylab="x2",col=gray(.5+(255:0)/511),lwd=2)# thats the estimated density on the gridlines(seq(0,1,.01),sqrt(1-seq(0,1,.01)^2),col=2,lty=2,lwd=2)lines(c(0,1),c(0,0),col=2,lty=2,lwd=2)lines(c(0,0),c(0,1),col=2,lty=2,lwd=2)# thats the boundary of the supporttitle("Estimated density (n=2500)")# now add contour lines of the estimated densitycontour(tmp$xgrid[[1]],tmp$xgrid[[2]],tmp$dens,nlevels=20,add=TRUE,col=1,lty=1,labcex=.1)rm(f0,m,x1,ind,n,y,tmp0,f1,x2,fx12,tmp)

awsh Univariate local polynomial Adaptive Weights Smoothing for regres-sion with heteroscedastic additive errors

Description

This function implements a univariate local polynomial Adaptive Weights Smoothing procedurefor regression problems with heteroskedastic additive errors as described in Polzehl & Spokoiny(2003).

14 awsh

Usage

awsh(y, x = NULL, p = 0, sigma2 = NULL, qlambda = NULL, eta = 0.5, tau = NULL,lkern = "Triangle", hinit = NULL, hincr = NULL, hmax = 100, hmaxs= 2*hmax, u = NULL,graph = FALSE, demo = FALSE, symmetric = NULL, conf = FALSE, qconf = 0.95, alpha = 2)

Arguments

y y contains the observed values (regression function plus errors). In case ofx=NULL (second parameter) y is assumed to be observed on a one-dimensionalgrid.

x x is either NULL, in this case y is assumed to be observed on a grid, or is avector determining the design.

p p is the degree of the polynomial model to use. For univariate regression p canbe an nonnegative integer less or equal than 5.

sigma2 sigma2 can be used to provide an estimate for the error variance. If is.null(sigma2)a homoskedastic model is assumed and a variance estimate is generated from thedata. If length(sigma2)==length(y) this parameter provides variancesat the design points.

qlambda qlambda determines the scale parameter qlambda for the stochastic penalty.The scaling parameter in the stochastic penalty lambda is choosen as the qlambda-quantile of a Chi-square-distribution with number of parameters in the polyno-mial model as degrees of freedom. If is.null(qlambda) a standard valuedepending on p is choosen.

eta eta is a memory parameter used to stabilize the procedure. eta has to bebetween 0 and 1, with eta=.5 being the default.

tau tau is used in case of a the scale parameter polynomial degree p!=0 only. It isthe scale parameter in the extention penalty used to prevent from leverage prob-lems. The default value for tau depends on p and on the number of parametersin the local model.

lkern lkern determines the location kernel to be used. Options are "Uniform","Triangle", "Quadratic", "Cubic" and "Exponential". Default is"Triangle". The Kernel operates on the squared distance, so "Triangle"corresponds to the use of an Epanechnikov kernel in kernel smoothing. "Exponential"requires larger values of hmax and therefore more iterations to reach compara-ble results.

hinit hinit Initial bandwidth for the location penalty. Appropriate value is choosenin case of hinit=NULL

hincr hincr hincr is used as a factor to increase the bandwidth between iterations.Defauts to hincr=1.25

hmax hmax Maximal bandwidth to be used. Determines the number of iterations andis used as the stopping rule.

hmaxs hmaxs Maximal bandwidth to be used when estimating the heterogenous vari-ance from consequtive differences of y by function laws. Determines the num-ber of iterations of laws.

awsh 15

u u used to supply values of the true regression function for test purposes to cal-culate Mean Squared Error (MSE) and Mean Absolute Error (MAE)

graph graph if TRUE results are displayed after each iteration step.

demo demo if TRUE after each iteration step results are displayed and the processwaits for user interaction.

symmetric If symmetric==TRUE the stochastic penalty is symmetrized, i.e. (sij +sji)/lambda is used instead of sij/lambda. See references for details.symmetric==FALSE is forced if p!=0

conf conf if TRUE conditional (on weights) confidence intervals are provided ateach design point.

qconf qconf determines the level of the conditional (on weights) confidence intervals

alpha alpha Parameter used for a penalized MSE estimate for p=0. This is experi-mental to try to select hmax.

Details

This function implements an local polynomial adaptive weights smoothing (AWS) procedure for aunivariate heteroskedastic regression model. The approach generalizes the original AWS procedurefrom Polzehl and Spokoiny (2000).

Adaptive weights smoothing is an iterative data adaptive smoothing technique that is designed forsmoothing in regression problems with discontinuous regression function. The basic assumptionis that the regression function can be approximated by a simple local, e.g. local constant or localpolynomial, model. The estimate of the regression function, i.e. the conditional expectation ofy given x is computed as a weighted maximum likelihood estimate, with weights choosen in acompletely data adaptive way. The procedure is edge preserving. If the assumed local model isglobally valid, almost all weights used will be 1, i.e. the resulting estimate almost is the globalestimate.

Currently implemented are the following models (specified by parameter p and attributes of x andy) are implemented:

p=0, x=NULL local constant univariate AWS on a grid. Measurement unit for hinit and hmaxis 1 (number grid points within distance h)

p=0, !is.null(x) local constant AWS for arbitrary design given in x.

p>2 univariate local polynomial AWS for arbitrary univariate design given in x. y has to be avector. If x is provided it has to be a vector of the same length as y. If is.null(x) anequidistant design (grid) with grid-step 1 is assumed.

The essential parameter in the procedure is qlambda. This parameter has an interpretation as asignificance level of a test for equivalence of two local parameter estimates. Optimal values mainlydepend on the choosen p and the value of symmetric (determines the use of an asymmetric or asymmetrized test). The optimal values only slightly depend on the model parameters, i.e. the defaultparameters should work in most situations. Larger values of qlambda may lead to oversmoothing,small values of qlambda lead to a random segmentation of homogeneous regions. A good valueof qlambda can be obtained by the propagation condition, requiring that in case of global validityof the local model the estimate for large hmax should be equal to the global estimate.

16 awsh

The numerical complexity of the procedure is mainly determined by hmax. The number of itera-tions is d*log(hmax/hinit)/log(hincr) with d being the dimension of y. Comlexity ineach iteration step is Const*hakt*n with hakt being the actual bandwith in the iteration stepand n the number of design points. hmax determines the maximal possible variance reduction.

Value

theta Parameter estimates, first dimension corresponds to parameter components

theta Standard deviations (conditional on weights) of parameter estimates, first di-mension corresponds to parameter components

y values provided in y

x values provided in x

call actual function call

Author(s)

Joerg Polzehl, 〈[email protected]〉, http://www.wias-berlin.de/project-areas/stat/projects/adaptive-image-processing.html

References

Polzehl, J. and Spokoiny, V. (2003). Varying coefficient regression modeling by adaptive weightssmoothing, WIAS-Preprint 818.

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp.335-354

See Also

aws

Examples

##---- Should be DIRECTLY executable !! ----##-- ==> Define data, use random,##-- or do help(data=index) for the standard data sets.

awstindex 17

awstindex Tail index estimation

Description

The function finds a pareto-approximation of the tail of a univariate distribution and estimates theparameter in this pareto-approximation. The construction is similar to the Hill-estimator. Thenumber of largest observations used in the estimate is chosen adaptively.

Usage

awstindex(y, qlambda = NULL, eta = 0.5, lkern = "Triangle", hinit = 1,hincr = 1.25, hmax = 1000, graph = FALSE, symmetric = FALSE)

Arguments

y y contains the observed values at location x. In case of x=NULL (second pa-rameter) y is assumed to be observed on a one, two or three-dimensional grid.The dimension of y determines if one, two or three-dimensional AWS is used.

qlambda qlambda determines the scale parameter qlambda for the stochastic penalty.The scaling parameter in the stochastic penalty lambda is choosen as the qlambda-quantile of a Chi-square-distribution with number of parameters in the polyno-mial model as degrees of freedom. If qlambda=NULL a standard value de-pending on model and symmetric is choosen.

eta eta is a memory parameter used to stabilize the procedure. eta has to bebetween 0 and 1, with eta=.5 being the default.

lkern lkern determines the location kernel to be used. Options are "Uniform","Triangle", "Quadratic", "Cubic" and "Exponential". Default is"Triangle". The Kernel operates on the squared distance, so "Triangle"corresponds to the use of an Epanechnikov kernel in kernel smoothing. "Exponential"requires larger values of hmax and therefore more iterations to reach compara-ble results.

hinit hinit Initial bandwidth for the location penalty. Appropriate value is choosenin case of hinit==NULL

hincr hincr hincr^(1/d), with d the dimensionality of the design, is used as afactor to increase the bandwidth between iterations. Defauts to hincr=1.2

hmax hmax Maximal bandwidth to be used. Determines the number of iterations andis used as the stopping rule.

graph graph if TRUE results are displayed after each iteration step.

symmetric If symmetric==TRUE the stochastic penalty is symmetrized, i.e. (sij +sji)/lambda is used instead of sij/lambda. See references for details.

18 awstindex

Details

From the data y an descending order statistics yn <- order(y)[n:1] is computed and trans-formed observations x <- (1:(n-1))*yn[-n]/yn[-1] are defined. The transformed obser-vations are assumed to follow an inhomogenious exponential model. Adaptive Weights Smoothing,i.e. function laws with parameter model="Exponential", is used to construct an inhomoge-nious intensity estimate. The estimated tail index is the estimated intensity in the left-most point,corresponding to the largest observation in the sample. This estimate is similar to the Hill-estimatecomputed from the k largest observations with k approximately equal to the sum of weights usedfor estimating the tail index by AWS. See Section 8 in Polzehl and Spokoiny (2002) for details.

Value

The returned object is a list with components

tindex Estimated tail-index

intensity Estimates of the intensity in the exponential model

y Values of y

call actual function call

Author(s)

Joerg Polzehl, 〈[email protected]

References

Polzehl, J. and Spokoiny, V. (2002). Local likelihood modelling by adaptive weights smoothing,WIAS-Preprint 787

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp.335-354

See Also

SEE ALSO aws, laws

Examples

###### Estimate the tail-index of a cauchy distribution### absolute values can be used because of the symmetry of centered cauchy###set.seed(1)n <- 500x <- rcauchy(n)tmp <- awstindex(abs(x),hmax=n)tmp$tindex###### now show the segmentation generated by AWS

awstri 19

###plot(tmp$intensity[1:250],type="l")

awstri Three-dimensional Adaptive Weights Smoothing

Description

Performes three-dimensional Adaptive Weigths Smoothing (depreciated version, use aws instead)

Usage

awstri(y, lambda=3, gamma=1.3, eta =4, s2hat = NULL, kstar = length(radii),rmax=max(radii), weight = c(1,1,1), radii = c((1:4)/2,2.3,(5:12)/2,7:9,10.5,12,13.5), control="dyadic")

Arguments

y array of observed values

lambda main smoothing parameter (should be approximately 3)

gamma allow for increase of variances during iteration by factor gamma (!!gamma>=1)

eta main control parameter (should be approximately 4)

s2hat initial variance estimate (if available, can be either a number (homogeneouscase), a matrix of same dimension as y (inhomogeneous variance) or NULL (ahomogeneous variance estimate will be generated in this case)

kstar maximal number of iterations to perform, actual number may be smaller de-pending on parameters radii and rmax

weight weights used for distances, determining elliptical neighborhoods

radii radii of circular neighbourhoods used

rmax maximal radius of neighborhood to be used, may change kstar

control the control step is performed in either a dyadic sceme ("dyadic") or using allprevious estimates (otherwise)

Value

A list with components

yhat estimates of the regression function (matrix corresponding to the y’s)

shat estimated standard deviations of yhat (conditional on the chosen weights)

args Main arguments supplied to awstri

Note

The function assumes that the data are given on a 3D-grid corresponding to the dimensionality of y.This function is superseded by function aws and will be removed in the next mayor version of thepackage.

20 awsuni

Author(s)

Joerg Polzehl 〈[email protected]

References

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp.335-354

See Also

aws, awsbi,awsuni

Examples

xy <- rbind(rep(0:30,31),rep(0:30,rep(31,31)))w3 <- array(0,c(31,31,31))w3[4:28,4:28,4:28] <- 1dim(w3) <- c(961,31)w3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=144,16] <- 0for(i in 1:12) {

r2 <- 144-i*iw3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=r2,16+c(-i,i)] <- 0

}dim(w3) <- c(31,31,31)w3[10:22,10:22,10:22] <- 1dim(w3) <- c(961,31)w3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=36,16] <- 0for(i in 1:6) {

r2 <- 36-i*iw3[((xy[1,]-15)^2+(xy[2,]-15)^2)<=r2,16+c(-i,i)] <- 0

}dim(w3) <- c(31,31,31)sigma <- .4y <- w3+rnorm(w3,0,sigma)# increase rmax for better resultsyhat <- awstri(y,rmax=2)rm(y,yhat,w3,xy)

awsuni One-dimensional Adaptive Weights Smoothing

Description

Performes one-dimensional Adaptive Weigths Smoothing (depreciated version, use aws instead)

awsuni 21

Usage

awsuni(y, lambda=3, gamma=1.3, eta =4, s2hat = NULL, kstar = length(radii),radii = c(1:8,(5:12)*2,(7:12)*4,(7:12)*8,(7:10)*16,(6:8)*32,

(5:8)*64,(5:8)*128,(5:8)*256),rmax=max(radii),graph = FALSE,z0 = NULL, eps = 1e-08,control="dyadic", demomode=FALSE)

Arguments

y observed values (ordered by value of independent variable)

lambda main smoothing parameter (should be approximately 3)

gamma allow for increase of variances during iteration by factor gamma (!! gamma>=1)

eta main control parameter (should be approximately 4)

s2hat initial variance estimate (if available, can be either a number (homogeneouscase), a vector of same length as y (inhomogeneous variance) or NULL (a ho-mogeneous variance estimate will be generated in this case)

kstar maximal number of iterations to perform, actual number may be smaller de-pending on parameters radii, rmax and eps

radii radii of neighbourhoods used

rmax maximal radius of neighborhood to be used, may change kstar

graph logical, if TRUE progress (for each iteration) is illustrated grahically, if FALSEthe program runs until the final estimate is obtained (much faster !!!)

z0 allows for submission of "true" values for illustration and test purposes; only ifgraph=TRUE, MSE and MAE are reported for each iteration step

eps stop iteration if ||(yhatnew − yhat)||2 < eps ∗ sum(s2hat)

control the control step is performed in either a dyadic sceme ("dyadic") or using allprevious estimates (otherwise)

demomode if TRUE the function will wait for user input after each iteration; only if graph=TRUE

Value

A list with components

yhat estimates of the regression function (corresponding to the y’s)

shat estimated standard deviations of yhat (conditional on the chosen weights)

args Main arguments supplied to awsuni

Note

Although the algorithm evaluates a regression model the structure of the regression function onlydepends on the ordering of the independent variable. Therefore no independent variable is to begiven as a parameter but the values of the dependent variable are required to be ordered by the valueof the independent variable. This function is superseded by function aws and will be removed inthe next mayor version of the package.

22 getnubi

Author(s)

Joerg Polzehl 〈[email protected]

References

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp. 335-354

See Also

aws, awsbi, awstri

Examples

# Blocks data (from Donoho, Johnstone, Kerkyacharian and Picard (1995))mofx6 <- function(x){xj <- c(10,13,15,23,25,40,44,65,76,78,81)/100hj <- c(40,-50,30,-40,50,-42,21,43,-31,21,-42)*.37Kern <- function(x) (1-sign(x))/2apply(Kern(outer(xj,x,"-"))*hj,2,sum)}x <- seq(0,1,1/2047)fx6 <- mofx6(x)# sigma==3y <- rnorm(fx6,fx6,3)tmp <- awsuni(y)par(mfrow=c(1,1))plot(x,y)lines(x,tmp$yhat,col=2)lines(x,fx6,col=3)title(expression(paste("AWS Reconstruction of blocks data ",sigma==3)))rm(x,y,fx6,mofx6,tmp)

getnubi Calculate number of grid points in a bivariate elliptical neighborhood

Description

This function is for internal use only

Usage

getnubi(radiusq, weights)

Arguments

radiusq Square of radius

weights axis weights w

getnutri 23

Details

Value

Returns number of grid points (i,j) with w[1] i^2 + w[2] j^2 <= radiusq

Author(s)

Joerg Polzehl 〈[email protected]

See Also

awstri

Examples

getnutri Calculate number of grid points in a 3D ellipsoidal neighborhood

Description

This function is for internal use only

Usage

getnutri(radiusq, weights)

Arguments

radiusq Square of radius

weights axis weights

Details

Value

Returns number of grid points (i,j,k) with w[1] i^2 + w[2] j^2 + w[3] k^2 <= radiusq

Author(s)

Joerg Polzehl 〈[email protected]

24 laws

References

See Also

awstri

Examples

laws Likelihood based Adaptive Weights Smoothing

Description

This function implements a Adaptive Weights Smoothing procedure for local constant Poisson,Bernoulli, Exponential, Weibull, Volatility and Gaussian models as described in Polzehl & Spokoiny(2002).

Usage

laws(y, x = NULL, qlambda = NULL, eta = 0.5, lkern = "Triangle",model = "Poisson", shape = NULL, hinit = NULL, hincr = NULL,hmax = 10, NN = FALSE, u = NULL, graph = FALSE, demo = FALSE,symmetric = FALSE, wghts=NULL)

Arguments

y y contains the observed values at location x. In case of x==NULL (secondparameter) y is assumed to be observed on a one, two or three-dimensional grid.The dimension of y determines if one, two or three-dimensional AWS is used.

x x is either NULL, in this case y is assumed to be observed on a grid, or isa matrix, with rows corresponding to variables, containing the design pointswhere y is observed.

qlambda qlambda determines the scale parameter qlambda for the stochastic penalty.The scaling parameter in the stochastic penalty lambda is choosen as the qlambda-quantile of a Chi-square-distribution with number of parameters in the polyno-mial model as degrees of freedom. If qlambda==NULL a standard value de-pending on model and symmetric is choosen.

eta eta is a memory parameter used to stabilize the procedure. eta has to bebetween 0 and 1, with eta==0.5 being the default.

laws 25

lkern lkern determines the location kernel to be used. Options are "Uniform","Triangle", "Quadratic", "Cubic" and "Exponential". Default is"Triangle". The Kernel operates on the squared distance, so "Triangle"corresponds to the use of an Epanechnikov kernel in kernel smoothing. "Exponential"requires larger values of hmax and therefore more iterations to reach compara-ble results.

model model determines the distribution type of y. Currently implemented models are"Poisson", "Bernoulli", "Gaussian", "Exponential", "Weibull","Volatility" (Estimation of the scale parameter of a Gaussian distribution).Defaults to "Poisson".

shape used for additional parameters of the specified distribution if needed, i.e. vari-ance if model=="Gaussian"

hinit hinit Initial bandwidth for the location penalty. Appropriate value is choosenin case of hinit==NULL

hincr hincr hincr^(1/d), with d the dimensionality of the design, is used as afactor to increase the bandwidth between iterations. Defauts to hincr==1.2

hmax hmax Maximal bandwidth to be used. Determines the number of iterations andis used as the stopping rule.

NN If NN==TRUE use nearest neighbor-rules instead of distances in the locationterm.

u u used to supply values of the true regression function for test purposes to cal-culate Mean Squared Error (MSE) and Mean Absolute Error (MAE)

graph graph if TRUE results are displayed after each iteration step.

demo demo if TRUE after each iteration step results are displayed and the processwaits for user interaction.

symmetric If symmetric==TRUE the stochastic penalty is symmetrized, i.e. (sij +sji)/lambda is used instead of sij/lambda. See references for details.

wghts Specifies wghts for distance evaluation on a bi- or trivariate grid. Allows foranisotropic local neighborhoods. If wghts=NULL isotropic neighborhoods areused.

Details

This function implements an adaptive weights smoothing (AWS) procedure for a several classes ofdistributions for the dependent variable in local constant regression models. The approach general-izes the original AWS procedure from Polzehl and Spokoiny (2000).

Adaptive weights smoothing is an iterative data adaptive smoothing technique that is designed forsmoothing in regression problems with discontinuous regression function. The basic assumptionis that the regression function can be approximated by a simple local, e.g. local constant or localpolynomial, model. The estimate of the regression function, i.e. the conditional expectation ofy given x is computed as a weighted maximum likelihood estimate, with weights choosen in acompletely data adaptive way. The procedure is edge preserving. If the assumed local model isglobally valid, almost all weights used will be 1, i.e. the resulting estimate almost is the globalestimate.

Currently implemented are the following models (specified by parameter model):

26 laws

Binary response model="Bernoulli"

Poisson regression model="Poisson" This model allows e.g. for density estimation or for theanalysis of poisson count data on a grid (e.g. Positron emission tomography (PET)).

Exponential regression model="Exponential" Applications of this model include e.g. testfor constant (over time) failure rates and estimation of tail indicies.

Gaussian regression model="Gaussian" This essentially coincides with the local constant re-gression model with additive sub-gaussian errors as described in Polzehl and Spokoiny (2000,2003).

Weibull regression model="Weibull" Applications in reliability analysis.

Volatility model model="Volatility" .

The essential parameter in the procedure is qlambda. This parameter has an interpretation as asignificance level of a test for equivalence of two local parameter estimates. Optimal values mainlydepend on the choosen model and the value of symmetric (determines the use of an asymmetricor a symmetrized test). The optimal values only slightly depend on the model parameters, i.e.the default parameters should work in most situations. Larger values of qlambda may lead tooversmoothing, small values of qlambda lead to a random segmentation of homogeneous regions.A good value of qlambda can be obtained by the propagation condition, requiring that in case ofglobal validity of the local model the estimate for large hmax should be equal to the global estimate.

The numerical complexity of the procedure is mainly determined by hmax. The number of itera-tions is d*log(hmax/hinit)/log(hincr) with d being the dimension of y. Comlexity ineach iteration step is Const*hakt*n with hakt being the actual bandwith in the iteration stepand n the number of design points. hmax determines the maximal possible variance reduction.

Value

theta Parameter estimates, first dimension corresponds to parameter components

y values provided in y

x values provided in x

call actual function call

Author(s)

Joerg Polzehl, 〈[email protected]〉, http://www.wias-berlin.de/project-areas/stat/projects/adaptive-image-processing.html

References

Polzehl, J. and Spokoiny, V. (2003). Varying coefficient regression modeling by adaptive weightssmoothing, WIAS-Preprint 818.

Polzehl, J. and Spokoiny, V. (2002). Local likelihood modelling by adaptive weights smoothing,WIAS-Preprint 787.

Polzehl, J. and Spokoiny, V. (2000). Adaptive Weights Smoothing with applications to imagerestoration, J.R.Statist.Soc. B, 62, Part 2, pp. 335-354

laws 27

See Also

SEE ALSO aws, awsdens, awstindex

Examples

###### Artificial PET data###x <- 1:128f12 <- function(x,y){2*((1.5*(x-64)^2+(y-64)^2<3025)) +((x-64)^2+(y-104)^2<16)-((x-92)^2+(y-84)^2<25)+((x-78)^2+(y-84)^2<25)-((x-64)^2+(y-84)^2<36)+((x-50)^2+(y-84)^2<36)-((x-36)^2+(y-84)^2<25)+((x-92)^2+(y-64)^2<25)-((x-78)^2+(y-64)^2<16)+((x-64)^2+(y-64)^2<16)-((x-50)^2+(y-64)^2<25)+((x-36)^2+(y-64)^2<25)-((x-92)^2+(y-44)^2<36)+((x-78)^2+(y-44)^2<36)-((x-64)^2+(y-44)^2<25)+((x-50)^2+(y-44)^2<25)-((x-36)^2+(y-44)^2<16)+((x-64)^2+(y-24)^2<16)}u0 <- 2*outer(x,x,"f12")set.seed(1)y <- matrix(rpois(u0,u0),128,128)# use larger hmax for good resultsyhat <- laws(y,model="Poisson",hmax=4)$thetapar(mfrow=c(1,3),mar=c(3,3,3,.5),mgp=c(2,1,0))image(y,col=gray((0:255)/255))title("Observed image")image(yhat,col=gray((0:255)/255))title("AWS-Reconstruction")image(u0,col=gray((0:255)/255))title("True image")rm(u0,y,yhat,x)###### VOLATITILTY ESTIMATION###### artificial example###sigma <- c(rep(1,125),rep(2,125),rep(.5,125),rep(1,125))set.seed(1)x <- rnorm(sigma,0,sigma)tmpa <- laws(x,model="Volatility",u=sigma,graph=TRUE,hmax=250)tmps <- laws(x,model="Volatility",u=sigma,hmax=250,symmetric=TRUE)par(mfrow=c(1,1),mar=c(3,3,3,1))plot(abs(x),col=3,xlab="time t",ylab=expression(abs( R[t] )))lines(tmpa$theta,col=1,lwd=2)lines(tmps$theta,col=1,lwd=2,lty=2)lines(sigma,col=2,lwd=2,lty=3)legend(350,5.5,c("asymmetric AWS","symmetric AWS","true sigma"),

lwd=c(2,2,2),lty=c(1,2,3),col=c(1,1,2))title(expression(paste("Estimates of ",sigma(t))))

28 laws

rm(tmpa,tmps,sigma,x)

Index

∗Topic miscgetnubi, 22getnutri, 23

∗Topic modelsaws, 1awsdens, 10awsh, 13awstindex, 16laws, 24

∗Topic nonparametricaws, 1awsbi, 8awsdens, 10awsh, 13awstindex, 16awstri, 18awsuni, 20laws, 24

∗Topic regressionaws, 1awsbi, 8awsh, 13awstri, 18awsuni, 20laws, 24

∗Topic smoothaws, 1awsbi, 8awsdens, 10awsh, 13awstindex, 16awstri, 18awsuni, 20laws, 24

aws, 1, 9, 12, 16, 18, 19, 21, 26awsbi, 4, 8, 19, 21awsdens, 10, 26awsh, 13awstindex, 16, 26

awstri, 4, 9, 18, 21–23awsuni, 4, 9, 19, 20

getnubi, 22getnutri, 23

laws, 4, 11, 12, 17, 18, 24

29