Statistics Toolbox    
glmval

Compute predictions for generalized linear model

Syntax

Description

yfit = glmval(b,X,'link') computes the predicted distribution parameters for observations with predictor values X using the coefficient vector b and link function 'link'. Typically, b is a vector of coefficient estimates computed by the glmfit function. The value of 'link' must be the same as that used in glmfit. The result yfit is the value of the inverse of the link function at the linear combination X*b.

[yfit,dlo,dhi] = glmval(b,X,'link',stats,clev) returns confidence bounds for the predicted values when you supply the stats structure returned from glmfit, and optionally specify a confidence level as the clev argument. (The default confidence level is 0.95 for 95% confidence.) The interval [yfit-dlo, yfit+dhi] is a confidence bound for the true parameter value at the specified X values.

[yhat,dlo,dhi] = glmval(beta,X,'link',stats,clev,N,offset,'const') specifies three additional arguments that may be needed if you used certain arguments to glmfit. If you fit a binomial distribution using glmfit, specify N as the value of the binomial N parameter for the predictions. If you included an offset variable, specify offset as the new value of this variable. Use the same 'const' value ('on' or 'off') that you used with glmfit.

Example

Let's model the number of cars with poor gasoline mileage using the binomial distribution. First we use the binomial distribution with the default logit link to model the probability of having poor mileage as a function of the weight and squared weight of the cars. Then we compute a vector wnew of new car weights at which we want to make predictions. Next we compute the expected number of cars, out of a total of 30 cars of each weight, that would have poor mileage. Finally we graph the predicted values and 95% confidence bounds as a function of weight.

See Also
glmfit, glmdemo


  glmfit gname