Skip to content
Back to formatted view

Raw Message

Message-ID: <20121004200304.24981.49852@home>
Date: 2012-10-04T20:03:04Z
From: Joseph Tannhuber
Subject: extract fit values from geom_smooth

Dear all,

I have a plot with two gaussian distributions:

ggplot( tofdf, aes( x = tof, y = counts ) ) +
geom_histogram( stat = "identity", position = "stack", fill = 2 ) +
geom_smooth( method = "nls", formula = y ~ (a/b)*exp(-(x-c)^2/(2*b^2)) + 
           (d/e)*exp(-(x-f)^2/(2*e^2)), se=F,
           start=list(a=100, b=1, c=695, d=100, e=1, f=710),
           control=nls.control(tol=1E-5, minFactor=1/1024),
           n = 1000 )

Now I would like to extract some values for further calculations. These are:
1st: mean of the two gauss fits ( c and f )
2nd: ?3 sigma integral of the two gaussians
3rd: minimum between the two gaussians

How can I extract these values from the geom_smooth function?
And is there an easy way to find the minimum?

Thanks in advance
Joseph