surfacemodel | R Documentation |
Provides a statistical represenation for a given stochastic textured surface image via a supervised learning model (a regression tree in this version).
surfacemodel(img, nb, trim.vars = TRUE, cp = 1e-5, xval = 5, standardize = TRUE, subsample = 1, verbose = FALSE, keep.residuals = FALSE)
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 |
cp |
the complexity parameter for rpart fits (see |
xval |
the number of folds in cross-validation (see |
standardize |
if |
subsample |
the portion of pixels in the given image |
verbose |
if |
keep.residuals |
if |
A surfacemodel
object containing the following components:
fit |
the pruned |
trim.vars |
the |
nb |
the |
Fr |
the empirical cdf with exponential tail approximation of the model residuals. |
MSE |
the mean squared residuals. |
standardize |
the |
R2cv |
the cross-validated R-squared of |
complexity |
the complexity value of the returned |
vars |
the variables used in the formula when fitting the model. |
residuals |
the residuals of the fitted model. |
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.
Anh Bui
Bui, A.T. and Apley., D.W. (2018a) "A Monitoring and Diagnostic Approach for Stochastic Textured Surfaces", Technometrics, 60, 1-13.
dataPrep, showNb, monitoringStat, rpart
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.