Main Content

feval

Class:NonLinearModel

Evaluate nonlinear regression model prediction

Syntax

ypred = feval(mdl,Xnew1,Xnew2,...,Xnewn)

Description

ypred= feval(mdl,Xnew1,Xnew2,...,Xnewn)returns the predicted response ofmdlto the input[Xnew1,Xnew2,...,Xnewn].

Input Arguments

mdl

Nonlinear regression model, constructed byfitnlm.

Xnew1,Xnew2,...,Xnewn

Predictor components.Xnewican be one of:

  • Scalar

  • Vector

  • Array

Each nonscalar component must have the same size (number of elements in each dimension).

If you pass just oneXnewarray,Xnewcan be a table, dataset array, or an array of doubles, where each column of the array represents one predictor.

Output Arguments

ypred

Predicted mean values atXnew.ypredis the same size as each component ofXnew.

Examples

expand all

Create a nonlinear model for auto mileage based on thecarbigdata. Predict the mileage of an average car.

Load the data and create a nonlinear model.

loadcarbigtbl = table(Horsepower,Weight,MPG); modelfun = @(b,x)b(1) + b(2)*x(:,1).^b(3) +...b(4)*x(:,2).^b(5); beta0 = [-50 500 -1 500 -1]; mdl = fitnlm(tbl,modelfun,beta0);

Find the predicted mileage of an average car. The data contains some missing (NaN) observations, so compute the mean usingmeanwith the'omitnan'option.

Xnew = mean([Horsepower Weight],'omitnan'); MPGnew = feval(mdl,Xnew)
MPGnew = 21.8073

Alternatives

predictgives the same predictions, but uses a single input array with one observation in each row, rather than one component in each input argument.predict也给了知名的ence intervals on its predictions.

randompredicts with added noise.