显示决定系数
此示例说明如何显示r侧(判决因子)并调整r侧。 加载示例数据并定义响应和参数。
加载主机
y=hospital.blood pressure (:1 );
x=double(hospital ) :2:5 );
配合线性回归模型。
MDL=fitlm(x,y ) ) )。
mdl=
线性注册模型:
y ~ 1 x1 x2 x3 x4
Estimated Coefficients:
Estimate SE tStat pValue
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ u
(Intercept ) 117.4 5.2451 22.383 1.1667e-39
x1 0.88162 2.9473 0.29913 0.76549
x2 0.08602 0.06731 1.278 0.20438
x3-0.0166850.055714-0.299470.76524
x4 9.884 1.0406 9.498 1.9546e-15
Number of observations: 100、Error degrees of freedom: 95
Root Mean Squared Error: 4.81
R-squared: 0.508、高级r-squared : 0.487
f-statistic vs.constant model :24.5,p-value=5.99e-14
r侧的值和调整r侧的值分别为0.508和0.487。 模型解释了响应变量约50%的变异。
使用拟合的LinearModel对象的特性访问r值并调整r值。
mdl.Rsquared.Ordinary
ans=0.5078
mdl.Rsquared.Adjusted
ans=0.4871
调整为r侧的值小于通常的r侧的值。