Esta página aún no se ha traducido para esta versión. Puede ver la versión más reciente de esta página en inglés.

plotAdded

Clase: LinearModel

Added variable plot or leverage plot for linear model

Sintaxis

plotAdded(mdl)
plotAdded(mdl,coef)
h = plotAdded(mdl,___)
h = plotAdded(mdl,coef,Name,Value)

Description

plotAdded(mdl) produces a generalized added variable plot for all terms in the full, fitted regression model mdl, except the constant term.

plotAdded(mdl,coef) produces an added variable plot for the coef terms in mdl, after adjusting for all other terms.

h = plotAdded(mdl,___) returns handles to the lines in the plot, using any of the previous syntaxes.

h = plotAdded(mdl,coef,Name,Value) plots with additional options specified by one or more Name,Value pair arguments.

Argumentos de entrada

expandir todo

Full, fitted linear regression model, specified as a LinearModel object constructed using fitlm or stepwiselm.

Coefficients in regression model mdl, specified as one of the following:

  • Character vector or string scalar giving a single coefficient name

  • Vector of coefficient numbers in the mdl.CoefficientNames property.

Tipos de datos: char | string | single | double

Argumentos de par nombre-valor

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Nota

The plot property name-value pairs apply to the first returned handle h(1).

Color of the line or marker, specified as the comma-separated pair consisting of 'Color' and a ColorSpec specification. For details, see linespec.

Line style, specified as the comma-separated pair consisting of 'LineStyle' and a Line Properties specification. For details, see linespec.

Width of the line or edges of filled area, in points, specified as the comma-separated pair consisting of 'LineWidth' and a positive numeric value. One point is equal to 1/72 inch.

Color of the marker or edge color for filled markers, specified as the comma-separated pair consisting of 'MarkerEdgeColor' and a ColorSpec specification. For details, see linespec.

Color of the marker face for filled markers, specified as the comma-separated pair consisting of 'MarkerFaceColor' and a ColorSpec specification. For details, see linespec.

Size of the marker in points, specified as the comma-separated pair consisting of 'MarkerSize' and a positive numeric value. One point is 1/72 inch.

Output Arguments

expandir todo

Graphics handles, returned as a vector of graphics handles corresponding to the lines or patches in the plot.

Ejemplos

expandir todo

Create a model of car mileage as a function of weight and model year. Then create a plot to see the significance of the model.

Create a linear model of mileage from the carsmall data.

load carsmall
tbl = table(MPG,Weight);
tbl.Year = ordinal(Model_Year);
mdl = fitlm(tbl,'MPG ~ Year + Weight^2');

Create an added variable plot.

plot(mdl)

The plot illustrates that the model is significant because a horizontal line does not fit between the confidence bounds.

Create a model of car mileage as a function of weight and model year. Then create a plot to see the effect of the weight terms (Weight and Weight^2).

Create a linear model of mileage from the carsmall data.

load carsmall
tbl = table(MPG,Weight);
tbl.Year = ordinal(Model_Year);
mdl = fitlm(tbl,'MPG ~ Year + Weight^2');

Find the terms in the model corresponding to the Weight and Weight^2.

mdl.CoefficientNames
ans = 1x5 cell array
    {'(Intercept)'}    {'Weight'}    {'Year_76'}    {'Year_82'}    {'Weight^2'}

The weight terms are 2 and 5.

Create an added variable plot with the weight terms.

coef = [2 5];
plotAdded(mdl,coef)

The plot illustrates that the weight terms are significant because a horizontal line does not fit between the confidence bounds.

Más acerca de

expandir todo

Sugerencias

  • For many plots, the Data Cursor tool in the figure window displays the x and y values for any data point, along with the observation name or number.