Michael,
It's not entirely clear what you are doing from the text (and the code is
incompplete), so just a few remarks.
I assume you are after the log likelihood rather than the likelihood
(otherwise the issue of positive/negative would not show up, dnorm always
returns positive numbers).
Taking the sum of log's is not the same as taking the log of a sum:
> sum(log(1:10))
[1] 15.10441> log(sum(1:10))
[1] 4.007333>
Positive log likelihoods are not problematic; as you note, when variances
are small, log likelihoods may turn positive; this does not change the use
of the log likelihood (eg using it for estimating parameters by maximizing
it, or for testing models).
hth, Ingmar
On Wed, Apr 20, 2011 at 4:13 AM, Turchin, Michael <
Michael.Turchin@childrens.harvard.edu> wrote:
> Hi all,
>
> I'll preface this with saying I've gone through the archives, and
am still
> in need of some help.
>
> I've been using this likelihood model with mean = 0 and s.d. = sqrt( (c
+ (
> 1 / N1 ) + ( 1 / N2 ) ) * x * ( 1 - x )), where c is a genetic drift
> parameter (usually very small, like between .005 - .001), N1 and N2 are my
> population sizes (~200), and x is a value between 0 and 1. The values
I'm
> testing are usually between -.25 to .25, so my command looks like
>
> dnorm(.1, 0, sqrt( (c + ( 1 / N1 ) + ( 1 / N2 ) ) * x * ( 1 - x )))
>
> Originally, I was doing this over multiple data points at once, summing up
> the values I was going to test and their variances, and just running the
> likelihood on these summed values once (getting one final likelihood in
> return). I've recently switched this over to running the likelihood on
each
> data point and its associated variance one at a time, and summing the
> likelihoods afterwards. However, upon doing this, I'm now getting
positive
> likelihoods since the individual variances are so small (.01 to .09, for
> instance). I'm not sure what to do, because I think these small
variances
> are messing up the behavior of my final data -- the patterns I'm
getting are
> not what I expected, whereas my previous method of summing multiple data
> points and just taking one likelihood value did return what I expected.
>
> I'm not sure if getting positive likelihoods somewhat implies that the
> behavior of the model / results are off. Should I be using a different
> function than dnorm, now that my variances are so small? Using pnorm
instead
> returns my data to what's expected, but my understanding is that pnorm
gets
> me a probability now, not a likelihood. Could I use the output from pnorm
in
> a likelihood ratio test (which was my original plan)?
>
> Thanks for any help,
> ~Michael Turchin
> Children's Hospital Boston
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]