www.gusucode.com > stats 源码程序 matlab案例代码 > stats/BootstrappingARegressionModelExample.m
%% Bootstrapping a Regression Model % This example shows how to estimate the standard errors for a coefficient % vector in a linear regression by bootstrapping the residuals. % Copyright 2015 The MathWorks, Inc. %% % Load the sample data. load hald %% % Perform a linear regression and compute the residuals. x = [ones(size(heat)),ingredients]; y = heat; b = regress(y,x); yfit = x*b; resid = y - yfit; %% % Estimate the standard errors by bootstrapping the residuals. se = std(bootstrp(... 1000,@(bootr)regress(yfit+bootr,x),resid))