Dear mailing list,
I desperately need help on making a small program that is trying to find the
likelihood of a distribution. Anyone that has any ideas please feel free to
suggest them.
Ok this is what I have done so far:
I wanted 20 random numbers that were normally distributed, and I did this by
typing x<-rnorm(20).
I then wanted to change any negative values in the data set to zero and I
did this by x[x<0]<-0.
These numbers have come from the normal density
1/sigma(2pi)1/2exp-{(x-mew)2/2sigma2}, what I want to do now and having
trouble with is that for each of these results (which can be substituted back
into the x in the eqation above) is to multiply all 20 results (in the above
equation form) together to form the likelihood. However the critical problem
that I am experiencing is that for each case I do not know the mew and sigma
eventhough that i know tthe x value. The reason why i dont know the values of
sigma and mew is because after I have formed the program i want to use nlmin(
, ) to basically maximse the the likelihood so i find the values for mew
and sigma, this is what i am aiming finally to do.
My pathetic effort so far is:
prod(dnorm(x,mean=mu,sd=sigma)
However I know that this doesn''t incorporate the fact that mew and
sigma are
not known as when i input this it says that mu is not recognised but I dont
know how to make mu and sigma different to each other.
If anyone has any ideas please feel free to suggest them as I will basically
try anything.
Yours Faithfully,
James Hutton
[[alternate HTML version deleted]]