200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 用matlab做一元线性回归画图 [转载]用matlab做一元线性回归分析

用matlab做一元线性回归画图 [转载]用matlab做一元线性回归分析

时间:2024-07-23 02:12:02

相关推荐

用matlab做一元线性回归画图 [转载]用matlab做一元线性回归分析

一元线性回归分析是在排除其他影响因素的假定其他影响因素确定的情况下,分析某一个因素(自变量)是如何影响另外一个事物(因变量)的过程,所进行的分析是比较理想化的。

用SPSS可以做一元线性回归分析,但是当回归的自变量比较多的时候,一个一个的输入会比较麻烦,增加了计算量,本文中描述了如何用matlab语言来实现一元线性回归分析。

在matlab中,regress命令是用来做回归的。假如有96个SNP,作为自变量,有一个因变量,比如说HDL,LDL等等,将它们以列导入matlab。值得注意的是:自变量前面必须有一列全为1的数据,看下面例子即可理解。

for i=1:96

z=[ones(2334,1), x(:,i)];

[b,bint,r,rint,stats]=regress(y,z);

c(i,:)=stats;

end

在一元线性回归方程中,回归方程的显著性检验可以替代回归系数的显著性检验,并且F=T2

百度中的一个例子:

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

regress

Multiple linear regression

Syntax

b =

regress(y,X)

[b,bint] = regress(y,X)

[b,bint,r] = regress(y,X)

[b,bint,r,rint] = regress(y,X)

[b,bint,r,rint,stats] = regress(y,X)

[...] = regress(y,X,alpha)

Description

b = regress(y,X) returns the least

squares fit of y on X by solving the linear model

for β, where:

y is an n-by-1

vector of observations

X is an n-by-p

matrix of regressors

β is a p-by-1

vector of parameters

ɛ is an n-by-1

vector of random disturbances

[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 is evidence that the ith observation is an outlier.

[b,bint,r,rint,stats] = regress(y,X) returns a vector

stats that contains the R2 statistic, the F statistic and a p value

for the full model, and an estimate of the error

variance.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。