Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: finding a peak in an asymmetric curve


From   "Maarten Buis" <M.Buis@fsw.vu.nl>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: finding a peak in an asymmetric curve
Date   Tue, 11 Apr 2006 12:01:46 +0200

Yoshiro Nagao:

You are asking for the mode of x, but the mode is hard to find in your case since x appears to be a continuous variable in your dataset. What is the most common value of a variable if all values are unique? However, you could smooth the distribution of x (using -kdensity-) and the value of x with the highest density would be a good guess of the mode. Bootstrap this if you want to know confidence intervals, standard errors, etc., like the example below. The "modes" in this program might depend on the halfwidth used in smoothing and the number of points on which the kernel density is evaluated (options n and width of -kdensity-). I have just used the defaults and leave it to you to make sure your results are robust for changes in these parameters.

HTH,
Maarten

*---------------------begin example-------------------
clear

input x        y
0.001	51.50260873
0.002	97.07276611
0.004	172.6656633
0.01	307.1488228
0.015	351.7068487
0.018	361.1290563
0.02	362.5851013
0.022	361.1579356
0.025	355.0243609
0.026936	349.2274688
0.03015	337.5129189
0.031578	331.7415732
0.034031	321.3389083
0.034865	317.7105064
0.037063	308.0381902
0.037358	306.7342402
0.037467	306.2523588
0.037474	306.2214115
0.038027	303.776684
0.038251	302.7867493
0.038585	301.311442
0.039193	298.6293865
0.039494	297.3038676
0.039935	295.3652685
0.040106	294.6148147
0.040191	294.2420642
0.040219	294.1193181
0.040488	292.9411912
0.040816	291.5075608
0.041131	290.1339949
0.041507	288.4989377
0.041591	288.1343652
0.041876	286.8994377
0.04228	285.1544511
0.04258	283.8631282
0.043052	281.8395817
0.043103	281.6215528
0.043225	281.1004946
0.043279	280.8700899
0.043478	280.0222289
0.043663	279.2357696
0.043929	278.1079959
0.044	277.8075879
0.044154	277.1569019
0.044216	276.8952895
0.044303	276.5285322
0.044435	275.9728462
0.044584	275.3467259
0.044585	275.3425278
0.044728	274.7427697
0.045133	273.0503312
0.045152	272.9711602
0.045487	271.5786566
0.045712	270.6470581
0.046434	267.6780716
0.046449	267.616725
0.047472	263.4661057
0.047808	262.1174236
0.047822	262.0613878
0.048543	259.1929745
0.048582	259.0388008
0.048648	258.7781234
0.048672	258.683404
0.048733	258.4428326
0.048899	257.7894298
0.048979	257.4752003
0.049285	256.2772735
0.049458	255.6028341
end

capture program drop mode
program define mode, rclass
	tempvar xx sx mis dmode
	quietly {
		kdensity x, nograph generate(`xx' `sx')
		gen `mis' = missing(`sx')
		sort `mis' `sx'
		by `mis': gen double `dmode' = `xx'[_N]
		return scalar mode = `dmode'
	}
end

bootstrap "mode" r(mode), reps(1000)
*---------------------end example--------------------



-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Yoshiro Nagao
Sent: dinsdag 11 april 2006 10:18
To: statalist@hsphsun2.harvard.edu
Subject: st: finding a peak in an asymmetric curve

Are there any statistical method
to find the value of x for the peak,
and show its "significance"?

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index