I am using a textfile with 364 rows as the following:
/first column bar number,second column counts,these are results of an
experiment in radioactive
measurements /
x y
1 84
2 77
3 87
4 56
5 69
6 57
7 67
8 40
9 46
....
....
I know the result of our measurement if I fit the following function
f(x) = a1*exp(-((x-a3)/a2)^2) + a4*exp(-((x-a6)/a5)^2) , using x-column
and y-column above :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
results from fitting with f(x) above using LevenbergMarquard ::
a1=~ 1138 a2= ~2.82 a3 = ~3.49 a4 = ~80.53 a5 = ~2.88 a6 = ~7.99
varianz of fit about ~0.148,because it isn't perfect Poisson-Statistik
if I had perfect PoissonStatistik it would be in borders of : 0.925 to
1.075
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
but I don't get it by Stata.
I can't reach it by varying the parameters.
are there other possibilities to reach the aim.?
thank you very much for help
Andreas
Here's the most important from the result-window :
. do doubleGau� ' name of do-file
. capture program drop nlexample
. program nlexample
1. version 8
2. if "`1'" == "?" {
3. global S_1 "a1 a2 a3 a4 a5 a6"
4. global a1 = 1131
5. global a2 = 1
6. global a3 = 1
7. global a4 = 1
8. global a5 = 1
9. global a6 = 1
10. exit
11. }
12. replace `1' = $a1*exp(-((x-$a2)/$a3)^2) + $a4*exp(-((x-$a5)/$a6)^2)
13. end
. twoway line y x
. nl example y
(obs = 364)
Iteration 0: residual SS = 5.70e+07
Iteration 1: residual SS = 5.58e+07
Iteration 2: residual SS = 3.35e+07
Iteration 3: residual SS = 3.32e+07
Iteration 4: residual SS = 3.32e+07
Iteration 5: residual SS = 3.32e+07
Iteration 6: residual SS = 3.32e+07
Iteration 7: residual SS = 3.32e+07
Iteration 8: residual SS = 3.32e+07
Iteration 9: residual SS = 3.32e+07
.....................
Iteration 77: residual SS = 1.48e+07
Iteration 78: residual SS = 1.29e+07
Iteration 79: residual SS = 2023443
Iteration 80: residual SS = 315738.2
Iteration 81: residual SS = 288846.4
Iteration 82: residual SS = 288838.4
Source | SS df MS Number of
obs = 364
-------------+------------------------------ F( 2, 361)
= 25371.18
Model | 40599291 2 20299645.5 Prob > F =
0.0000
Residual | 288838.388 361 800.106339 R-squared =
0.9929
-------------+------------------------------ Adj R-squared
= 0.9929
Total | 40888129.4 363 112639.475 Root MSE =
28.28615
Res. dev. =
3463.222
(example)
----------------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95%
Conf.
Interval]
-------------+--------------------------------------------------------------------------
a1 | -76051.86 . . .
. .
a2 | -132556.8 . . .
. .
a3 | -11881.27 . . .
. .
a4 | 1131.814 5.267092 214.88 0.000 1121.456
1142.173
a5 | 70.13886 .1312605 534.35 0.000 69.88072
70.39699
a6 | 34.55454 .1859685 185.81 0.000 34.18882
34.92026
------------------------------------------------------------------------------
* Parameter a3 taken as constant term in model & ANOVA table
(SEs, P values, CIs, and correlations are asymptotic approximations)
.
end of do-file
--
NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse f�r Mail, Message, More! +++
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/