Type: | Package |
Title: | Estimation and Testing of Hypothesis |
Version: | 0.1.0 |
Description: | A collection of functions to do some statistical inferences. On estimation, it has the function to get the method of moments estimates, the sampling interval. In terms of testing it has function of doing most powerful test. |
Imports: | actuar, VGAM |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
VignetteBuilder: | knitr |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-08-01 04:45:34 UTC; PRODUYMNA |
Author: | Produymna Ghose Majumdar [aut, cre], Sangbartta Banerjee [aut] |
Maintainer: | Produymna Ghose Majumdar <ghosemajumdarproduymna@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-08-19 15:20:08 UTC |
Method of Moments Estimation of Beta distribution
Description
function to get the method of moment estimate(s) of beta distribution
Usage
beta_est(
data,
unknown = c("shape1", "shape2", "both"),
shape1 = NULL,
shape2 = NULL,
plot = TRUE,
curvecol = "red",
...
)
Arguments
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
shape1 , shape2 |
Non-negative parameters of the Beta distribution. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical beta distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is beta distribution
Examples
beta_est(rbeta(1000,shape1=2,shape2=1),unknown="shape2",shape1=2)#shape1 is known
beta_est(rbeta(1000,shape1=2,shape2=1),unknown="shape1",shape2=1)#shape2 is known
beta_est(rbeta(1000,shape1=2,shape2=1),unknown="both")#both will be estimated
Method of Moments Estimation of Binomial distribution
Description
function to get the method of moment estimate(s) of binomial distribution
Usage
binom_est(
data,
size.known = FALSE,
size = NULL,
plot = TRUE,
curvecol = "red",
...
)
Arguments
data |
A numeric vector. |
size.known |
logical indicating whether the size of the binomial distribution is known or not. |
size |
integer valued parameter of binomial distribution. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical binomial distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is binomial distribution
Examples
binom_est(rbinom(1000,size=5,prob=0.2),size.known=TRUE,size=5)#no of trials known
binom_est(rbinom(1000,size=10,prob=0.6))
Method of Moments Estimation of Chi-Square distribution
Description
function to get the method of moment estimate(s) of chi-square distribution
Usage
chisq_est(data, plot = TRUE, curvecol = "red", ...)
Arguments
data |
A numeric vector. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical chi square distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
Value
the estimated degree of freedom by the method of moments of the data assuming the underlying distribution is chi square distribution
Examples
chisq_est(rchisq(1000,df=3))
Method of Moments Estimation of Exponential Distribution
Description
function to get the method of moment estimate of exponential distribution
Usage
exp_est(data, plot = TRUE, curvecol = "red", ...)
Arguments
data |
An object of numeric vector. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical exponential distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
Value
the estimated positive rate parameter by the method of moments of the data assuming the underlying distribution is exponential distribution
Examples
exp_est(rexp(1000,rate=0.1))
Method of Moments Estimation of Gamma distribution
Description
function to get the method of moment estimate(s) of gamma distribution
Usage
gamma_est(
data,
unknown = c("shape", "scale", "both"),
shape = NULL,
scale = NULL,
plot = TRUE,
curvecol = "red",
...
)
Arguments
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
shape , scale |
positive shape and scale parameters of the gamma distribution. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical gamma distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is gamma distribution
Examples
gamma_est(rgamma(1000,shape=2,scale=1),unknown="scale",shape=2)#shape is known
gamma_est(rgamma(1000,shape=2,scale=1),unknown="shape",scale=1)#scale is known
gamma_est(rgamma(1000,shape=2,scale=1),unknown="both")#both will be estimated
Method of Moments Estimation of Negative Binomial distribution
Description
function to get the method of moment estimate(s) of negative binomial distribution
Usage
geom_est(data, plot = TRUE, curvecol = "red", ...)
Arguments
data |
A numeric vector. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical negative binomial distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is geometric distribution
Examples
geom_est(rgeom(1000,prob=0.2))
Method of Moments Estimation of Log-Normal distribution
Description
function to get the method of moment estimate(s) of log-normal distribution
Usage
lnorm_est(
data,
unknown = c("meanlog", "sdlog", "both"),
meanlog = NULL,
sdlog = NULL,
plot = TRUE,
curvecol = "red",
...
)
Arguments
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
meanlog , sdlog |
mean and standard deviation of the distribution on the log scale. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical log normal distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is log normal distribution
Examples
lnorm_est(rlnorm(1000),unknown="meanlog",sdlog=1)#meanlog unknown, but sdlog known
lnorm_est(rlnorm(1000),unknown="sdlog",meanlog=0)#sdlog unknown, but meanlog known
lnorm_est(rlnorm(1000),unknown="both")#both will be estimated
Method of Moments Estimation of Logarithmic distribution
Description
function to get the method of moment estimate(s) of logarithmic distribution
Usage
logarithmic_est(data, plot = TRUE, curvecol = "red", ...)
Arguments
data |
A numeric vector. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical poisson distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is logarithmic distribution
Examples
require(actuar)
logarithmic_est(rlogarithmic(1000,prob=0.6))
A object structure of class momint
Description
A object structure of class momint
Usage
momint(dist, pop.par, FUN, n, conf.coeff, c)
Arguments
dist |
The parent population distribution |
pop.par |
The value of the population parameters |
FUN |
The statistic as a function of random data |
n |
sample size |
conf.coeff |
The confidence coefficient of the sampling interval |
c |
the interval |
Value
It doesn't return anything directly, it is used to print the output of another function
A structure of class momtest
Description
A structure of class momtest
Usage
momtest(
data,
null.dist,
null.par,
alter.dist,
alter.par,
n,
conf.level,
d,
power
)
Arguments
data |
A numeric vector |
null.dist |
The family of null distribution |
null.par |
The parameter values of the null distribution |
alter.dist |
The family of alternative distribution |
alter.par |
The parameter values of the alternative distribution |
n |
sample size |
conf.level |
The level of significance of the test |
d |
decision |
Value
It doesn't return anything directly, it just used as output of the testing in this package
Method of Moments Estimation of Negative Binomial distribution
Description
function to get the method of moment estimate(s) of negative binomial distribution
Usage
nbinom_est(
data,
size.known = FALSE,
size = NULL,
plot = TRUE,
curvecol = "red",
...
)
Arguments
data |
A numeric vector. |
size.known |
logical indicating whether the size of the binomial distribution is known or not. |
size |
integer valued parameter of binomial distribution. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical negative binomial distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is negative binomial distribution
Examples
nbinom_est(rnbinom(1000,size=5,prob=0.2),size.known=TRUE,size=5)#no of successes known
nbinom_est(rnbinom(1000,size=10,prob=0.6))
Method of Moments Estimation of Normal distribution
Description
function to get the method of moment estimate(s) of normal distribution
Usage
norm_est(
data,
unknown = c("mean", "sd", "both"),
mean = NULL,
sd = NULL,
plot = TRUE,
curvecol = "red",
...
)
Arguments
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
mean , sd |
mean and standard deviation of the distribution of the normal distribution, sd must be strictly positive. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical normal distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is normal distribution
Examples
norm_est(rnorm(1000),unknown="mean",sd=1)#mean unknown, but sd known
norm_est(rnorm(1000),unknown="sd",mean=0)#sd unknown, but mean known
norm_est(rnorm(1000),unknown="both")#both will be estimated
Method of Moments Estimation of Poisson distribution
Description
function to get the method of moment estimate(s) of poisson distribution
Usage
pois_est(data, plot = TRUE, curvecol = "red", ...)
Arguments
data |
A numeric vector. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical poisson distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
Value
the estimated parameters by the method of moments of the data assuming the underlying distribution is poisson distribution
Examples
pois_est(data=rpois(1000,lambda=2),plot=TRUE)
pois_est(data=rpois(1000,lambda=0.2),plot=FALSE)#will not give the plot
Most Powerful Test by Neyman-Pearson Lemma
Description
It can be used to check whether a data comes from null distribution or from the alternative distribution
Usage
sim_mp_test(
data,
null.dist = c("uniform", "normal", "lognormal", "gamma", "cauchy", "pareto", "weibull",
"rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial",
"geometric", "t", "f", "logarithmic"),
null.par,
alter.dist = c("uniform", "normal", "lognormal", "gamma", "cauchy", "pareto",
"weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial",
"geometric", "t", "f", "logarithmic"),
alter.par,
test.level = 0.95,
sim.size = 1,
power = TRUE
)
Arguments
data |
A numeric vector |
null.dist |
The family of null distribution |
null.par |
The parameter values of the null distribution |
alter.dist |
The family of alternative distribution |
alter.par |
The parameter values of the alternative distribution |
test.level |
The level of significance of the test |
sim.size |
simulation size, increasing it will gives more accuracy. |
power |
A loogical vector, whether power of the test will be calculated. |
Details
This function mainly test whether data comes from the null distribution or alternative distribution. It uses the theory of the Most Powerful (MP) test. It basically uses simulation to get the p value and make the decision. Increasing sim.size give more accuracy as well as test can be failed if you increase it heavily.
Value
A list of class "momtest"
will be returned having the following components:
- Method
The Method's Name
- Data
The first 6 elements of input data
- Null.Distrbution
The family of null distribution
- Null.Parameter
The parameter values of the null distribution
- Alternative.Distrbution
The family of alternative distribution
- Alternative.Parameter
The parameter values of the alternative distribution
- Sample.Size
The sample size
- Significance.level
The level of the significance of the test
- Decision
The Test Result, wheter the null hypotheis is rejected or not
- Power
Power of the Test
Examples
sim_mp_test(rnorm(100),null.dist="normal",null.par=c(0,1),alter.dist="cauchy",alter.par=c(0,1))
sim_mp_test(rnorm(100),null.dist="nor",null.par=c(2,1),alter.dist="nor",alter.par=c(0,1))
Simulated confidence interval of a statistic
Description
A function that returns a sampling interval for a statistic formed from random sample of certain probability distributions. The function generates the confidence interval using Monte Carlo simulations. The results might be unreliable if the resulting statistic has fat tailed distribution.
Usage
sim_sam_int(
dist = c("normal", "lognormal", "gamma", "chisquare", "cauchy", "pareto", "weibull",
"rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial",
"geometric", "t", "f", "uniform"),
pop.par,
FUN,
side = c("lower", "upper", "both"),
conf.coeff = 0.95,
range = 1,
n = 100,
sim.size = 1000
)
Arguments
dist |
The parent population distribution |
pop.par |
The value of the population parameters |
FUN |
The statistic as a function of random data |
side |
The type of the confidence interval (both sided, only lower bound or only upper bound) |
conf.coeff |
The confidence coefficient of the sampling interval |
range |
It controls the length of the interval in which the boundary points are searched for. One may increase the range in case the distribution of statistic is suspected to be fat tailed. |
n |
sample size |
sim.size |
simulation size, increasing it will gives more accuracy. |
Details
The function asks the user to specify a distribution from which random sample is drawn and to specify a function of the random variables for which an approximate sampling Interval is to be provided. The function then uses Monte Carlo simulation technique to provide an approximate sampling interval of the statistic. This function might be useful when the sampling distribution for a particular statistic is unknown, but that statistic might be useful in drawing meaningful inference. Although this function is inferior to other sophisticated techniques to deal with this problem, it might come handy for a beginner.
Value
A list of class "momint"
will be returned having the following components:
- Method
The Method's Name
- Population.Distrbution
The family of population distribution
- Paramater
The parameter values of the population distribution
- Statistic
The function of which the interval will be provided
- Sample.Size
The sample size
- Confidence.Coefficient
The confidence coefficient of the sampling interval
- Sampling.Interval
The estimated sampling interval
Examples
sim_sam_int(dist="normal",pop.par=c(0,1),FUN=mean,side="both")
sim_sam_int(dist="binomial",pop.par=c(5,0.5),FUN=sum,side="lower")