matlab 中rstool工具箱(多变量线性回归)
1.rstool工具箱
具体参考官网https://ww2.mathworks.cn/help/stats/rstool.html
用法:rstool(x,y,model
,alpha,xname,yname)
运行上面的语句后出现一个交互式画面(如下图所示)
x为一个矩阵(n*m) y矩阵(n*1) alpha:显著水平
model 包括 :
-
Linear
— Constant and linear terms (the default) -
Pure Quadratic
— Constant, linear, and squared terms(squared terms:平方项) -
Interactions
— Constant, linear, and interaction terms -
Full Quadratic
— Constant, linear, interaction, and squared terms
可点击 上图中的 Export 将所得的参数(beta,rmse)导出
.beta是所得多项式的参数,
例如当model为linear,且只有两个自变量为,多项式公式为:常数 + aX1 + bX2
当model为Interactions且
有三个自变量(1 2 3 ),多项式为: 常数 + ax1 + bx2 + cx3 dx1x2 + ex1x3 + fx2x3
即交叉项的顺序为12 ,13 ,23
rmse:
- 均方根误差
- 是观测值与真值偏差的平方和与观测次数m比值的平方根。
- 是用来衡量观测值同真值之间的偏差