1
我使用mdl = NonLinearModel.fit來擬合非線性模型。 如何從結果中獲得F統計量和p值(行:「F統計量與常量模型」)?如何在MATLAB中使用非線性模型獲得f-統計量,p值2013a
示例代碼:
load carsmall
X = Weight;
y = MPG;
modelfun = 'y ~ b1 + b2*exp(-b3*x/1000)';
beta0 = [1 1 1];
mdl=NonLinearModel.fit(X,y,modelfun,beta0)
產生如下:
mdl =
Nonlinear regression model:
y ~ b1 + b2*exp(- b3*x/1000)
Estimated Coefficients:
Estimate SE tStat pValue
________ _______ ________ __________
b1 -17.725 31.321 -0.56594 0.57283
b2 77.862 21.332 3.6499 0.00043735
b3 0.21775 0.17176 1.2677 0.20814
Number of observations: 94, Error degrees of freedom: 91
Root Mean Squared Error: 4.12
R-Squared: 0.743, Adjusted R-Squared 0.738
F-statistic vs. constant model: 132, p-value = 1.34e-27
看吧: http://mathworks.com/help/stats/nonlinearmodel.coeftest.html#zmw57dd0e119263 然而,當我做'[P,F] = coefTest(MDL)'在你的榜樣,我得到顯示模型時報告的不同p值和F值。另外,不允許使用'fTest(mdl)',儘管'NonLinearModel'類具有'fTest'方法。我想它是受保護的或無法訪問的。 要使用在鏈接頁面中看到的公式手動計算它,您需要知道v(公式中的C,H和beta-hat是已知的)。我不知道如何計算訴 – Erik
嗨,埃裏克,謝謝你通過這些! 我試過類似的東西給你的建議,也找不到解決方案。 我想我可以複製fTest和所有調用另一個函數的私有方法,但是我將不得不復制很多東西。 – theoddquestion