首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >matlab中的回归分析

matlab中的回归分析
EN

Stack Overflow用户
提问于 2011-07-23 05:27:49
回答 1查看 1.1K关注 0票数 0

我有一个独立变量回归的matlab代码,但是如果我有两个独立变量(x1和x2)呢?我应该如何修改这个多项式回归的代码?

代码语言:javascript
复制
x = linspace(0,10,200)'; % independent variable
y = x + 1.5*sin(x) + randn(size(x,1),1); % dependent variable

A = [x.^0, x];        % construct a matrix of permutations
w = (A'*A)\(A'*y);    % solve the normal equation 
y2 = A*w;             % restore the dependent variable
r = y-y1;             % find the vector of regression residual

plot(x, [y y2]);
EN

回答 1

Stack Overflow用户

发布于 2011-07-23 05:54:11

Matlab具有多项式回归函数polyfit的功能。你试过吗?

http://www.mathworks.com/help/techdoc/data_analysis/f1-8450.html

http://www.mathworks.com/help/toolbox/stats/bq_676m-2.html#bq_676m-3

但是,如果你想制定自己的公式,你可能应该看看教科书或一些关于回归的在线资源。

http://www.edwardtufte.com/tufte/dapp/DAPP3a.pdf

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6796316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档