www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CustomConfidenceIntervalsExample.m
%% Fit Linear Model with Custom Confidence Intervals % Fit a linear regression model for auto mileage based on the |carbig| data. Then % obtain confidence intervals for the resulting model coefficients at the % 99% level. %% % Load the data and create a table. load carbig Origin = nominal(Origin); tbl = table(Horsepower,Weight,MPG,Origin); %% % Fit a linear regression model using horsepower, weight, and origin as the % predictor variables, and miles per gallon as the response variable. modelspec = 'MPG ~ 1 + Horsepower + Weight + Origin'; mdl = fitlm(tbl,modelspec); %% % Find 99% confidence intervals for the coefficients. ci = coefCI(mdl,.01) %% % The confidence intervals are wider than the default 5% confidence intervals.