I want to test the normality of a statistical exeperience defined by this code.
# a
y0<-50
a<-10
b<-0.4
theta<-4
T<-30
h<-0.01
t<-seq(0,T,h)
n<-length(t)
M<-1000
est<-rep(0,M)
for( j in 1:M)
{
W<-c(0,cumsum(rnorm(n-1,0,1)*sqrt(h)))
y<-rep(y0,n)
for(i in 1:(n-1))
{
y[i+1]<-y[i]+a*t[i]*h-b*y[i]*h+theta*(W[i+1]-W[i])
}
delta<-1/n
X<-y
M<-(a/b)+(X-(a/b))*exp(-b*delta)
est[j]<-sqrt((2*b)/(1-exp(-2*b*delta))*(1/n)*sum(X[2:n]-M[1:(n-1)]))
}
hist(sqrt(n)*(est-theta),nclass = 40,freq = FALSE)
Please note that I do not need to get the line graph of the histogram itself at all. I just need to add other normal distribution to compare it with the histogram. This new normal distribution is defined by:
x<-seq(-1,1,length=1000)
y<-dnorm(x,mean = 0,sd=sqrt(theta^2/2))
lines(x,y)
But I did not get any curve plot added to the graph of the density function defined above.
just I can't get the density distribution
I did understand what's the problem? Thank you for you help!