Learn R Programming

spc4sts (version 0.6.3)

surfacemodel: 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.

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

Run this code
# NOT RUN {
## 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
# }

Run the code above in your browser using DataLab