Learn R Programming

fitODBOD (version 1.5.3)

fitBetaBin: Fitting the Beta-Binomial Distribution when binomial random variable, frequency and shape parameters a and b are given

Description

The function will fit the Beta-Binomial distribution when random variables, corresponding frequencies and shape parameters are given. It will provide the expected frequencies, chi-squared test statistics value, p value, degree of freedom and over dispersion value so that it can be seen if this distribution fits the data.

Usage

fitBetaBin(x,obs.freq,a,b)

Value

The output of fitBetaBin gives the class format fitBB and fit consisting a list

bin.ran.var binomial random variables.

obs.freq corresponding observed frequencies.

exp.freq corresponding expected frequencies.

statistic chi-squared test statistics.

df degree of freedom.

p.value probability value by chi-squared test statistic.

fitBB fitted values of dBetaBin.

NegLL Negative Log Likelihood value.

a estimated value for alpha parameter as a.

b estimated value for alpha parameter as b.

AIC AIC value.

over.dis.para over dispersion value.

call the inputs of the function.

Methods summary, print, AIC, residuals and fitted can be used to extract specific outputs.

Arguments

x

vector of binomial random variables.

obs.freq

vector of frequencies.

a

single value for shape parameter alpha representing as a.

b

single value for shape parameter beta representing as b.

Details

$$0 < a,b$$ $$x = 0,1,2,...,n$$ $$obs.freq \ge 0$$

NOTE : If input parameters are not in given domain conditions necessary error messages will be provided to go further.

References

young2008poolingfitODBOD trenkler1996continuousfitODBOD hughes1993usingfitODBOD

See Also

mle2

Examples

Run this code
No.D.D <- 0:7    #assigning the random variables
Obs.fre.1 <- c(47,54,43,40,40,41,39,95)  #assigning the corresponding frequencies

#estimating the parameters using maximum log likelihood value and assigning it
parameters <- EstMLEBetaBin(No.D.D,Obs.fre.1,0.1,0.1)

bbmle::coef(parameters)   #extracting the parameters a and b
aBetaBin <- bbmle::coef(parameters)[1]  #assigning the parameter a
bBetaBin <- bbmle::coef(parameters)[2]  #assigning the parameter b

#fitting when the random variable,frequencies,shape parameter values are given.
fitBetaBin(No.D.D,Obs.fre.1,aBetaBin,bBetaBin)

#estimating the parameters using moment generating function methods
results <- EstMGFBetaBin(No.D.D,Obs.fre.1)
results

aBetaBin1 <- results$a  #assigning the estimated a
bBetaBin1 <- results$b  #assigning the estimated b

#fitting when the random variable,frequencies,shape parameter values are given.
BB <- fitBetaBin(No.D.D,Obs.fre.1,aBetaBin1,bBetaBin1)

#extracting the expected frequencies
fitted(BB)

#extracting the residuals
residuals(BB)

Run the code above in your browser using DataLab