[R] Adding a normal density curve over the empirical curve

Newbie lille_knold at hotmail.com
Thu Aug 25 18:45:54 CEST 2011


Hi

I have created the following plot over the empirical returns.. What I now
want to do is to overlay a curve/line with the normal density as a
comparison of the two. Does anyone know how to do this?
(NB the last two lines are the problem, and are wrong, I know). 

Thank you in advance!
Rikke
http://r.789695.n4.nabble.com/file/n3768783/S%26P_500_spot_and_return_2010.csv
S%26P_500_spot_and_return_2010.csv 

setwd("F:/Data til speciale/")

marketdata <- read.csv(file="S&P 500 spot and return 2010.csv", header=TRUE,
sep=";")
returns <- marketdata[,7]		

### Kernel density estimator ###########################

x <- density (returns)

plot(density(returns), main = "Kernel density")
y <- rnorm(209,mean=0,sd=1)
curve(dnorm(y,mean=mean(normal1),sd=sd(normal1)))

--
View this message in context: http://r.789695.n4.nabble.com/Adding-a-normal-density-curve-over-the-empirical-curve-tp3768783p3768783.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list