Simulate responses for nonlinear regression model
ysim = random(mdl)
ysim = random(mdl,Xnew)
ysim = random(mdl,Xnew,'Weights',W)
Nonlinear regression model, constructed by
Points at which
Vector of real, positive value weights or a function handle.
Default: No weights
Vector of predicted mean values at
Create a nonlinear model of car mileage as a function of weight, and simulate the response.
Create an exponential model of car mileage as a function of weight from the
carsmall data. Scale the weight by a factor of 1000 so all the variables are roughly equal in size.
load carsmall X = Weight; y = MPG; modelfun = 'y ~ b1 + b2*exp(-b3*x/1000)'; beta0 = [1 1 1]; mdl = fitnlm(X,y,modelfun,beta0);
Create simulated responses to the data.
Xnew = X; ysim = random(mdl,Xnew);
Plot the original responses and the simulated responses to see how they differ.
For predictions without added noise, use