数学建模社区-数学中国

标题: 多元回归用matlab怎么算 [打印本页]

作者: wxkdesky    时间: 2012-8-27 16:46
标题: 多元回归用matlab怎么算
多元回归用matlab怎么算呀?不会,有没有示例程序呀?包括求参数,求残差,求置信区间,最后怎么检验?
作者: HNzhangjie    时间: 2012-8-27 17:17
额   我也需要
作者: hzs2012    时间: 2012-8-27 19:23
给个实例,好点儿。。。意思是给个题目
作者: hzs2012    时间: 2012-8-27 19:46
不需要例子的话,直接百度、google就好了。很多很多
作者: liwenhui    时间: 2012-8-27 19:58
本帖最后由 liwenhui 于 2012-8-31 23:35 编辑

使用函数,regress(),具体调用方式见matlab的帮助。
  1. regress Multiple linear regression using least squares.
  2.     B = regress(Y,X) returns the vector B of regression coefficients in the
  3.     linear model Y = X*B.  X is an n-by-p design matrix, with rows
  4.     corresponding to observations and columns to predictor variables.  Y is
  5.     an n-by-1 vector of response observations.

  6.     [B,BINT] = regress(Y,X) returns a matrix BINT of 95% confidence
  7.     intervals for B.

  8.     [B,BINT,R] = regress(Y,X) returns a vector R of residuals.

  9.     [B,BINT,R,RINT] = regress(Y,X) returns a matrix RINT of intervals that
  10.     can be used to diagnose outliers.  If RINT(i,:) does not contain zero,
  11.     then the i-th residual is larger than would be expected, at the 5%
  12.     significance level.  This is evidence that the I-th observation is an
  13.     outlier.

  14.     [B,BINT,R,RINT,STATS] = regress(Y,X) returns a vector STATS containing, in
  15.     the following order, the R-square statistic, the F statistic and p value
  16.     for the full model, and an estimate of the error variance.

  17.     [...] = regress(Y,X,ALPHA) uses a 100*(1-ALPHA)% confidence level to
  18.     compute BINT, and a (100*ALPHA)% significance level to compute RINT.

  19.     X should include a column of ones so that the model contains a constant
  20.     term.  The F statistic and p value are computed under the assumption
  21.     that the model contains a constant term, and they are not correct for
  22.     models without a constant.  The R-square value is one minus the ratio of
  23.     the error sum of squares to the total sum of squares.  This value can
  24.     be negative for models without a constant, which indicates that the
  25.     model is not appropriate for the data.

  26.     If columns of X are linearly dependent, regress sets the maximum
  27.     possible number of elements of B to zero to obtain a "basic solution",
  28.     and returns zeros in elements of BINT corresponding to the zero
  29.     elements of B.

  30.     regress treats NaNs in X or Y as missing values, and removes them.
复制代码

作者: 秋leaves    时间: 2012-8-28 10:16
liwenhui 发表于 2012-8-27 19:58
使用函数,regress(),具体调用方式见matlab的帮助。

regress Multiple linear regression using least  ...

果断有道翻译了一下
作者: 傻人招    时间: 2012-8-31 23:04
数据输入:x1=[1000 600 1200 500 300 400 1300 1100 1300 300]; x2=[5 7 6 6 8 7 5 4 3 9]; y=[100 75 80 70 50 65 90 100 110 60];x=[x1' x2'];回归、检验、预测:rstool(x,y,'purequadratic')   之后得到一个交互画面,给出两幅图形,左边是x2固定时的曲线y(x1)及其置信区间,右边是x1固定时的曲线y(x2)及其置信区间。假如X1为平均收入,x2为价格,y为商品需求量,改变X1或者X2,画面左边的‘predicted y’下方的数据就为对应的y值。  在画面左下方的下拉式菜单中选‘all’,则beta、rmse和residuals都传送到matlab工作区中,在matlab工作区中输入命令 beta,rmse就能得到结果了·~
作者: 蓝枫心叶    时间: 2012-9-1 09:02
呵呵,要是楼上的把它变成图文形式就更好了。。。




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5