On Sun, 23 Feb 2003, Ryan Davies wrote:
> Hey Professor King,
>
> I'm a little confused about by the way you define the negative
> binomial distribution in your lecture notes. Sheldon Ross gives
>
> P{X = n} = ((n - 1) choose (r - 1))*p^r*(1-p)^(n-r)
>
> and the intuitive explanation that n is the number of trials of a
> binomial variable until r sucesses are attained. I can't see how this
> is equivalent to the distribution you give in your lecture notes. So I
> was wondering if they are in fact the same and I just can't spot how, or
> if they're different (and if so, why they're called the same thing).
>
> Thanks,
> Ryan
>
its a good question. these distributions can often be used for different
purposes, and Ross gives probably the more common usage, but less useful
for us. what I did in my notes and in my book was to find the mean of the
distribution E(Y) and called that mu and the variance E(Y) and called that
mu*sigma^2. then i set the mean (a function of p,r,n) equal to the mu and
the variance (also a fucntion of p,r,n) equal to mu*sigma^2. then fixing
n, I solved for p and r. finally, i substituted the right side of these
eqns in for p and r, and the result was what I give. (I might have r and
n switched; i don;t have his book in front of me at the moment.) Give it
a try if you have time; this is exactly the kind of thing you will often
need to do if you are trying to adapt a distribution for a new purpose.
Gary
Note that gamma(n)=(n-1)!
Kosuke
On Sat, 22 Feb 2003, David Konisky wrote:
> I believe an equivalent expression is the following: binom <-
> choose(N,y)*pi^y*(1-pi)^(N-y)
>
> Is the gamma in this case the same as factorial?
>
> David
>
> At 08:27 PM 2/22/2003 -0500, Nirmala Ravishankar wrote:
> >Dan,
> >
> >I think you have the formula for the combination wrong. (N y) = N!/(y! *
> >(N-y)!.
> >
> >So in this came, you want something like
> >gamma(n+1)/(gamma(y+1)*gamma(n-y+1).
> >
> >
> >See if this helps...
> >
> >- Nirmala
> >
> >On Sat, 22 Feb 2003 dhopkins(a)fas.harvard.edu wrote:
> >
> > > Dear all,
> > >
> > > I am trying to graph the binomial distribution, and when I run the
> > following:
> > >
> > > binom1 <- (gamma(n+1)/gamma(y+1))*(pi1^(y))*(1-pi1)^(n-y)
> > >
> > > for a short sequence (say, n=2, sequence=0-2), it gives correct values
> > for all
> > > but y=0, which is strangely double what it should be. For instance,
> > >
> > > > pi1 <- .15
> > > > n <- 2
> > > > y<-seq(0,n,1)
> > > > binom1 <- (gamma(n+1)/gamma(y+1))*(pi1^(y))*(1-pi1)^(n-y)
> > > >
> > > > binom1
> > > [1] 1.4450 0.2550 0.0225
> > >
> > > Does anyone have any thoughts as to what I am doing wrong? Does y=0 do
> > > something strange to the factorial terms that I should account for?
> > >
> > > Many thanks.
> > >
> > > Best,
> > > Dan
> > >
> > >
> > >
> > > _______________________________________________
> > > gov2001-l mailing list
> > > gov2001-l(a)fas.harvard.edu
> > > http://www.fas.harvard.edu/mailman/listinfo/gov2001-l
> > >
> >
> >_______________________________________________
> >gov2001-l mailing list
> >gov2001-l(a)fas.harvard.edu
> >http://www.fas.harvard.edu/mailman/listinfo/gov2001-l
>
>
> _______________________________________________
> gov2001-l mailing list
> gov2001-l(a)fas.harvard.edu
> http://www.fas.harvard.edu/mailman/listinfo/gov2001-l
>
I believe an equivalent expression is the following: binom <-
choose(N,y)*pi^y*(1-pi)^(N-y)
Is the gamma in this case the same as factorial?
David
At 08:27 PM 2/22/2003 -0500, Nirmala Ravishankar wrote:
>Dan,
>
>I think you have the formula for the combination wrong. (N y) = N!/(y! *
>(N-y)!.
>
>So in this came, you want something like
>gamma(n+1)/(gamma(y+1)*gamma(n-y+1).
>
>
>See if this helps...
>
>- Nirmala
>
>On Sat, 22 Feb 2003 dhopkins(a)fas.harvard.edu wrote:
>
> > Dear all,
> >
> > I am trying to graph the binomial distribution, and when I run the
> following:
> >
> > binom1 <- (gamma(n+1)/gamma(y+1))*(pi1^(y))*(1-pi1)^(n-y)
> >
> > for a short sequence (say, n=2, sequence=0-2), it gives correct values
> for all
> > but y=0, which is strangely double what it should be. For instance,
> >
> > > pi1 <- .15
> > > n <- 2
> > > y<-seq(0,n,1)
> > > binom1 <- (gamma(n+1)/gamma(y+1))*(pi1^(y))*(1-pi1)^(n-y)
> > >
> > > binom1
> > [1] 1.4450 0.2550 0.0225
> >
> > Does anyone have any thoughts as to what I am doing wrong? Does y=0 do
> > something strange to the factorial terms that I should account for?
> >
> > Many thanks.
> >
> > Best,
> > Dan
> >
> >
> >
> > _______________________________________________
> > gov2001-l mailing list
> > gov2001-l(a)fas.harvard.edu
> > http://www.fas.harvard.edu/mailman/listinfo/gov2001-l
> >
>
>_______________________________________________
>gov2001-l mailing list
>gov2001-l(a)fas.harvard.edu
>http://www.fas.harvard.edu/mailman/listinfo/gov2001-l
Dear all,
I am trying to graph the binomial distribution, and when I run the following:
binom1 <- (gamma(n+1)/gamma(y+1))*(pi1^(y))*(1-pi1)^(n-y)
for a short sequence (say, n=2, sequence=0-2), it gives correct values for all
but y=0, which is strangely double what it should be. For instance,
> pi1 <- .15
> n <- 2
> y<-seq(0,n,1)
> binom1 <- (gamma(n+1)/gamma(y+1))*(pi1^(y))*(1-pi1)^(n-y)
>
> binom1
[1] 1.4450 0.2550 0.0225
Does anyone have any thoughts as to what I am doing wrong? Does y=0 do
something strange to the factorial terms that I should account for?
Many thanks.
Best,
Dan
Hi,
I'm using the following formula to calculate 2(b):
beta <- (gamma(a+b)/gamma(a) * gamma(b))) * y^(a-1) *
(1-i)^(b-1)
where y varies from 0 to 1 in increments of 0.01. I have found
that for the five parametizations described in 2(b), the beta
for y = 0.29 is NA. For some of the specifictions, NA is also
returned for y = 0.58. Clearly, there's something going wrong
here in my program or something...but what??
Thanks,
Olivia
> 1) based on your email about the rt function, I assume that it is also the
> case that we shouldn't use the rbinom function to answer #3b?
Don't use rbinom. Use the function you wrote in 2(c).
>
> 2) for 3a, do you actually want us to write out the normal dist function to
> derive the t distribution, or can we use the rnorm function instead? In
> other words, I know that, in order to simulate the t dist, I need to draw
> variables from a N(0,1), & then use those draws to define the variance of
> the N (0,1/z) sample, which will be my T dist. My question is whether, in
> taking random draws from the N (0,1) and N(0,1/z) distributions, I need to
> write out the formula for a normal & create a continuous range of
> normally-distributed Y values over which the function is defined, or
> whether I can just use the rnorm function for that part.
You can use rnorm for this.
Kosuke
Does anyone know why the fullpage package uses something like a
half inch margin on the top and 1 inch margins on the other
three sides? Is there a command that I can use with the
fullpage package to make the margins 1 inch all around? I want
to avoid setting all the margins maually, which is what I've
been doing...
Thanks, Olivia
You need to change your own printer layout options: some printers do not
allow this option.
Kosuke
On Sat, 22 Feb 2003, Ryan Davies wrote:
> How did you print your lecture notes so that they're four slides to a page, rather than one?
>
> -Ryan
>
This is a multi-part message in MIME format.
------=_NextPart_000_00BA_01C2DA6A.03B705F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Is the beta-binomial distribution built into R, and if so, what's it =
called?
-Ryan
------=_NextPart_000_00BA_01C2DA6A.03B705F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Is the beta-binomial distribution built =
into R, and=20
if so, what's it called?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>-Ryan</FONT></DIV></BODY></HTML>
------=_NextPart_000_00BA_01C2DA6A.03B705F0--
Here are some general comments on Hw1. I hope that they will help you do
better in Hw2.
1. many people got the answers right, but didn't write efficient programs.
You should look at my solution codes and "imitate" their structure etc. In
particular, I noticed the use of unnecessary loops, functions, and
improper indentation for loops and conditional statements.
2. Make sure you answer "all" questions by presenting your simulation
results and some sentences.
3. Don't copy others' answers. You can work in groups, but you have to
write up your own answers (run your own simulations and interpret them).
I will return them on Monday in the lecture.
Kosuke