surfacemodel: Statistical reprentations of stochastic textured surfaces...

View source: R/surfacemodel.R

surfacemodelR Documentation

Statistical reprentations of stochastic textured surfaces using supervised learning

Description

Provides a statistical represenation for a given stochastic textured surface image via a supervised learning model (a regression tree in this version).

Usage

surfacemodel(img, nb, trim.vars = TRUE, cp = 1e-5,
             xval = 5, standardize = TRUE, subsample = 1,
             verbose = FALSE, keep.residuals = FALSE)

Arguments

img

the given stochastic textured surface image in the matrix format.

nb

the size of the neighborhood. It must be a 1-length or 3-length vector of positive integer(s). If the former, it is the same with a 3-length vector with the same elements.

trim.vars

if TRUE, refit the model using only the variables that were used in the first fit.

cp

the complexity parameter for rpart fits (see rpart.control).

xval

the number of folds in cross-validation (see rpart.control). If xval <= 1, cross-validation will not be used.

standardize

if TRUE, standardize the given image img <- (img - mean(img))/sd(img). This reduces the effect of different lighting conditions when images are taken.

subsample

the portion of pixels in the given image img to be used. It takes values in (0,1]. subsample = .5 means that roughly a half number of pixels is used.

verbose

if TRUE, output some model fitting information.

keep.residuals

if TRUE, keep residuals of the fitted model in the output.

Value

A surfacemodel object containing the following components:

fit

the pruned rpart tree using cross-validation.

trim.vars

the trim.vars argument.

nb

the nb argument.

Fr

the empirical cdf with exponential tail approximation of the model residuals.

MSE

the mean squared residuals.

standardize

the standardize argument.

R2cv

the cross-validated R-squared of fit.

complexity

the complexity value of the returned fit.

vars

the variables used in the formula when fitting the model.

residuals

the residuals of the fitted model.

Note

The best value for the neighborhood size nb argument can be chosen by comparing the cross-validated R-squared values R2cv of models built with different values of nb. Users may use 'surfacemodel' with some initial large nb, and then use the showNb() function to visualize the importance of the predictors used in the fitted model to have some idea about the range of important predictors to reduce (or increase if necessary) nb.

After finalizing the choice of nb, it is better to set trim.vars = TRUE to further remove some unused variables within that neighborhood.

The raster scan order for constructing the neiborhood data in dataPrep() is left-to-right then top-to-bottom (see Bui and Apley 208a). Rotating the image by every 90 degrees could be used to quicly change to some other raster scan orders. Again, the cross-validated R-squared R2cv output can be used to select the best raster scan order. See the below examples.

plot.surfacemodel() is a generic function for surfacemodel() that produces two plots: a plot of the cross-validation R-squared against the complexity parameter and a histogram of the residuals (along with a normal density curve) of the fitted model.

Author(s)

Anh Bui

References

Bui, A.T. and Apley., D.W. (2018a) "A Monitoring and Diagnostic Approach for Stochastic Textured Surfaces", Technometrics, 60, 1-13.

See Also

dataPrep, showNb, monitoringStat, rpart

Examples

## fit a model to characterize the surface of a simulated image:
img <- sarGen(m = 50, n = 50, border = 50) # training image
model <- surfacemodel(img, nb = 1, keep.residuals = TRUE) # see Note above for how to select nb
model
# plot cross-validation R-squared against complexity parameter and residual histogram
plot(model, type=1:2)

## change the raster scan order from left-to-right then top-to-bottom to
## left-to-right then bottom-to-top, and re-fit the model
## (see the Note section above)
img2  <- as.matrix(t(apply(img , 2, rev)))
model2 <- surfacemodel(img2, nb = 1)
model2$R2cv # cross-validation R-squared

spc4sts documentation built on May 24, 2022, 5:07 p.m.