Documentation Center    • Trial Software   • Product Updates
Class: LinearModel  Simulate responses for linear regression
model   ysim = random(mdl) ysim = random(mdl,Xnew)   ysim =
random(mdl) simulates responses from the fitted linear model mdl
at the original design points.  ysim = random(mdl,Xnew)
simulates responses from the mdl linear model to the data in
Xnew, adding random noise.  Input Arguments   Linear model, as
constructed by fitlm or stepwiselm.   Points at which mdl
predicts responses.    Output Arguments   Vector of predicted
mean values at Xnew, perturbed by random noise. The noise is
independent, normally distributed, with mean zero, and variance
equal to the estimated error variance of the model.   expand all
Simulate Response Data  Create a model of car mileage as a
function of weight, and simulate the response.   load carsmall X
= Weight; y = MPG;  Create simulated responses to the data.
Xnew = X; ysim = random(mdl,Xnew);  Plot the original responses
and the simulated responses to see