Plot of slices through fitted generalized linear regression surface
plotSlice( creates a figure
containing one or more plots, each representing a slice through the regression
surface predicted by
mdl. Each plot shows the fitted response
values as a function of a single predictor variable, with the other predictor
variables held constant.
plotSlice also displays the 95% confidence bounds for the
response values. Use the Bounds menu to choose the type
of confidence bounds, and use the Predictors menu to
select which predictors to use for each slice plot. For details, see Tips.
Slice Plot for Generalized Linear Regression Model
Plot slices through a fitted generalized linear regression model surface.
Generate sample data using Poisson random numbers with two underlying predictors
rng('default') % For reproducibility rndvars = randn(100,2); X = [2 + rndvars(:,1),rndvars(:,2)]; mu = exp(1 + X*[1;2]); y = poissrnd(mu);
Create a generalized linear regression model of Poisson data.
mdl = fitglm(X,y,'y ~ x1 + x2','Distribution','poisson');
Create a slice plot.
The green line in each plot represents the predicted response values as a function of a single predictor variable, with the other predictor variables held constant. The red dotted lines are the 95% confidence bounds. The y-axis label includes the predicted response value and the corresponding confidence bound for the point selected by the vertical and horizontal lines. The x-axis label shows the predictor variable name and the predictor value for the selected point.
Move the vertical line in the
x1 plot to the right and observe the change in the y-axis label and the changes in the
Use the Bounds menu in the figure window to choose the type of confidence bounds. You can choose Simultaneous or Non-Simultaneous. You can also choose No Bounds to have no confidence bounds.
Simultaneous (default) —
plotSlicecomputes confidence bounds for the curve of the response values using Scheffe's method. The range between the upper and lower confidence bounds contains the curve consisting of true response values with 95% confidence.
plotSlicecomputes confidence bounds for the response value at each observation. The confidence interval for a response value at a specific predictor value contains the true response value with 95% confidence.
Simultaneous bounds are wider than separate bounds, because requiring the entire curve of response values to be within the bounds is stricter than requiring the response value at a single predictor value to be within the bounds.
Use the Predictors menu in the figure window to select which predictors to use for each slice plot. If the regression model
mdlincludes more than eight predictors,
plotSlicecreates plots for the first five predictors by default.
predictto return the predicted response values and confidence bounds. You can also specify the confidence level for confidence bounds by using the
'Alpha'name-value pair argument of the
predictfunction. Note that
predictfinds nonsimultaneous bounds by default, whereas
plotSlicefinds simultaneous bounds by default.
GeneralizedLinearModelobject provides multiple plotting functions.
When verifying a model, use
plotDiagnosticsto find questionable data and to understand the effect of each observation. Also, use
plotResidualsto analyze the residuals of the model.
After fitting a model, use
plotPartialDependenceto understand the effect of a particular predictor. Also, use
plotSliceto plot slices through the prediction surface.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Introduced in R2012a