| 10 | 1/1 | 返回列表 |
| 查看: 6310 | 回復(fù): 9 | ||||
古道西風(fēng)11新蟲 (初入文壇)
|
[求助]
求助 用matlab擬合三元線性回歸方程及分析
|
|
用matlab擬合三元線性回歸方程,我自己弄了一個(gè)如下 x1=[23.00 23.00 23.00 23.00 23.00 28.00 28.00 28.00 28.00 28.00]'; x2=[0.30 0.30 0.30 0.30 0.30 0.10 0.10 0.10 0.10 0.10]'; x3=[0.00 0.69 1.09 1.38 1.61 0.00 0.69 1.09 1.38 1.61]'; y=[-0.91 -0.35 -0.05 0.15 0.29 -0.58 -0.04 0.23 0.41 0.54]; x=[ones(10,1) x1 x2 x3]; >> [b,bint,r,rint,stats]=regress(y,x); ??? Error using ==> or Matrix dimensions must agree. Error in ==> regress at 70 wasnan = (isnan(y) | any(isnan(X),2)); >> b,bint,stats,rcoplot(r,rint) b = 0 -0.0115 -1.7878 0.6751 bint = 0 0 -0.0168 -0.0062 -2.2782 -1.2973 0.5701 0.7800 stats = 0.9747 134.6812 0.0000 0.0059 問題: 1.我編寫的程序?qū)幔?br /> 2.輸入程序中,總是會出現(xiàn)warning的那段文字,不知道怎么修改? |
榮譽(yù)版主 (著名寫手)
彩色掛圖
![]() |
專家經(jīng)驗(yàn): +2 |

新蟲 (初入文壇)
|
請問y寫成列向量后又出現(xiàn)問題了,這是怎么回事啊?? >> x1=[23.00 23.00 23.00 23.00 23.00 28.00 28.00 28.00 28.00 28.00]'; x2=[0.30 0.30 0.30 0.30 0.30 0.10 0.10 0.10 0.10 0.10]'; x3=[0.00 0.69 1.09 1.38 1.61 0.00 0.69 1.09 1.38 1.61]'; >> y=[-0.91 -0.35 -0.05 0.15 0.29 -0.58 -0.04 0.23 0.41 0.54]; >> x=[ones(10,1) x1 x2 x3]; >> [b,bint,r,rint,stats]=regress(y,x); Warning: X is rank deficient to within machine precision. > In regress at 82 >> b,bint,stats,rcoplot(r,rint) |
榮譽(yù)版主 (著名寫手)
彩色掛圖
![]() |
專家經(jīng)驗(yàn): +2 |
|
Most likely you have too many predictor variables, and too few observations. As an alaogy, imagine trying to fit a cubic polynomial regression with only two observations. REGRESS will make a choise about which coefficients to set to zero, but it can't possibly know what you really want. 變量太多,你可以試一下,分別使用x(:,1:2), x(:,1:3), x(:,2:3)算一下,使用3列時(shí)總會出現(xiàn)一個(gè)b=0。 |

新蟲 (初入文壇)
榮譽(yù)版主 (著名寫手)
彩色掛圖
![]() |
專家經(jīng)驗(yàn): +2 |
|
上面那樣的就可以了。問題是你的x的第2列和第3列,也就是x1和x2在回歸計(jì)算時(shí)有問題,所以matlab默認(rèn)把常數(shù)項(xiàng)b(1)為零。 你可以把x1改成另外的一系列數(shù)試試,或者把x1刪掉,或者再做多組(x1,x2,x3,y)的數(shù)據(jù)用作回歸。 |

新蟲 (初入文壇)
|
本帖內(nèi)容被屏蔽 |
金蟲 (小有名氣)
|
迭代數(shù): 33 計(jì)算用時(shí)(時(shí):分:秒:微秒): 00:00:00:241 優(yōu)化算法: 麥夸特法(Levenberg-Marquardt) + 通用全局優(yōu)化法 計(jì)算結(jié)束原因: 達(dá)到收斂判斷標(biāo)準(zhǔn) 均方差(RMSE): 0.0274286872091944 殘差平方和(SSE): 0.00752332882019822 相關(guān)系數(shù)(R): 0.998018933040592 相關(guān)系數(shù)之平方(R^2): 0.996041790707481 決定系數(shù)(DC): 0.996041790707481 卡方系數(shù)(Chi-Square): -0.0155244265746169 F統(tǒng)計(jì)(F-Statistic): 2013.11596653563 參數(shù) 最佳估算 ---------- ------------- a -37.3038021226221 b -934.025053065556 c 0.724150995543315 d 1137.33012469023 ====== 結(jié)果輸出 ===== No 實(shí)測值y 計(jì)算值y 1 -0.91 -0.8648400 2 -0.35 -0.3651759 3 -0.05 -0.0755155 4 0.15 0.1344883 5 0.29 0.3010431 6 -0.58 -0.5788400 7 -0.04 -0.0791759 8 0.23 0.2104845 9 0.41 0.4204883 10 0.54 0.5870431 |
| 10 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 材料專碩調(diào)劑 +11 | 椰椰。 2026-03-29 | 11/550 |
|
|---|---|---|---|---|
|
[考研] 262求調(diào)劑 +4 | ZZ..000 2026-03-30 | 4/200 |
|
|
[考研] 材料與化工272求調(diào)劑 +21 | 阿斯蒂芬2004 2026-03-28 | 21/1050 |
|
|
[考研] 282求調(diào)劑 +4 | wcq131415 2026-03-24 | 4/200 |
|
|
[考研] 085404求調(diào)劑,總分309,本科經(jīng)歷較為豐富 +6 | 來財(cái)aa 2026-03-25 | 6/300 |
|
|
[考研] 085600,材料與化工321分求調(diào)劑 +10 | 大饞小子 2026-03-28 | 10/500 |
|
|
[考研] 求調(diào)劑 +4 | QiMing7 2026-03-25 | 5/250 |
|
|
[考研] 311求調(diào)劑 +6 | 冬十三 2026-03-24 | 6/300 |
|
|
[考研] 349求調(diào)劑 +6 | 李木子啊哈哈 2026-03-25 | 6/300 |
|
|
[考研] 298求調(diào)劑 +3 | 種圣賜 2026-03-29 | 3/150 |
|
|
[考研] 070300求調(diào)劑306分 +4 | 26要上岸 2026-03-27 | 4/200 |
|
|
[考研] 265求調(diào)劑11408 +3 | 劉小鹿lu 2026-03-27 | 3/150 |
|
|
[考研] 一志愿上海理工能源動力(085800)310分求調(diào)劑 +3 | zhangmingc 2026-03-27 | 4/200 |
|
|
[考研] 292求調(diào)劑 +4 | 求求了收下我吧?/a> 2026-03-26 | 4/200 |
|
|
[考研] 0703化學(xué)338求調(diào)劑! +6 | Zuhui0306 2026-03-26 | 7/350 |
|
|
[考研] 機(jī)械學(xué)碩310分,數(shù)一英一,一志愿211本科雙非找調(diào)劑信息 +3 | @357 2026-03-25 | 3/150 |
|
|
[考研] 打過很多競賽,085406控制工程300分,求調(diào)劑 +3 | askeladz 2026-03-26 | 3/150 |
|
|
[考研] 生物學(xué)學(xué)碩求調(diào)劑 +7 | 小羊睡著了? 2026-03-23 | 10/500 |
|
|
[考研] 一志愿北化315 求調(diào)劑 +3 | akrrain 2026-03-24 | 3/150 |
|
|
[考研] 277分求調(diào)劑,跨調(diào)材料 +3 | 考研調(diào)劑lxh 2026-03-24 | 3/150 |
|