当前位置:首页>开发>正文

matlab做回归分析 怎样用MATLAB进行回归分析

2023-04-12 01:19:26 互联网 未知 开发

matlab做回归分析 怎样用MATLAB进行回归分析

怎样用MATLAB进行回归分析

X=[1 1 4 6 8 11 14 17 21]
Y=[2.49 3.30 3.68 12.20 27.04 61.10 108.80 170.90 275.50]
X=[ones(9,1), X]
[b,bint,r,rint,stats]= regress(Y,X)

输出向量b,bint为回归系数估计值和它们的置信区间,r,rint为残差及其置信区间,stats是用于检验回归模型的统计量,有三个数值,第一个是R2,其中R是相关系数,第二个是F统计量值,第三个是与统计量F对应的概率P,当P<α时拒绝H0,回归模型成立。

matlab进行回归分析

regress可以解决多元线性回归,非线性回归转换后也可以解
polyfit是一元的多项式回归,[p,S]=polyfit(x,y,2)
中的2是多项式中自变量的最高次数,即y=a b*x c*x^2

利用matlab做回归分析,

利用matlab做回归分析的步骤:
x1=[]
x2=[]
x3=[]
X=[ones(length(x1) x1 x2 x3]
[b,bint,r,rint,stats]=regress(y,X)
a=b(1),c=b(3),c=b(4),b=(2)
这样就可以得到y=a bx1 cx2 dx3的表达式的系数。

大哥,MATLAB做线性回归分析

自己看regress帮助文档。

[b,bint] = regress(y,X) returns a matrix bint of 95% confidence intervals for β.

[b,bint,r] = regress(y,X) returns a vector, r, of residuals.

[b,bint,r,rint] = regress(y,X) returns a matrix rint of intervals that can be used to diagnose outliers. If rint(i,:) does not contain zero, then the ith residual is larger than would be expected, at the 5% significance level. This suggests that the ith observation is an outlier.

[b,bint,r,rint,stats] = regress(y,X) returns a vector stats that contains, in the following order, the R2 statistic, the F statistic and a p value for the full model, and an estimate of the error variance.

[...] = regress(y,X,alpha) uses a 100(1 - alpha)% confidence level to compute bint, and a (100*alpha)% significance level to computerint. For example, alpha = 0.2 gives 80% confidence intervals.

在MATLAB中怎么做啊?一元回归分析的内容

X和Y的长度不等啊,X是16个数,Y是8个数。且X的前8个都是1。如果用X的后8个数与Y回归,则:

clearclc
X=[1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.5 2.0 3.0 4.5 7.5 9.1 10.5 12.0]
Y=[5.6 6.6 7.2 7.8 10.1 10.8 13.5 16.5]

p=polyfit(X(:,2),Y,1)
xx=linspace(1.5,12,30)
yy=polyval(p,xx)
plot(X(:,2),Y,o,xx,yy)
y=poly2sym(p,x)

运行结果:
p =
0.8950 4.15y = 0.8950*x 4.1575

最新文章