[R-br] Erro no ajuste usando nls()
Elias Teixeira Krainski
eliaskrainski em yahoo.com.br
Sexta Fevereiro 12 06:47:56 BRST 2016
Mesmos resultados com Matlab R2015b:
>> mc'
ans =
Columns 1 through 17
8.2834 7.7900 7.3243 7.8408 6.9411 8.0788 7.5859
8.5045 7.7377 7.6300 7.4584 8.3254 8.4231 9.2183
8.4298 8.1621 7.7530
Columns 18 through 34
8.5202 7.5397 8.4437 8.5259 8.5115 8.6919 7.8751
8.7256 8.4112 8.4320 8.0465 8.0767 7.6655 6.8035
7.0164 8.7062 7.7244
Columns 35 through 51
6.8070 6.9982 7.3664 7.2780 7.9291 7.8874 7.5017
6.7873 7.0532 7.3677 7.2136 7.2331 6.5543 7.7349
7.4804 7.8031 8.5610
Columns 52 through 68
7.7096 7.2965 7.4251 7.5591 7.4227 7.7352 7.4859
7.5243 7.4444 6.5160 6.2838 7.3013 6.7309 7.1362
6.7886 7.4702 7.3704
Columns 69 through 85
7.1180 7.1678 7.5752 7.1045 7.3966 7.1747 7.2116
7.4036 6.9948 7.1491 7.6249 6.7693 7.0764 7.1518
7.1104 7.7013 7.0376
Columns 86 through 102
6.8196 7.1667 7.5509 7.1804 6.8358 7.5356 6.3120
5.8329 5.8187 6.8354 6.5233 6.1144 7.1026 6.9876
5.8963 6.6491 6.1090
Columns 103 through 112
6.5956 6.6286 6.3461 6.5980 5.7874 6.3855 6.7979
6.1270 6.7997 6.4785
>> x'
ans =
Columns 1 through 29
269 270 271 272 273 274 275 276 277 278 279
280 281 282 283 284 285 286 287 288 289 290 291
292 293 294 295 296 297
Columns 30 through 58
298 299 300 301 302 303 304 305 306 307 308
309 310 311 312 313 314 315 316 317 318 319 320
321 322 323 324 325 326
Columns 59 through 87
327 328 329 330 331 332 333 334 335 336 337
338 339 340 341 342 343 344 345 346 347 348 349
350 351 352 353 354 355
Columns 88 through 112
356 357 358 359 360 361 362 363 364 365 366
367 368 369 370 371 372 373 374 375 376 377 378
379 380
>> myfun = 'mc ~ 9.548 - b1 * (x - 268)^b2';
>> b0 = [1;1];
>> mnl = fitnlm(x, mc, myfun, b0);
>> mnl
mnl =
Nonlinear regression model:
mc ~ 9.548 - b1*(x - 268)^b2
Estimated Coefficients:
Estimate SE tStat pValue
________ ________ ______ __________
b1 0.66888 0.10226 6.5412 1.9908e-09
b2 0.30739 0.036839 8.3441 2.3263e-13
Number of observations: 112, Error degrees of freedom: 110
Root Mean Squared Error: 0.541
R-Squared: 0.432, Adjusted R-Squared 0.427
F-statistic vs. zero model: 1.04e+04, p-value = 5.23e-126
>>
>> model2 = 'mc ~ b1 - b2 * (x - 268)^b3';
>> ini2 = [8;0;1.4];
>> mnl2 = fitnlm(x, mc, model2, ini2);
Warning: Rank deficient, rank = 2, tol = 1.038937e-10.
> In nlinfit>LMfit (line 574)
In nlinfit (line 276)
In NonLinearModel/fitter (line 1123)
In classreg.regr.FitObject/doFit (line 220)
In NonLinearModel.fit (line 1430)
In fitnlm (line 94)
>> mnl2
mnl2 =
Nonlinear regression model:
mc ~ b1 - b2*(x - 268)^b3
Estimated Coefficients:
Estimate SE tStat pValue
_________ _________ _______ __________
b1 8.0691 0.13723 58.802 2.1409e-84
b2 0.0021746 0.0035616 0.61058 0.54275
b3 1.4158 0.34368 4.1196 7.4165e-05
Number of observations: 112, Error degrees of freedom: 109
Root Mean Squared Error: 0.49
R-Squared: 0.537, Adjusted R-Squared 0.528
F-statistic vs. constant model: 63.2, p-value = 6e-19
>>
Mais detalhes sobre a lista de discussão R-br