> I'm no R expert, but I think I can help with this one.

>

> In short, the problem is that you are trying to evaluate dnbinom(x) for x

> not an integer. Well, not you exactly: but the curve function, which

> automatically makes a mesh of rational numbers over which to graph

> dnbinom(x). On my system, the call produces a funny graph (flat with spikes

> at the integers if I jiggle the parameters just right) and produces warnings

> of the form:

>

> " In dnbinom(x, 6, 0.3) : non-integer x = 1.040000 "

>

> which should make the underlying problem pretty clear to you.

>

> One simple work-around, depending on what you want is to call instead:

>

> curve(dnbinom(floor(x),6,0.3)) or curve(dnbinom(ceil(x),6,0.3)) or

> curve(dnbinom(round(x),6,0.3))

>

> which will round all the non-integer calls down/up/nearest to an integer;

> this will produce a graph that I believe gets at what you want.

>

> You'll note that in your code that does work, you only call dnbinom at the

> integers 1,2,...,50.

>

> Depending on how much probability theory you know, you should be careful of

> how you interpret the graph that lines(1:50, dnbinom(1:50, 6, 0.3))

> produces...there's a few knotty technical issues relating to the values of

> the PMF between integers and this graph solves them in one way (linear

> interpolation), but you have to engage the question for yourself before

> making too many inferences. Since this is a somewhat thorny issue, my

> recommendation is that you handle the plot call yourself so you know exactly

> what you are getting.

>

> Hope this helps and good luck getting started with R,

>

> Michael Weylandt

>

>

>

>

>

>

> On Wed, Jul 13, 2011 at 4:05 AM, éç«äº <

[hidden email]> wrote:

>

>> Dear everyone,

>> I want to draw the density lines of the a negative binomial

>> distribution X~Neg(6,0.3). The code lines(1:50, dnbinom(1:50, 6, 0.3)) work,

>> but curve(dnbinom(x, 6, 0.3)) doesn't work, why?

>> Thank you very much!

>> [[alternative HTML version deleted]]

>>

>> _______________________________________________

>>

[hidden email] mailing list

>>

https://stat.ethz.ch/mailman/listinfo/r-sig-finance>> -- Subscriber-posting only. If you want to post, subscribe first.

>> -- Also note that this is not the r-help list where general R questions

>> should go.

>>

>

>