|
|
楼主

楼主 |
发表于 2009-11-27 13:58:42
|
只看该作者
怎样用做logistic生长曲线编程?
请教各位:我最近在作关于牛的生长曲线拟合,在编程遇到了点困难,下面是我的程序,在parms k0=300 a0=0 b0=0最初值是怎样确定的?程序最后不明白,比较着急,请大家批评指正。谢谢
data nlindata;
input days weight @@;
cards;
843 388
819 359
876 321
844 271
967 369
896 363
904 350
800 387
829 342
935 312
909 321
879 365
918 398
943 394
940 332
551 231
527 252
568 270
613 187
482 264
452 213
470 221
544 193
516 350
458 378
460 271
540 289
88 117
108 127
179 138
81 125
150 154
173 130
182 122
885 342
849 281
873 315
1003 282
862 297
951 360
932 337
886 262
861 258
960 481
890 291
912 255
883 315
948 283
873 334
901 276
902 439
891 370
938 347
792 439
857 374
477 166
455 192
505 215
496 236
446 288
582 376
576 311
581 323
178 158
175 144
215 176
75 67
90 56
148 119
232 236
202 142
123 120
909 550
955 368
890 342
934 367
976 349
853 453
483 208
533 246
574 231
476 347
545 269
566 274
967 387
975 405
591 313
469 192
483 242
542 323
608 304
597 316
;
proc nlin data=nlindata;
parms k0=300 a0=0 b0=0;
model weight=k0/(1+a0*exp(-b0*days));
output out=save1 sse=se predicted=pweight residual=rweight;
proc print data=save1;
proc plot data=save1;
plot weight*days='*' pweight*days='.' /overlay;
proc means data=nlindata noprint css;
var weight;
output out=save2 css=cs;
data _null_;
set save1(obs=1);
set save2(obs=1);
rsq=1-se/cs;
file print;
put // +10 '非线性模型的拟合度定义为:1-sse/css' /
+10 'sse为离回归平方和' /
+10 'css为总平方和' //
+10 '拟合度(R^2)=' +5 rsq 8.6;
run;
*********************下面是运行结果********************************
The SAS System 08:25 Tuesday, November 27, 2001 117
Non-Linear Least Squares Iterative Phase Dependent Variable WEIGHT Method:
Gauss-Newton
Iter K0 A0 B0 Sum of Squares
0 300.000000 0 0 884765
1 300.000000 0.056051 0 858825
2 300.000000 0.716038 0.018338 783988
3 300.913145 0.369400 0.008840 735004
4 304.849066 0.354172 0.001995 642725
5 422.532647 1.858386 0.003294 474842
6 385.991354 2.899735 0.003846 278195
7 383.475486 3.443275 0.004004 270538
8 383.391734 3.509034 0.004012 270442
9 383.428116 3.508924 0.004011 270442
10 383.428282 3.508941 0.004011 270442
NOTE: Convergence criterion met.
Non-Linear Least Squares Summary Statistics Dependent Variable WEIGHT
Source DF Sum of Squares Mean Square
Regression 3 7966123.1667 2655374.3889
Residual 89 270441.8333 3038.6723
Uncorrected Total 92 8236565.0000
(Corrected Total) 91 858751.8587
Parameter Estimate Asymptotic Asymptotic 95 %
Std. Error Confidence Interval
Lower Upper
K0 383.4282819 23.659221275 336.41768702 430.43887679
A0 3.5089408 0.726921249 2.06455677 4.95332475
B0 0.0040110 0.000770209 0.00248063 0.00554142
Asymptotic Correlation Matrix
Corr K0 A0 B0
儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍儍
K0 1 -0.336162344 -0.862339023
A0 -0.336162344 1 0.7117473824
B0 -0.862339023 0.7117473824 1
The SAS System 08:25 Tuesday, November 27, 2001 118
OBS DAYS WEIGHT PWEIGHT RWEIGHT SE
1 843 388 342.556 45.444 270441.83
2 819 359 338.905 20.095 270441.83
3 876 321 347.144 -26.144 270441.83
4 844 271 342.702 -71.702 270441.83
5 967 369 357.489 11.511 270441.83
6 896 363 349.695 13.305 270441.83
7 904 350 350.669 -0.669 270441.83
8 800 387 335.817 51.183 270441.83
9 829 342 340.460 1.540 270441.83
10 935 312 354.207 -42.207 270441.83
11 909 321 351.265 -30.265 270441.83
12 879 365 347.537 17.463 270441.83
13 918 398 352.313 45.687 270441.83
14 943 394 355.062 38.938 270441.83
15 940 332 354.744 -22.744 270441.83
16 551 231 276.863 -45.863 270441.83
17 527 252 269.299 -17.299 270441.83
18 568 270 282.029 -12.029 270441.83
19 613 187 294.909 -107.909 270441.83
20 482 264 254.325 9.675 270441.83
21 452 213 243.827 -30.827 270441.83
22 470 221 250.171 -29.171 270441.83
23 544 193 274.689 -81.689 270441.83
24 516 350 265.731 84.269 270441.83
25 458 378 245.956 132.044 270441.83
26 460 271 246.663 24.337 270441.83
27 540 289 273.435 15.565 270441.83
28 88 117 110.646 6.354 270441.83
29 108 127 117.066 9.934 270441.83
30 179 138 141.411 -3.411 270441.83
31 81 125 108.449 16.551 270441.83
32 150 154 131.196 22.804 270441.83
33 173 130 139.270 -9.270 270441.83
34 182 122 142.487 -20.487 270441.83
35 885 342 348.312 -6.312 270441.83
36 849 281 343.426 -62.426 270441.83
37 873 315 346.746 -31.746 270441.83
38 1003 282 360.771 -78.771 270441.83
39 862 297 345.256 -48.256 270441.83
40 951 360 355.893 4.107 270441.83
41 932 337 353.881 -16.881 270441.83
42 886 262 348.440 -86.440 270441.83
43 861 258 345.118 -87.118 270441.83
44 960 481 356.802 124.198 270441.83
45 890 291 348.947 -57.947 270441.83
46 912 255 351.618 -96.618 270441.83
47 883 315 348.056 -33.056 270441.83
48 948 283 355.584 -72.584 270441.83
49 873 334 346.746 -12.746 270441.83
50 901 276 350.307 -74.307 270441.83
51 902 439 350.428 88.572 270441.83
The SAS System 08:25 Tuesday, November 27, 2001 119
OBS DAYS WEIGHT PWEIGHT RWEIGHT SE
52 891 370 349.072 20.928 270441.83
53 938 347 354.530 -7.530 270441.83
54 792 439 334.463 104.537 270441.83
55 857 374 344.562 29.438 270441.83
56 477 166 252.602 -86.602 270441.83
57 455 192 244.893 -52.893 270441.83
58 505 215 262.102 -47.102 270441.83
59 496 236 259.089 -23.089 270441.83
60 446 288 241.684 46.316 270441.83
61 582 376 286.162 89.838 270441.83
62 576 311 284.404 26.596 270441.83
63 581 323 285.870 37.130 270441.83
64 178 158 141.053 16.947 270441.83
65 175 144 139.982 4.018 270441.83
66 215 176 154.525 21.475 270441.83
67 75 67 106.587 -39.587 270441.83
68 90 56 111.278 -55.278 270441.83
69 148 119 130.504 -11.504 270441.83
70 232 236 160.855 75.145 270441.83
71 202 142 149.740 -7.740 270441.83
72 123 120 122.015 -2.015 270441.83
73 909 550 351.265 198.735 270441.83
74 955 368 356.300 11.700 270441.83
75 890 342 348.947 -6.947 270441.83
76 934 367 354.099 12.901 270441.83
77 976 349 358.349 -9.349 270441.83
78 853 453 343.998 109.002 270441.83
79 483 208 254.668 -46.668 270441.83
80 533 246 271.219 -25.219 270441.83
81 574 231 283.814 -52.814 270441.83
82 476 347 252.256 94.744 270441.83
83 545 269 275.001 -6.001 270441.83
84 566 274 281.430 -7.430 270441.83
85 967 387 357.489 29.511 270441.83
86 975 405 358.254 46.746 270441.83
87 591 313 288.759 24.241 270441.83
88 469 192 249.822 -57.822 270441.83
89 483 242 254.668 -12.668 270441.83
90 542 323 274.063 48.937 270441.83
91 608 304 293.536 10.464 270441.83
92 597 316 290.464 25.536 270441.83
The SAS System 08:25 Tuesday, November 27, 2001 120
Plot of WEIGHT*DAYS. Symbol used is '*'.
Plot of PWEIGHT*DAYS. Symbol used is '.'.
WEIGHT ?
600 ?
?
?
? *
?
?
?
500 ?
? *
?
? *
? * *
?
?
400 ? * * *
? * * *
? * * * * * **
? * * *...*. .
? * ..*...*. ** *
? * * . * *
? *** ** **
300 ? * *
? * * ... * * * *
? * ..*.* * *
? .*. * * * *
? * ...** *
? **
? ****
200 ? *
? ** *
? * *
? ** ..
? ***
? * *...**
? * .**
100 ? .
?
? *
? *
?
?
?
0 ?
妰儓儍儍儍儍儍儍儓儍儍儍儍儍儍儓儍儍儍儍儍儍儓儍儍儍儍儍儍儓儍儍儍儍儍儍儓儍
0 200 400 600 800 1000
DAYS
NOTE: 67 obs hidden.
The SAS System 08:25 Tuesday, November 27, 2001 121
非线性模型的拟合度定义为:1-sse/css
sse为离回归平方和
css为总平方和
拟合度(R^2)= 0.685076 |
|