Skip to content
Prev 383247 / 398502 Next

Add Gauss normal curve ?

On 4/11/20 7:00 AM, varin sacha via R-help wrote:
(I infer) The values in the `nc` vector are not taken from observations 
that are interpretable as independent sampling from a continuous random 
vector. They are counts, i.e. "new cases".


Furthermore, the "x" value in your plot is not the `nc` vector but 
rather it is the the ""y"-vector, so even if it were appropriate to use 
a Normal curve for fitting you would need to take the `nc` vector as 
corresponding to a density along the time axis.

You could probably do as well by "eyeballing" where you want the 
"normal" curve to sit, since there would be no theoretical support for 
more refined curve fitting efforts. You might also need to scale the 
density values so they would appear as something other than a flat line.

And the `curve` function does need an expression but it would be 
plotting that result far to the left of your current plotting range 
which is set by the integer values of those dates, i.e values in the 
tens of thousands. Use the `lines` function for better control.


lines( x= as.numeric(mydates),

 ? ? ? ? ? ? ? ? ? # 3000 was eyeball guess as to a scaling factor that 
might work

 ????????????????? # but needed a larger number to make the curves 
commensurate

 ?????? y=10000* dnorm( x= as.numeric(mydates),? #set a proper x scale

 ??????????????? ? ? ?? mean= as.numeric( mydates[ which.max(nc) ]),? 
#use location of max

 ???????????????? ? ? ? sd= 7) )


Might need to use smaller value for the "standard deviation" and higher 
scaling factor to improve the eyeball fit.You might like a value of 
sd=4, but it would remain an unsupportable effort from a statistical 
viewpoint.