Title: | Nonparametric Methods for Smoothing Nonsmooth Data |
---|---|
Description: | Nonparametric methods for smoothing regression function data with change-points, utilizing range kernels for iterative and anisotropic smoothing methods. For further details, see the paper by John R.J. Thompson (2024) <doi:10.1080/02664763.2024.2352759>. |
Authors: | John R.J. Thompson [aut, cre] |
Maintainer: | John R.J. Thompson <[email protected]> |
License: | CC BY 4.0 |
Version: | 1.0.0 |
Built: | 2024-11-01 04:39:20 UTC |
Source: | https://github.com/jrjthompson/r-package-nonsmooth |
This function implements the method in Thompson, J.R.J. (2024) for iterative smoothing
of change-point data that utilizes oversmoothed estimates of the underlying data
generating process to inform re-smoothing. The function calculates a local constant
estimator of
, and then utilizes
in the range kernel of another local constant estimator. This process is iterated
for a specified number of resmooth iterations.
alc(X,Y,bw.fixed.value=NULL,resmooths=1,...)
alc(X,Y,bw.fixed.value=NULL,resmooths=1,...)
X |
numeric matrix of |
Y |
numeric vector of the continuous response variable. |
bw.fixed.value |
numeric value for the bandwidth of the range kernel. Setting this value sets the
iterative smoothing bandwidths to be the local constant estimator bandwidths for
domain kernels and the set value for the range kernel. Default is |
resmooths |
integer number of resmooth iterations. Default is 1 resmooth, which is a suggested starting point for iterative smoothing. |
... |
additional specifications for |
The code here returns a npregression
object of the iteratively smoothed estimator.
For more details, see the npreg
function in the np
package.
Thompson, J.R.J. (2024) “Iterative Smoothing for Change-point Regression Function Estimation”, Journal of Applied Statistics, 1-25. <doi:10.1080/02664763.2024.2352759>
library(np) options(np.messages=FALSE) ## 1D Simulated change-point data changepoint.data <- changepoint.sim1D(500) ## Isotropic local constant model bw.lc <- npregbw(Y~X,data=changepoint.data) model.lc <- npreg(bw.lc) ## Anisotropic local constant model with one resmooth iteration model.alc <- alc(changepoint.data$X,changepoint.data$Y) ## Plot isotropic and anistropic smoothers plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y", pch=1,col="grey",las=1) lines(changepoint.data$X,model.lc$mean,col="blue",lty=1) lines(changepoint.data$X,model.alc$mean,col="red",lty=1) ## 2D Simulated image change-point data ## This simulation and estimation can take up to 5 minutes library(reshape2) changepoint.data <- changepoint.sim2D(data.dim=c(50,50)) image(changepoint.data) ## Melt the 2D image data for model estimation changepoint.data.melt <- melt(id.var=1:nrow(changepoint.data), changepoint.data) ## Isotropic local constant model bw.lc <- npregbw(xdat=changepoint.data.melt[,1:2],ydat=changepoint.data.melt[,3]) model.lc <- npreg(bw.lc) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.lc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## Anisotropic local constant model with one resmooth iteration and ## and fixed range kernel bandwidth model.alc <- alc(changepoint.data.melt[,1:2],changepoint.data.melt[,3],bw.fixed.value=10) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.alc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## 2D real fire spread change-point data data("fireData") changepoint.data <- fireData[,,1,20] ## Plot with pixel locations image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(changepoint.data, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## Melt the 2D image data for model estimation changepoint.data.melt <- melt(id.var=1:nrow(changepoint.data), changepoint.data) ## Isotropic local constant model bw.lc <- npregbw(xdat=changepoint.data.melt[,1:2],ydat=changepoint.data.melt[,3]) model.lc <- npreg(bw.lc) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.lc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## Anisotropic local constant model with one resmooth iteration and ## and fixed range kernel bandwidth model.alc <- alc(changepoint.data.melt[,1:2],changepoint.data.melt[,3],bw.fixed.value=10) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.alc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) options(np.messages=TRUE)
library(np) options(np.messages=FALSE) ## 1D Simulated change-point data changepoint.data <- changepoint.sim1D(500) ## Isotropic local constant model bw.lc <- npregbw(Y~X,data=changepoint.data) model.lc <- npreg(bw.lc) ## Anisotropic local constant model with one resmooth iteration model.alc <- alc(changepoint.data$X,changepoint.data$Y) ## Plot isotropic and anistropic smoothers plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y", pch=1,col="grey",las=1) lines(changepoint.data$X,model.lc$mean,col="blue",lty=1) lines(changepoint.data$X,model.alc$mean,col="red",lty=1) ## 2D Simulated image change-point data ## This simulation and estimation can take up to 5 minutes library(reshape2) changepoint.data <- changepoint.sim2D(data.dim=c(50,50)) image(changepoint.data) ## Melt the 2D image data for model estimation changepoint.data.melt <- melt(id.var=1:nrow(changepoint.data), changepoint.data) ## Isotropic local constant model bw.lc <- npregbw(xdat=changepoint.data.melt[,1:2],ydat=changepoint.data.melt[,3]) model.lc <- npreg(bw.lc) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.lc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## Anisotropic local constant model with one resmooth iteration and ## and fixed range kernel bandwidth model.alc <- alc(changepoint.data.melt[,1:2],changepoint.data.melt[,3],bw.fixed.value=10) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.alc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## 2D real fire spread change-point data data("fireData") changepoint.data <- fireData[,,1,20] ## Plot with pixel locations image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(changepoint.data, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## Melt the 2D image data for model estimation changepoint.data.melt <- melt(id.var=1:nrow(changepoint.data), changepoint.data) ## Isotropic local constant model bw.lc <- npregbw(xdat=changepoint.data.melt[,1:2],ydat=changepoint.data.melt[,3]) model.lc <- npreg(bw.lc) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.lc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) ## Anisotropic local constant model with one resmooth iteration and ## and fixed range kernel bandwidth model.alc <- alc(changepoint.data.melt[,1:2],changepoint.data.melt[,3],bw.fixed.value=10) image(1:dim(changepoint.data)[1], 1:dim(changepoint.data)[2], matrix(model.alc$mean, nrow=dim(changepoint.data)[1], byrow=FALSE)) options(np.messages=TRUE)
This function simulates one-dimension change-point data for three data types, and one smooth data type for testing change-point regression estimators.
changepoint.sim1D(n,sigma=1,data.type = "continuousWithJump")
changepoint.sim1D(n,sigma=1,data.type = "continuousWithJump")
n |
Integer value for sample size. |
sigma |
Numeric value of standard deviation. |
data.type |
Character value for different data types. The options for
change-point data are: constant functions seperated by two jumps
( |
This function produces a data.frame, consisting of the simulated data and the data generating process.
X |
Numeric vector of explanatory data |
Y |
Numeric vector of response data |
oracle |
Numeric vector of the data generating process for |
Thompson, J.R.J. (2024) “Iterative Smoothing for Change-point Regression Function Estimation”, Journal of Applied Statistics, 1-25. <doi:10.1080/02664763.2024.2352759>
## 1D continuous data of nonlinear functions with a jump change-point changepoint.data <- changepoint.sim1D(100) plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1) ## 1D continuous data of constant functions with two jump change-points changepoint.data <- changepoint.sim1D(100,data.type="uniformJump") plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1) ## 1D continuous data of linear functions with two derivative change-points changepoint.data <- changepoint.sim1D(100,data.type="gradualJump") plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1) ## 1D continuous data of a nonlinear continuous function changepoint.data <- changepoint.sim1D(100,data.type="continuous") plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1)
## 1D continuous data of nonlinear functions with a jump change-point changepoint.data <- changepoint.sim1D(100) plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1) ## 1D continuous data of constant functions with two jump change-points changepoint.data <- changepoint.sim1D(100,data.type="uniformJump") plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1) ## 1D continuous data of linear functions with two derivative change-points changepoint.data <- changepoint.sim1D(100,data.type="gradualJump") plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1) ## 1D continuous data of a nonlinear continuous function changepoint.data <- changepoint.sim1D(100,data.type="continuous") plot(changepoint.data$X,changepoint.data$Y,xlab = "X",ylab = "Y",pch=1,col="grey",las=1) lines(changepoint.data$X,changepoint.data$oracle,col="red",lty=1)
This function simulates circular change-point data with Gaussian noise.
changepoint.sim2D(data.dim = c(100,100),sigma = 20,radius=NULL,cbase=80,ctop=130)
changepoint.sim2D(data.dim = c(100,100),sigma = 20,radius=NULL,cbase=80,ctop=130)
data.dim |
Vector of two integers for the size of the two-dimensional dataset. The dimensions are suggested to be the same. However, for uneven dimensions, the first value must be larger. The default is an image of 100 by 100 pixels. |
sigma |
Numeric value of standard deviation. |
radius |
Numeric value of the radius of the inner disk before the change-point. The radius cannot be larger than one-half of either dimension in |
cbase |
Numeric value for the disk that radiates out from the approximate center of the dataset. |
ctop |
Numeric value after the circular change-point, seperating the disk and the outer region. |
This function produces a matrix of integer values of the same dimensions as data.dim
.
Thompson, J.R.J. (2024) “Iterative Smoothing for Change-point Regression Function Estimation”, Journal of Applied Statistics, 1-25. <doi:10.1080/02664763.2024.2352759>
## Simulate 2D data and plot it library(reshape2) changepoint.data <- changepoint.sim2D() image(1:nrow(changepoint.data), 1:ncol(changepoint.data), matrix(changepoint.data, nrow=nrow(changepoint.data), byrow=FALSE))
## Simulate 2D data and plot it library(reshape2) changepoint.data <- changepoint.sim2D() image(1:nrow(changepoint.data), 1:ncol(changepoint.data), matrix(changepoint.data, nrow=nrow(changepoint.data), byrow=FALSE))
The fire spread data consists of 45 segmented RGB images from a fire smouldering experiment of wax paper. The data were measured using a digital camera at a birds-eye view above the experiment. The data is segmented 1 frame per second.
data("fireData")
data("fireData")
The movie of the fire spread is a data frame with four dimensions. The first and second dimensions of the data frame are the pixel coordinates of one image. The third dimension is the RGB channel, with the red channel (1), blue channel (2), and green channel (3). The fourth dimension is time, starting at ignition (time point 1), and then each RGB image is separated by one second for a total of 45 seconds.
John R.J. Thompson
Thompson, J.R.J., Wang, X.J., & Braun, W.J. (2020) “A mouse model for studying fire spread rates using experimental micro-fires”, Journal of Environmental Statistics, 9(1), 1-19. <[https://www.jenvstat.org/v09/i06]https://www.jenvstat.org/v09/i06>
Wang, X.J., Thompson, J.R.J., Braun, W.J., & Woolford, D.G. (2019) “Fitting a stochastic fire spread model to data.” Advances in Statistical Climatology, Meteorology and Oceanography, 5(1), 57-66. <[https://ascmo.copernicus.org/articles/5/57/2019/]https://ascmo.copernicus.org/articles/5/57/2019/>
## Example - viewing a fire spread experiment that contains change-points data("fireData") ## Plot the red channel at 10 seconds as a 2d image image(1:dim(fireData)[1], 1:dim(fireData)[2], matrix(fireData[,,1,10], nrow=dim(fireData)[1], byrow=FALSE))
## Example - viewing a fire spread experiment that contains change-points data("fireData") ## Plot the red channel at 10 seconds as a 2d image image(1:dim(fireData)[1], 1:dim(fireData)[2], matrix(fireData[,,1,10], nrow=dim(fireData)[1], byrow=FALSE))
This package provides nonparametric methods for smoothing nonsmooth data. Change-point data is the intended application, with a focus on those with jumps in the regression function. Descriptions of the implementation of these methods can be found in Thompson, J.R.J. (2024).
This package contains two additional functions for simulated one-D and two-D change-point data. This package also contains a real fire spread dataset from a micro-fire experiment. This data can be viewed as time dependent two-dimensional change-point data. The boundaries between fuel, burning and burn-out regions are seperated by two change-point curves. More information on experimentation and data can befound in Thompson, Wang, and Braun (2020) and Wang, Thompson, and Braun (2019).
John R.J. Thompson <[email protected]>
Maintainer: John R.J. Thompson <[email protected]>
I would like to acknowledge funding support from the University of British Columbia Aspire Fund (UBC:www.ok.ubc.ca/).
Thompson, J.R.J. (2024) “Iterative Smoothing for Change-point Regression Function Estimation”, Journal of Applied Statistics, 1-25. <doi:10.1080/02664763.2024.2352759>
Thompson, J.R.J., Wang, X.J., & Braun, W.J. (2020) “A mouse model for studying fire spread rates using experimental micro-fires”, Journal of Environmental Statistics, 9(1), 1-19. <[https://www.jenvstat.org/v09/i06]https://www.jenvstat.org/v09/i06>
Wang, X.J., Thompson, J.R.J., Braun, W.J., & Woolford, D.G. (2019) “Fitting a stochastic fire spread model to data.” Advances in Statistical Climatology, Meteorology and Oceanography, 5(1), 57-66. <[https://ascmo.copernicus.org/articles/5/57/2019/]https://ascmo.copernicus.org/articles/5/57/2019/>