feval - Predict responses of generalized linear regression model using one input for

        each predictor - MATLAB ([original](http://www.mathworks.com/help/stats/generalizedlinearmodel.feval.html)) ([raw](?raw))

Predict responses of generalized linear regression model using one input for each predictor

Syntax

Description

[ypred](#btbshi0-ypred) = feval([mdl](#btbshi0%5Fsep%5Fshared-mdl),[Xnew1,Xnew2,...,Xnewn](#btbshi0%5Fsep%5Fshared-Xnew1Xnew2Xnewn)) returns the predicted response of mdl to the new input predictorsXnew1,Xnew2,...,Xnewn.

example

Examples

collapse all

Create a generalized linear regression model, and plot its responses to a range of input data.

Generate sample data using Poisson random numbers with two underlying predictors X(:,1) and X(:,2).

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');

Generate a range of values for X(:,1) and X(:,2), and plot the predictions at the values.

[Xtest1,Xtest2] = meshgrid(min(X(:,1)):.5:max(X(:,1)),min(X(:,2)):.5:max(X(:,2))); Z = feval(mdl,Xtest1,Xtest2); surf(Xtest1,Xtest2,Z)

Figure contains an axes object. The axes object contains an object of type surface.

Input Arguments

collapse all

Data Types: single | double | table

Output Arguments

collapse all

Predicted response values at Xnew1,Xnew2,...,Xnewn, returned as a numeric vector.

For a binomial model, feval uses 1 as theBinomialSize parameter, so the values inypred are predicted probabilities. To return the numbers of successes in the trials, use the predict function and specify the number of trials by using the 'BinomialSize' name-value pair argument.

For a model with an offset, feval uses 0 as the offset value. To specify the offset value used when you fit a model, use thepredict function and the'Offset' name-value pair argument.

Tips

Alternative Functionality

Extended Capabilities

Version History

Introduced in R2012a