Title: | Hypothesis Testing Based on R-Size Biased Samples |
---|---|
Description: | Provides functions and examples for testing hypothesis about the population mean and variance on samples drawn by r-size biased sampling schemes. |
Authors: | Dimitrios Bagkavos [aut, cre], Polychronis Economou [aut], Apostolos Batsidis [aut], Gorgios Tzavelas [aut] |
Maintainer: | Dimitrios Bagkavos <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0 |
Built: | 2024-11-28 06:33:37 UTC |
Source: | CRAN |
The function returns the Kullback-Leibler divergence (minus a constant) between the (parametrized with respect to shape and mean or variance) underlying Weibull or gamma distribution and its (assumed) maximum likelihood estimates.
Cond.KL.Weib.Gamma(par,nullvalue,hata,hatb,type,dist)
Cond.KL.Weib.Gamma(par,nullvalue,hata,hatb,type,dist)
par |
The (actual) shape parameter |
nullvalue |
The (actual) distribution mean or variance. |
hata |
Maximum likelihood estimate of the shape parameter of the distribution. |
hatb |
Maximum likelihood estimate of the scale parameter of the distribution. |
type |
Numeric switch, enables the choice of mean or variance: type: 1 for mean, 2 (or any other value != 1) for variance. |
dist |
Character switch, enables the choice of distribution: type "weib" for the Weibull or "gamma" for the gamma distribution. |
The Kullback-Leibler divergence between the Weibull( or the gamma(
and its maximum likelihood estimate Gamma(
is given by
Since is used to determine the closest distribution - given its mean or variance - to the estimated gamma p.d.f., the first four terms are omitted from the function outcome, i.e. the function returns the result of the following quantity:
For the Weibull distribution the corresponding formulas are
and since is used to determine the closest distribution - given its mean or variance - to the estimated gamma p.d.f., the first term is omitted from the function outcome, i.e. the function returns the result of the following quantity:
A scalar, the value of the Kullback-Leibler divergence (minus a constant).
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
#K-L divergence for the Gamma distribution for shape=2 #and variance=3 and their assumed MLE=(1,1): Cond.KL.Weib.Gamma(2,3,1,1,2, "gamma") #K-L divergence for the Weibull distribution for shape=2 #and variance=3 and their assumed MLE=(1,1): Cond.KL.Weib.Gamma(2,3,1,1,2, "weib")
#K-L divergence for the Gamma distribution for shape=2 #and variance=3 and their assumed MLE=(1,1): Cond.KL.Weib.Gamma(2,3,1,1,2, "gamma") #K-L divergence for the Weibull distribution for shape=2 #and variance=3 and their assumed MLE=(1,1): Cond.KL.Weib.Gamma(2,3,1,1,2, "weib")
.Calculates the density of the size biased Weibull distribution.
d_rsize_Weibull(x,TRpar,r)
d_rsize_Weibull(x,TRpar,r)
x |
Grid points where the functional is being calculated. |
TRpar |
A vector of length 2, containing the shape and scale parameters of the distribution. |
r |
The size (order) of the distribution. The special cases |
The size density of the observed biased sample
is defined by
where is the density of the Weibull distribution and
the vector of the shape and scale parameters of the distribution.
A vector of length equal to the length of .
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
p_rsize_Weibull
, r_rsize_Weibull
# example of r-size Weibull distribution, r=0,1,2 x<- seq(0, 10, length=50) dens.0.size<-d_rsize_Weibull(x,c(2,3),0) dens.1.size<-d_rsize_Weibull(x,c(2,3),1) dens.2.size<-d_rsize_Weibull(x,c(2,3),2) plot(x, dens.0.size, type="l", ylab="r-denisty") lines(x, dens.1.size, col=2) lines(x, dens.2.size, col=3) legend("topright",legend=c("r= 0","r= 1","r= 2"), col=c("black","red","green"),lty=c(1,1,1))
# example of r-size Weibull distribution, r=0,1,2 x<- seq(0, 10, length=50) dens.0.size<-d_rsize_Weibull(x,c(2,3),0) dens.1.size<-d_rsize_Weibull(x,c(2,3),1) dens.2.size<-d_rsize_Weibull(x,c(2,3),2) plot(x, dens.0.size, type="l", ylab="r-denisty") lines(x, dens.1.size, col=2) lines(x, dens.2.size, col=3) legend("topright",legend=c("r= 0","r= 1","r= 2"), col=c("black","red","green"),lty=c(1,1,1))
Calculates the log-likelihood function of the weighted gamma or Weibull (depends on user input) distribution.
log_Lik_Weib_gamma_weighted(TRpar,datain,r,dist)
log_Lik_Weib_gamma_weighted(TRpar,datain,r,dist)
TRpar |
A vector of length 2, containing the shape and scale parameters of the distribution. |
datain |
The available sample points. |
r |
The size (order) of the distribution. The special cases |
dist |
Character switch, enables the choice of distribution: type "weib" for the Weibull or "gamma" for the gamma distribution. |
The log likelihood function of the weighted gamma distribution is defined by
where is the density of the
size biased gamma distribution. Setting
corresponds to the log likelihood of the Gamma distribution.
In the case of Weibull, the log likelihood is defined by
where is the density of the
size biased Weibull distribution. Setting
corresponds to the log likelihood of the Weibull distribution.
A scalar, the result of the log likelihood calculation.
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
#Log-likelihood for the gamma distribution for true parms=(2,3), r=0: log_Lik_Weib_gamma_weighted(c(2,3), rgamma(100, shape=2, scale=3), 0, "gamma") #Log-likelihood for the Weibull distribution for true parms=(2,3), r=0: log_Lik_Weib_gamma_weighted(c(2,3), rweibull(100, shape=2, scale=3), 0, "weib")
#Log-likelihood for the gamma distribution for true parms=(2,3), r=0: log_Lik_Weib_gamma_weighted(c(2,3), rgamma(100, shape=2, scale=3), 0, "gamma") #Log-likelihood for the Weibull distribution for true parms=(2,3), r=0: log_Lik_Weib_gamma_weighted(c(2,3), rweibull(100, shape=2, scale=3), 0, "weib")
.Calculates the cumulative distribution of the size biased Weibull distribution.
p_rsize_Weibull(q,TRpar,r)
p_rsize_Weibull(q,TRpar,r)
q |
Points where the functional is being calculated. |
TRpar |
A vector of length 2, containing the shape and scale parameters of the distribution. |
r |
The size (order) of the distribution. The special cases |
The size c.d.f. of the Weibull density is defined by
where is a bivariate vector with the the shape and scale of the Weibull distribution.
A vector of length equal to the lemgth of .
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
d_rsize_Weibull
, r_rsize_Weibull
# c.d.f of the r-size Weibull distribution, r=0,1,2 evalutated at a specific point x. x<- 2 dist.0.size<-p_rsize_Weibull(x,c(2,3),0) dist.1.size<-p_rsize_Weibull(x,c(2,3),1) dist.2.size<-p_rsize_Weibull(x,c(2,3),2)
# c.d.f of the r-size Weibull distribution, r=0,1,2 evalutated at a specific point x. x<- 2 dist.0.size<-p_rsize_Weibull(x,c(2,3),0) dist.1.size<-p_rsize_Weibull(x,c(2,3),1) dist.2.size<-p_rsize_Weibull(x,c(2,3),2)
th moment of the gamma or the Weibull distribution.Calculates the th moment of the gamma or Weibull distribution.
r_moment_gamma_Weib(TRpar,r,dist)
r_moment_gamma_Weib(TRpar,r,dist)
TRpar |
A vector of length 2, containing the shape and scale parameters of the distribution. |
r |
The size (order) of the distribution. The special cases |
dist |
Character switch, enables the choice of distribution: type "weib" for the Weibull or "gamma" for the gamma distribution. |
In the case of the distribution the
-th moment is given by
while for the distribution the
-th moment is given by
A scalar, the value of the moment.
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
#r-moment for the Gamma distribution for true parms=(2,3), r=1: r_moment_gamma_Weib(c(2,3),1, "gamma") #r-moment for for the Weibull distribution for true parms=(2,3), r=1: r_moment_gamma_Weib(c(2,3),1, "weib")
#r-moment for the Gamma distribution for true parms=(2,3), r=1: r_moment_gamma_Weib(c(2,3),1, "gamma") #r-moment for for the Weibull distribution for true parms=(2,3), r=1: r_moment_gamma_Weib(c(2,3),1, "weib")
(modified).Provides a random sample of size from the
size biased Weibull distribution (modified).
r_rsize_Weibull(n,TRpar,r)
r_rsize_Weibull(n,TRpar,r)
n |
Number of th sample data points to be provided. |
TRpar |
A vector of length 2, containing the shape and scale parameters of the distribution. |
r |
The size (order) of the distribution. The special cases |
The size random number generator from the Weibull distribution is implemented based on a change-of-variable technique, to the standard gamma distribution as described by Gove and Patil (1998).
A vector of length with the random sample.
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Gove J.H. and Patil G.P. (1998). Modeling the Basal Area-size Distribution of Forest Stands: A Compatible Approach. Forest Science, 44(2), 285-297.
d_rsize_Weibull
, p_rsize_Weibull
#Random number geenration for the r-size Weibull distribution. r_rsize_Weibull(100,c(2,3),1)
#Random number geenration for the r-size Weibull distribution. r_rsize_Weibull(100,c(2,3),1)
specifically for the Weibull and gamma distributions.Variance estimates for test statistics specifically for the Weibull and gamma distributions.
s11.s22(TRpar,r,sgg,dist)
s11.s22(TRpar,r,sgg,dist)
TRpar |
A vector of length 2, containing the shape and scale parameters of the Weibull distribution. |
r |
The size (order) of the distribution. The special cases |
sgg |
Character switch ("s11" or "s22"), enables choosing between the s11 and s22 options |
dist |
Character switch, enables the choice of distribution: type "weib" for the Weibull or "gamma" for the gamma distribution. |
Provided that is the
th moment of the Weibull or the Gamma distribution, then
and
A scalar with the value of the variance estimate for the test statistic.
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
#s11 for the Gamma distribution for true parms=(2,3), r=1: s11.s22(c(2,3),1, "s11", "gamma") #s22 for for the Weibull distribution for true parms=(2,3), r=1: s11.s22(c(2,3),1, "s22", "weib")
#s11 for the Gamma distribution for true parms=(2,3), r=1: s11.s22(c(2,3),1, "s11", "gamma") #s22 for for the Weibull distribution for true parms=(2,3), r=1: s11.s22(c(2,3),1, "s22", "weib")
The function returns the test statistics for testing a null hypothesis for the mean and a null hypothesis for the varaince.
Size.BiasedMV.Tests(datain_r,r,nullMEAN,nullVAR,start_par,nboot,alpha,prior_sel,distr)
Size.BiasedMV.Tests(datain_r,r,nullMEAN,nullVAR,start_par,nboot,alpha,prior_sel,distr)
datain_r |
The available sample points. |
r |
The size (order) of the distribution. The special cases |
nullMEAN |
The null value of the distribution mean. |
nullVAR |
The null value of the distribution variance. |
start_par |
Vector with two values, containing the starting values for the MLE for the two parameter distribution (Weibull or gamma) . |
nboot |
Defines the number of bootstrap replications. |
alpha |
Significance level. |
prior_sel |
"normal" for the normal distribution or "gamma" for the gamma. |
distr |
Character switch, enables the choice of distribution: type "weib" for the Weibull or "gamma" for the gamma distribution. |
The test statistics implemented are given by the Plug-in and the bootstrap Methods as described in section 3.1 and 3.2 of Economou et al (2021).
An object containing the following components.
par |
A vector of the MLE of the distribution parameters. |
loglik |
A scalar, the maximized log-likelihood. |
CovMatrix |
The Variance - Covariance matrix of the MLEs. |
Zeta_i |
A vector of the values of the |
Tivalues |
A vector of the values of the |
T1_bootstrap_quan |
A vector of the bootstrap quantiles for the |
T2_bootstrap_quan |
A vector of the bootstrap quantiles for the |
NullValues |
A vector of the null values of the distribution mean and variance. |
distribution |
Character representing the choice of distribution: "weib" for the Weibull or "gamma" for the gamma distribution. |
alpha |
A vector of significance levels for the test level. |
bootstrap_p_mean |
A scalar with the bootstrap p-value for testing the mean. |
bootstrap_p_var |
A scalar with the bootstrap p-value for testing the variance. |
decision |
A matrix of 0 and 1 of the decisions taken for each one of the significance levels alpha based on the bootstrap method. The first row corresponds to the null hypothesis for the mean and the second to the null hypothesis for the variance. |
asymptotic_p_mean |
A scalar with the asymptotic p-value for testing the mean (if |
asymptotic_p_var |
A scalar with the asymptotic p-value for testing the variance (if |
decisionasympt |
A matrix of 0 and 1 of the decisions taken for each one of the significance levels alpha based on the plug-in method and the asymptotic distribution of the test statistics. The first row corresponds to the null hypothesis for the mean and the second to the null hypothesis for the variance. |
prior_selection |
Character representing the choice of the prior distribution for the bootstrap method: "normal" for the normal distribution or "gamma" for the gamma. |
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
data(ufc) datain_r <- ufc[,4] nullMEAN <- 14 #according to null mean in Sec. 6.3, Economou et. al. (2021). nullVAR <- 180 #according to null variance in Sec. 6.3, Economou et. al. (2021). Size.BiasedMV.Tests(datain_r, 2, nullMEAN, nullVAR, c(2,3), 100, 0.05, "normal", "gamma")
data(ufc) datain_r <- ufc[,4] nullMEAN <- 14 #according to null mean in Sec. 6.3, Economou et. al. (2021). nullVAR <- 180 #according to null variance in Sec. 6.3, Economou et. al. (2021). Size.BiasedMV.Tests(datain_r, 2, nullMEAN, nullVAR, c(2,3), 100, 0.05, "normal", "gamma")
or
depending on user input.The test statistics and
are consistent estimators of the mean value
and variance
respectively given an
size biased sample.
T1T2.Mean.Var(datain,r, type)
T1T2.Mean.Var(datain,r, type)
datain |
The available sample points. |
r |
The size (order) of the distribution. The special cases |
type |
Numeric switch: type =1 corresponds to the T1 statistic while any other numeric value will cause calculation of T2. |
The test statistic is defined by
The test statistic is defined by
A scalar, the value of the test statistic for the given sample.
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
#e.g.: T1T2.Mean.Var(rgamma(100, 2,3),0, 1)
#e.g.: T1T2.Mean.Var(rgamma(100, 2,3),0, 1)
Forest measurement data from the Upper Flat Creek unit of the University of Idaho Experimental Forest, measured in 1991.
ufc
ufc
A data frame with 336 observations on the following 5 variables; plot (plot label), tree (tree label), species (species kbd with levels DF, GF, WC, WL), dbh.cm (tree diameter at 1.37 m. from the ground, measured in centimetres.), height.m (tree height measured in metres).
The inventory was based on variable radius plots with 6.43 sq. m. per ha. BAF (Basal Area Factor). The forest stand was 121.5 ha. This version of the data omits errors, trees with missing heights, and uncommon species. The four species are Douglas-fir, grand fir, western red cedar, and western larch.
Harold Osborne and Ross Appelgren of the University of Idaho Experimental Forest.
Robinson, A.P., and J.D. Hamann. 2010. Forest Analytics with R: an Introduction. Springer.
data(ufc)
data(ufc)
test statistic for the Weibull or the gamma distribution (depending on user input.Studentized version of the test statistic for the Weibull/gamma distribution.
zeta_plug_in(null_value, datain,r,EST_par,type, dist)
zeta_plug_in(null_value, datain,r,EST_par,type, dist)
null_value |
The parameter value in the hypothesis test under the null |
datain |
The available sample points. |
r |
The size (order) of the distribution. The special cases |
EST_par |
A vector of length 2, containing the shape and scale parameters of the Weibull distribution. |
type |
Numeric switch: type =1 returns the |
dist |
Character switch, enables the choice of distribution: type "weib" for the Weibull or "gamma" for the gamma distribution. |
When type
=1 the function returns
after using the fact that under the null we have . Any other value for
type
returns
in which case the fact that var(X) under the null has been used.
A scalar with the value of the test statistic.
Polychronis Economou
R implementation and documentation: Polychronis Economou <[email protected]>
Economou et. al. (2021). Hypothesis testing for the population mean and variance based on r-size biased samples, under review.
data(ufc) datain_r <- ufc[,4] nullMEAN <- 14 # ml estimates = c(2.6555,8.0376), taken from section 6.2 in Economou et. al. (2021). zeta_plug_in(nullMEAN, datain_r, 2, c(2.6555,8.0376),1, "gamma") #corresponds to mean nullVar <- 180 zeta_plug_in(nullVar, datain_r, 2, c(2.6555,8.0376),2, "gamma") #corresponds to var
data(ufc) datain_r <- ufc[,4] nullMEAN <- 14 # ml estimates = c(2.6555,8.0376), taken from section 6.2 in Economou et. al. (2021). zeta_plug_in(nullMEAN, datain_r, 2, c(2.6555,8.0376),1, "gamma") #corresponds to mean nullVar <- 180 zeta_plug_in(nullVar, datain_r, 2, c(2.6555,8.0376),2, "gamma") #corresponds to var