[R] normalmixEM does not produce the same results when run twice using the same data.
John Sorkin
JSorkin at grecc.umaryland.edu
Thu Jan 1 05:52:21 CET 2015
Windows 7
I am running normalmixEM to fit two normal curves to my data. For some reason, that I don't understand, the results of running the function twice, on the same data, results in two different (although similar) sets of values. I would expect the function run twice on the same data would give exactly the same results!
I ran the program below and got the following results:
lambda1 mu1 lambda1 lambda2 lambda2 mu2
0.5030387 31.5172824 0.5030387 0.4969613 0.4969613 104.9249404
> run2
lambda1 mu1 lambda1 lambda2 lambda2 mu2
0.5030406 31.5174149 0.5030406 0.4969594 0.4969594 104.9251556
#Define data
John<-c(9.181 ,9.464 ,9.464 ,10.265 ,11.477 ,11.477 ,11.477 ,12.361,
12.361 ,12.361 ,12.361 ,12.985 ,12.985 ,13.384 ,13.384 ,13.962,
14.517 ,14.698 ,14.698 ,14.698 ,14.698 ,15.398 ,15.398 ,16.231,
16.231 ,16.552 ,16.552 ,16.711 ,16.711 ,17.481 ,17.481 ,17.481,
17.927 ,18.506 ,18.506 ,18.928 ,18.928 ,18.928 ,19.612 ,19.612,
19.745 ,19.745 ,20.530 ,20.530 ,21.162 ,21.162 ,21.162 ,21.162,
21.162 ,21.776 ,21.776 ,22.607 ,22.607 ,22.723 ,22.954 ,23.408,
23.632 ,25.353 ,25.353 ,25.663 ,25.663 ,25.663 ,25.969 ,26.171,
26.171 ,26.171 ,26.768 ,27.544 ,27.640 ,27.640 ,27.735 ,28.761,
29.215 ,29.840 ,30.190 ,30.881 ,30.881 ,31.220 ,31.220 ,31.220,
31.888 ,31.888 ,32.135 ,32.461 ,32.461 ,32.623 ,33.104 ,34.123,
35.855 ,35.928 ,35.928 ,36.293 ,36.293 ,37.012 ,37.366 ,37.366,
37.366 ,37.647 ,37.850 ,37.856 ,37.856 ,38.202 ,38.202 ,38.954,
39.021 ,39.089 ,39.089 ,39.223 ,39.491 ,39.624 ,40.153 ,40.609,
40.868 ,41.380 ,41.380 ,42.200 ,42.324 ,42.324 ,42.324 ,43.126,
43.853 ,43.853 ,44.152 ,44.568 ,45.213 ,45.446 ,45.562 ,46.193,
46.193 ,46.421 ,47.320 ,48.203 ,48.257 ,49.284 ,49.656 ,50.550,
50.550 ,51.938 ,52.342 ,52.342 ,52.342 ,52.393 ,53.586 ,53.733,
54.560 ,55.184 ,55.280 ,56.691 ,57.384 ,57.384 ,57.522 ,59.856,
59.856 ,60.599 ,61.975 ,65.004 ,68.861 ,69.052 ,69.811 ,70.897,
71.267 ,71.489 ,73.056 ,74.485 ,74.732 ,75.189 ,76.439 ,77.126,
77.670 ,77.975 ,78.514 ,80.338 ,80.600 ,83.173 ,83.205 ,83.553,
84.181 ,84.960 ,86.160 ,86.405 ,86.618 ,87.646 ,89.284 ,89.401,
89.989 ,90.456 ,90.892 ,90.892 ,90.950 ,91.412 ,91.729 ,92.072,
92.273 ,92.330 ,92.529 ,92.870 ,93.661 ,94.194 ,94.640 ,94.807,
95.029 ,95.112 ,95.885 ,96.132 ,96.869 ,97.438 ,97.600 ,98.567,
99.020 ,99.020 ,99.127 ,100.683 ,100.683 ,101.231 ,102.266 ,102.498,
102.883 ,103.113 ,103.291 ,103.800 ,103.927 ,104.332 ,104.685 ,104.685,
104.710 ,105.911 ,106.333 ,107.073 ,107.123 ,107.172 ,107.172 ,107.907,
107.907 ,108.272 ,108.272 ,108.345 ,108.564 ,108.758 ,109.338 ,110.201,
110.201 ,110.559 ,111.130 ,111.438 ,111.556 ,112.004 ,112.004 ,112.004,
112.684 ,112.940 ,112.940 ,113.034 ,113.661 ,113.661 ,113.962 ,113.985,
114.031 ,114.607 ,114.607 ,114.768 ,115.249 ,115.797 ,116.069 ,116.160,
117.041 ,117.154 ,117.983 ,118.473 ,118.473 ,118.495 ,118.495 ,118.762,
119.027 ,120.501 ,120.959 ,122.000 ,122.022 ,123.396 ,123.609 ,123.737,
124.035 ,124.416 ,124.818 ,124.881 ,124.881 ,125.071 ,125.387 ,125.576,
127.636 ,128.089 ,128.233 ,132.675 ,133.566 ,134.509 ,134.666 ,135.037,
135.504 ,136.589 ,138.675 ,141.961 ,144.608 ,155.222 ,158.646 ,168.502)
# First run of normalmixEM
mixmdl = normalmixEM(John)
run1<-c(lambda1=mixmdl$lambda[1],mu1=mixmdl$mu[1],lambda=mixmdl$lambda,lambda2=mixmdl$lambda[2],mu2=mixmdl$mu[2])
#Second run of normalmixEM
mixmdl = normalmixEM(John)
# Results are not the same!
run2<-c(lambda1=mixmdl$lambda[1],mu1=mixmdl$mu[1],lambda=mixmdl$lambda,lambda2=mixmdl$lambda[2],mu2=mixmdl$mu[2])
run1
run2
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
More information about the R-help
mailing list