Title: | Mean and Scale-Factor Modeling of Under- And Over-Dispersed Binary Data |
---|---|
Description: | Under- and over-dispersed binary data are modeled using an extended Poisson process model (EPPM) appropriate for binary data. A feature of the model is that the under-dispersion relative to the binomial distribution only needs to be greater than zero, but the over-dispersion is restricted compared to other distributional models such as the beta and correlated binomials. Because of this, the examples focus on under-dispersed data and how, in combination with the beta or correlated distributions, flexible models can be fitted to data displaying both under- and over-dispersion. Using Generalized Linear Model (GLM) terminology, the functions utilize linear predictors for the probability of success and scale-factor with various link functions for p, and log link for scale-factor, to fit a variety of models relevant to areas such as bioassay. Details of the EPPM are in Faddy and Smith (2012) <doi:10.1002/bimj.201100214> and Smith and Faddy (2019) <doi:10.18637/jss.v090.i08>. |
Authors: | David M. Smith [aut, cre], Malcolm J. Faddy [aut] |
Maintainer: | David M. Smith <[email protected]> |
License: | GPL-2 |
Version: | 3.0 |
Built: | 2024-12-02 06:39:47 UTC |
Source: | CRAN |
Under- and over-dispersed binary data are modeled using an extended Poisson process model (EPPM) appropriate for binary data. A feature of the model is that the under-dispersion relative to the binomial distribution only needs to be greater than zero, but the over-dispersion is restricted compared to other distributional models such as the beta and correlated binomials. Because of this, the examples focus on under-dispersed data and how, in combination with the beta or correlated distributions, flexible models can be fitted to data displaying both under- and over-dispersion. Using Generalized Linear Model (GLM) terminology, the functions utilize linear predictors for the probability of success and scale-factor with various link functions for p, and log link for scale-factor, to fit a variety of models relevant to areas such as bioassay. Details of the EPPM are in Faddy and Smith (2012) and Smith and Faddy (2019). Two important changes from version 2.3 are the change to scale-factor rather than variance modeling, and the inclusion of a vignette.
Index of help topics:
BBprob Calculation of vector of probabilities for the beta binomial distribution. Berkshires.litters The data are of the number of male piglets born in litters of varying sizes for the Berkshire breed of pigs. BinaryEPPM Fitting of EPPM models to binary data. BinaryEPPM-package Mean and Scale-Factor Modeling of Under- And Over-Dispersed Binary Data CBprob Calculation of vector of probabilities for the correlated binomial distribution. EPPMprob Calculation of vector of probabilities for a extended Poisson process model (EPPM). GBprob Calculation of vector of probabilities for the EPPM binomial distribution. KupperHaseman.case Kupper and Haseman example data LL.Regression.Binary Function called by optim to calculate the log likelihood from the probabilities and hence perform the fitting of regression models to the binary data. LL.gradient Function used to calculate the first derivatives of the log likelihood with respect to the model parameters. Model.BCBinProb Probabilities for beta and correlated binomial distributions given p's and scale-factors. Model.Binary Function for obtaining output from distributional models. Model.GB Probabilities for binomial and EPPM extended binomial distributions given p's and b. Model.JMVGB Probabilities for EPPM extended binomial distributions given p's and scale-factors. Parkes.litters The data are of the number of male piglets born in litters of varying sizes for the Parkes breed of pigs. Yorkshires.litters The data are of the number of male piglets born in litters of varying sizes for the Yorkshire breed of pigs. coef.BinaryEPPM Extraction of model coefficients for BinaryEPPM Objects cooks.distance.BinaryEPPM Cook's distance for BinaryEPPM Objects doubexp Double exponential Link Function doubrecip Double reciprocal Link Function fitted.BinaryEPPM Extraction of fitted values from BinaryEPPM Objects hatvalues.BinaryEPPM Extraction of hat matrix values from BinaryEPPM Objects logLik.BinaryEPPM Extract Log-Likelihood loglog Log-log Link Function negcomplog Negative complementary log-log Link Function plot.BinaryEPPM Diagnostic Plots for BinaryEPPM Objects powerlogit Power Logit Link Function predict.BinaryEPPM Prediction Method for BinaryEPPM Objects print.BinaryEPPM Printing of BinaryEPPM Objects print.summaryBinaryEPPM Printing of summaryBinaryEPPM Objects residuals.BinaryEPPM Residuals for BinaryEPPM Objects ropespores.case Dilution series for the presence of rope spores. ropespores.grouped Dilution series for the presence of rope spores. summary.BinaryEPPM Summary of BinaryEPPM Objects vcov.BinaryEPPM Variance/Covariance Matrix for Coefficients waldtest.BinaryEPPM Wald Test of Nested Models for BinaryEPPM Objects wordcount.case Number of occurences of an article in five-word and ten-word samples from two authors. wordcount.grouped Number of occurences of an article in five-word and ten-word samples from two authors.
Further information is available in the following vignettes:
Vignette_RSP_one.pdf |
Mean and Scale-Factor Modeling of Under- and Overdispersed Grouped Binary Data (source, pdf) |
David M. Smith [aut, cre], Malcolm J. Faddy [aut]
Maintainer: David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
Grun B, Kosmidis I, Zeileis A. (2012). Extended Beta Regression in R: Shaken, Stirred, Mixed, and Partitioned. Journal of Statistical Software, 48(11), 1-25. doi:10.18637/jss.v048.i11.
Smith D, Faddy M. (2019). Mean and Variance Modeling of Under-Dispersed and Over-Dispersed Grouped Binary Data. Journal of Statistical Software, 90(8), 1-20. doi:10.18637/jss.v090.i08.
Zeileis A, Croissant Y. (2010). Extended Model Formulas in R: Multiple Parts and Multiple Responses. Journal of Statistical Software, 34(1), 1-13. doi:10.18637/jss.v034.i01.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') summary(output.fn)
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') summary(output.fn)
Given a vector of parameters and a scalar of the number of trials the function returns a vector of probabilities.
BBprob(twoparameter, nt)
BBprob(twoparameter, nt)
twoparameter |
A vector of the parameters of the beta binomial distribution. |
nt |
The number of trials. |
Vector of probabilities
David M. Smith <[email protected]>
Smith D (1982). Algorithm AS189. Maximum Likelihood Estimation of the Parameters of the Beta Binomial Distribution. Applied Statistics, 32, 196-204.
Williams D (1996). "Overdispersion in Logistic Linear Models." In B Mrgan (ed.), Statistics in Toxicology, pp75-84. Oxford Science Publications.
twoparameter <- c(0.96477815,0.7561417) names(twoparameter) <- c('p','theta') nt <- 37 BBprob(twoparameter,nt)
twoparameter <- c(0.96477815,0.7561417) names(twoparameter) <- c('p','theta') nt <- 37 BBprob(twoparameter,nt)
The data are arranged as a list of binomial frequency distributions where the listing is by litter size which is included both as a variate (vsize) and as a factor (fsize)
data("Berkshires.litters")
data("Berkshires.litters")
The format is: List of 3 $ fsize : Factor w/ 7 levels " size 5"," size 6",..: 1 2 3 4 5 6 7 $ vsize : int [1:7] 5 6 7 8 9 10 11 $ number.success:List of 7 ..$ : num [1:6] 8 29 72 65 40 3 ..$ : num [1:7] 5 22 89 129 74 35 4 ..$ : num [1:8] 1 25 62 131 136 89 26 5 ..$ : num [1:9] 1 15 79 179 219 149 71 33 4 ..$ : num [1:10] 2 6 47 117 172 181 117 40 9 2 ..$ : num [1:11] 2 1 23 65 131 145 120 61 20 3 ... ..$ : num [1:12] 0 3 9 22 53 94 72 54 20 4 ...
Brooks, R.J., James, W.H., Gray, E. (1993). Modelling Sub-Binomial Variation in the Frequency of Sex Combinations in Litters of Pigs. Biometrics 47, 403-417.
data("Berkshires.litters")
data("Berkshires.litters")
Fits regression models to under- and over-dispersed binary data using extended Poisson process models.
BinaryEPPM(formula, data, subset = NULL, na.action = NULL, weights = NULL, model.type = "p only", model.name = "EPPM extended binomial", link = "cloglog", initial = NULL, method = "Nelder-Mead", pseudo.r.squared.type = "square of correlation", control = NULL)
BinaryEPPM(formula, data, subset = NULL, na.action = NULL, weights = NULL, model.type = "p only", model.name = "EPPM extended binomial", link = "cloglog", initial = NULL, method = "Nelder-Mead", pseudo.r.squared.type = "square of correlation", control = NULL)
formula |
Formulae for the probability of a success p and scale-factor. The
object used is from the package |
data |
"data" should be either a data frame (as for use of "glm") or a list. The list should be exactly the same as for a data frame except that the response variable is a list of vectors of frequency distributions rather than a vector of single counts as for the data frame. Only one list is allowed within "data" as it is identified as the dependent variable. If other lists are in "data", for example for use as weights, they should be removed from "data" prior to calling this function. The extracted list can be called using the "weights" argument to this function. Within the function a working list "listcounts" and data frames with components such as "p.obs", "scalef.obs", "covariates", "offset.mean", "offset.variance" are set up . The component "covariates" is a data frame of vectors of covariates in the model. The component "listcounts" is a list of vectors of frequency distributions, or the single pairs of r/n in grouped form if "data" is a data frame. |
subset |
Subsetting commands. |
na.action |
Action taken for NAs in data. |
weights |
Vector of list of lists of weights. |
model.type |
Takes one of two values i.e. "p only" or "p and scale-factor". The "p only" value fits a linear predictor function to the parameter a in equation (3) of Faddy and Smith (2012). If the model type being fitted is binomial, modeling a is the same as modeling the mean. For the negative binomial the mean is b exp(a)-1), b also being as in equation (3) of Faddy and Smith (2012). The "p and scale-factor" value fits linear predictor functions to both the probability of a success p and the scale-factor. |
model.name |
If model.type is "p only" the model being fitted is one of the four "binomial", "EPPM extended binomial", "beta binomial", "correlated binomial". If model.type is "p and scale-factor" the model being fitted is either "EPPM extended binomial" i.e. as equations (4) and (6) of Faddy and Smith (2012) or one of the two "beta binomial", "correlated binomial". |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
initial |
This is a vector of initial values for the parameters. If this vector is NULL then initial values based on a fitting binomial models using "glm" are calculated within the function. |
method |
Takes one of the two values "Nelder-Mead" or "BFGS" these
being arguments of |
pseudo.r.squared.type |
Takes one of the three values "square of correlation", "R square" or "max-rescaled R square". The "default" is as used in Cribari-Neto and Zeileis (2010) and is the square of the correlation between the observed and predicted values on the GLM linear predictor scale. The other two are as described in Cox and Snell (1989), and Nagelkerke (1991) and apply to logistic regression. |
control |
"control" is a list of control parameters as used in "optim". If this list is NULL the defaults for "optim" are set as "control <- list(fnscale=-1, trace=0, maxit=1000)". The control parameters that can be changed by inputting a variable length list are "fnscale, trace, maxit, abstol, reltol, alpha, beta, gamma". Details of "optim" and its control parameters are available in the online R help manuals. |
An object of class "BinaryEPMM" is returned. A list of object items follows.
data.type |
The type of the data i.e., data frame or list |
list.data |
Data as a list of lists of frequency distributions |
call |
The call of the function |
formula |
The formula argument |
model.type |
The type of model being fitted |
model.name |
The model being fitted |
link |
The link function |
covariates.matrix.p |
The design matrix for the probability of a success |
covariates.matrix.scalef |
The design matrix for the scalefactor |
offset.p |
The offset vector for the probability of a success |
offset.scalef |
The offset vector for the scalefactor |
coefficients |
Estimates of model parameters |
loglikelihood |
Loglikelihood |
vcov |
The variance/covariance matrix |
n |
The number of observations |
nobs |
The number of observations |
df.null |
The degrees of freedom of the null model |
df.residual |
The degrees of freedom of the residual |
vnmax |
Vector of maximums of grouped count data vectors in list.counts |
weights |
Vector or list of weights |
converged |
Whether the iterative process converged, TRUE or FALSE |
iterations |
Number of iterations taken |
method |
Method for optim either Nelder-Mead or BFGS |
pseudo.r.squared |
Pseudo R**2 value |
start |
Starting values for iterative process |
optim |
Estimates of model parameters |
control |
Control parameters for |
fitted.values |
Fitted values for probability of success |
y |
Dependent variable |
terms |
Terms in model fitted |
David M. Smith <[email protected]>
Cox DR, Snell EJ. (1989). Analysis of Binary Data. Second Edition. Chapman & Hall.
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
Grun B, Kosmidis I, Zeileis A. (2012). Extended Beta Regression in R: Shaken, Stirred, Mixed, and Partitioned. Journal of Statistical Software, 48(11), 1-25. doi:10.18637/jss.v048.i11.
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
Nagelkerke NJD. (1991). A Note on a General Definition of the Coefficient of Determination. Biometrika, 78, 691-692.
Smith D, Faddy M. (2019). Mean and Variance Modeling of Under-Dispersed and Over-Dispersed Grouped Binary Data. Journal of Statistical Software, 90(8), 1-20. doi:10.18637/jss.v090.i08.
Zeileis A, Croissant Y. (2010). Extended Model Formulas in R: Multiple Parts and Multiple Responses. Journal of Statistical Software, 34(1), 1-13. doi:10.18637/jss.v034.i01.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = "p only", model.name = "binomial") summary(output.fn)
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = "p only", model.name = "binomial") summary(output.fn)
Given a vector of parameters and a scalar of the number of trials the function returns a vector of probabilities.
CBprob(twoparameter, nt)
CBprob(twoparameter, nt)
twoparameter |
A vector of the parameters of the correlated binomial distribution. |
nt |
The number of trials. |
Vector of probabilities
David M. Smith <[email protected]>
Kupper L, Haseman J (1978). The Use of a Correlated Binomial Model for the Analysis of Toxicological Experiments. Biometrics, 34(1), 69-76.
twoparameter <- c(0.971242852,0.001465007) names(twoparameter) <- c('p','rho') nt <- 37 CBprob(twoparameter,nt)
twoparameter <- c(0.971242852,0.001465007) names(twoparameter) <- c('p','rho') nt <- 37 CBprob(twoparameter,nt)
Extract the regression model coefficients from models of class "BinaryEPMM".
## S3 method for class 'BinaryEPPM' coef(object, prtpar = c("full", "p", "scale.factor"), ...)
## S3 method for class 'BinaryEPPM' coef(object, prtpar = c("full", "p", "scale.factor"), ...)
object |
fitted model object of class "BinaryEPPM". |
prtpar |
character indicating coefficients of the fitted model to be output: all coefficients ("full"), coefficients of the model for probability of success ("p"), coefficients of the model for scale-factor ("scale.factor") |
... |
some methods for this generic function require additional arguments. |
One of a set of standard extractor functions for fitted model objects of class "BinaryEPPM.
Vector of coefficients of fitted regression model.
David M. Smith <[email protected]>
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution)) coef(output.fn, prtpar = "full") coef(output.fn, prtpar = "p") coef(output.fn, prtpar = "scale.factor")
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution)) coef(output.fn, prtpar = "full") coef(output.fn, prtpar = "p") coef(output.fn, prtpar = "scale.factor")
Calculates Cook's distances for BinaryEPPM objects.
## S3 method for class 'BinaryEPPM' cooks.distance(model, ...)
## S3 method for class 'BinaryEPPM' cooks.distance(model, ...)
model |
fitted model object of class "BinaryEPPM". |
... |
some methods for this generic function require additional arguments. |
Cook's distances as in GLMs.
A vector of Cook's distances.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') cooks.distance(output.fn)
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') cooks.distance(output.fn)
Computes the double exponential link function, including its inverse.
doubexp()
doubexp()
The double exponential transformation of theta.
David M. Smith <[email protected]>
Ford I, Torsney B, Wu C (1992). "The Use of a Canonical Form in the Construction of Locally Optimal Designs for Non-linear Problems." Journal of the Royal Statistical Society B, 54, 569-583. doi:10.1111/j.2517-6161.1992.tb01897.x
Computes the double reciprocal link function, including its inverse.
doubrecip()
doubrecip()
The double reciprocal transformation of theta.
David M. Smith <[email protected]>
Ford I, Torsney B, Wu C (1992). "The Use of a Canonical Form in the Construction of Locally Optimal Designs for Non-linear Problems." Journal of the Royal Statistical Society B, 54, 569-583. doi:10.1111/j.2517-6161.1992.tb01897.x
Calculates a vector of probabilities given a vector of rates using the matrix exponential function from Maechler, Dutang, Goulet, Bates, Firth (2023).
EPPMprob(vlambda)
EPPMprob(vlambda)
vlambda |
a vector of rates of an extended Poisson process. |
This is a similar function to that in Smith and Faddy (2014).
The value returned is a vector of probabilities.
David M. Smith <[email protected]>
Maechler M, Dutang C, Goulet V, Bates D, Firth D. (2023). expm: Matrix Exponential. R package version 0.999-8, https://CRAN.R-project.org/package=expm.
Smith D, Faddy M (2014). CountsEPPM: Mean and Variance Modeling of Count Data. R package version 2.0, https://CRAN.R-project.org/package=CountsEPPM.
This function is generic. Extract the fitted values from models of class "BinaryEPMM".
## S3 method for class 'BinaryEPPM' fitted(object, ...)
## S3 method for class 'BinaryEPPM' fitted(object, ...)
object |
fitted model object of class "BinaryEPPM". |
... |
currently not used. |
This function is included so that function lrtest from package lmtest can be used.
An vector of class "numeric" of the fitted values from the object of class "BinaryEPMM".
David M. Smith <[email protected]>
Given a vector of parameters and a scalar of the number of trials the function returns a vector of probabilities. The name GBprob is used to avoid confusion with EPPMprob which is the function calculating the probabilties given the constructed vector vector of lambdas.
GBprob(twoparameter, nt)
GBprob(twoparameter, nt)
twoparameter |
A vector of the parameters of the EPPM binomial distribution. |
nt |
The number of trials. |
Vector of probabilities
David M. Smith <[email protected]>
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
twoparameter <- c(0.971242852,0.001465007) names(twoparameter) <- c('p','b') nt <- 37 GBprob(twoparameter,nt)
twoparameter <- c(0.971242852,0.001465007) names(twoparameter) <- c('p','b') nt <- 37 GBprob(twoparameter,nt)
Extract the values of the hat matrix from models of class "BinaryEPMM".
## S3 method for class 'BinaryEPPM' hatvalues(model, ...)
## S3 method for class 'BinaryEPPM' hatvalues(model, ...)
model |
fitted model object of class "BinaryEPPM". |
... |
some methods for this generic function require additional arguments. |
The calculated hat values for the fitted model. These are used to calculate Cook's distances.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') hatvalues(output.fn)
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') hatvalues(output.fn)
Data of the number of deaths out of number of implants for pregnant female mice for two groups each of size 10.
data("KupperHaseman.case")
data("KupperHaseman.case")
A data frame with 20 observations on the following 3 variables.
Group
a factor with levels Control
Treated
Number.Deaths
a numeric vector
Number.Implants
a numeric vector
Kupper L, Haseman J. (1978). The Use of a Correlated Binomial Model for the Analysis of Toxicological Experiments. Biometrics, 34(1), 69-76.
data("KupperHaseman.case")
data("KupperHaseman.case")
Function used to calculate the first derivatives of the log likelihood with respect to the model parameters. These are numerical derivatives calculated using the numerical derivative functions of Gilbert and Varadhan (2015).
LL.gradient(parameter, model.type, model.name, link, ntrials, nsuccess, covariates.matrix.p, covariates.matrix.scalef, offset.p, offset.scalef, weights, grad.method)
LL.gradient(parameter, model.type, model.name, link, ntrials, nsuccess, covariates.matrix.p, covariates.matrix.scalef, offset.p, offset.scalef, weights, grad.method)
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
model.type |
Takes one of two values i.e. 'p only' or 'p and scale-factor'. The 'p only' value fits linear predictor functions to the probability of a success 'p' as in Faddy and Smith (2012). The 'p and scale-factor' value fits linear predictor functions to both the 'p' and the scale-factor. The default is 'p and scale-factor'. |
model.name |
If model.type is 'p only' the model being fitted is one of the four 'binomial', 'EPPM extended binomial', 'beta binomial' or 'correlated binomial'. If model.type is 'p and scale-factor' the model being fitted is one of the three 'EPPM extended binomial', 'beta binomial' or 'correlated binomial'. Information about these models is given in Faddy and Smith (2012). The default is 'EPPM extended binomial'. |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
ntrials |
A vector length 'n+1' representing the number of trials 'n' i.e., a vector with all elements equal to 'n'. |
nsuccess |
A vector representing the frequency distribution of the binomial distribution for fixed number of trials 'n'. |
covariates.matrix.p |
A matrix of covariates for the mean where rows are the number of values in list.binary and columns the covariates. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
covariates.matrix.scalef |
A matrix of covariates for the variance where rows are the number of values in list.binary and columns the covariates. The default is a vector of ones. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
offset.p |
An offset vector for the probability of success p. The default is a vector of ones. |
offset.scalef |
An offset vector for the scale-factor. The default is a vector of ones. |
weights |
A vector or list of weights for the modeling of probability of success. The default is a vector of ones. |
grad.method |
Numerical method used to calculate gradients when the optimization method for optim is BFGS either simple or Richardson. This is the grad.method attribute of argument method of BinaryEPPM. The default is simple. |
A vector of numerical first derivatives.
David M. Smith <[email protected]>
Gilbert P, Varadhan R. (2015). numDeriv: Accurate Numerical Derivatives. R Package version 2014.2-1, https://CRAN.R-project.org/package=numDeriv.
link <- 'cloglog' attr(link, which="p") <- make.link(link) nsuccess <- list(c(rep(0,5),352,479,530,291,101,17)) ntrials <- list(c(rep(10,11))) parameter <- c(0.06363398,-0.47085362) LL.gradient(parameter, model.type = "p and scale-factor", model.name = "EPPM extended binomial", link = link, ntrials = ntrials, nsuccess = nsuccess, covariates.matrix.p = matrix(c(1), nrow=1), covariates.matrix.scalef = matrix(c(1), nrow=1), offset.p = c(0), offset.scalef = c(0), weights = list(c(rep(1,11))), grad.method = "Richardson")
link <- 'cloglog' attr(link, which="p") <- make.link(link) nsuccess <- list(c(rep(0,5),352,479,530,291,101,17)) ntrials <- list(c(rep(10,11))) parameter <- c(0.06363398,-0.47085362) LL.gradient(parameter, model.type = "p and scale-factor", model.name = "EPPM extended binomial", link = link, ntrials = ntrials, nsuccess = nsuccess, covariates.matrix.p = matrix(c(1), nrow=1), covariates.matrix.scalef = matrix(c(1), nrow=1), offset.p = c(0), offset.scalef = c(0), weights = list(c(rep(1,11))), grad.method = "Richardson")
Fits specified regression models to the data.
LL.Regression.Binary(parameter,model.type,model.name,link,ntrials,nsuccess, covariates.matrix.p,covariates.matrix.scalef, offset.p,offset.scalef,weights,grad.method)
LL.Regression.Binary(parameter,model.type,model.name,link,ntrials,nsuccess, covariates.matrix.p,covariates.matrix.scalef, offset.p,offset.scalef,weights,grad.method)
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
model.type |
Takes one of two values i.e. 'p only' or 'p and scale-factor'. The 'p only' value fits linear predictor functions to the probability of a success 'p' as in Faddy and Smith (2012). The 'p and scale-factor' value fits linear predictor functions to both the 'p' and the scale-factor. The default is 'p and scale-factor'. |
model.name |
If model.type is 'p only' the model being fitted is one of the four 'binomial', 'EPPM extended binomial', 'beta binomial' or 'correlated binomial'. If model.type is 'p and scale-factor' the model being fitted is one of the three 'EPPM extended binomial', 'beta binomial' or 'correlated binomial'. Information about these models is given in Faddy and Smith (2012). The default is 'EPPM extended binomial'. |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
ntrials |
A vector length 'n+1' representing the number of trials 'n' i.e., a vector with all elements equal to 'n'. |
nsuccess |
A vector representing the frequency distribution of the binomial distribution for fixed number of trials 'n'. |
covariates.matrix.p |
A matrix of covariates for the mean where rows are the number of values in list.binary and columns the covariates. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
covariates.matrix.scalef |
A matrix of covariates for the variance where rows are the number of values in list.binary and columns the covariates. The default is a vector of ones. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
offset.p |
An offset vector for the probability of success p. The default is a vector of ones. |
offset.scalef |
An offset vector for the scale-factor. The default is a vector of ones. |
weights |
A vector or list of weights for the modeling of probability of success. The default is a vector of ones. |
grad.method |
Numerical method used to calculate gradients either simple or Richardson. The default is simple. |
The log likelihood is returned.
David M. Smith <[email protected]>
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
link <- 'cloglog' attr(link, which="p") <- make.link(link) nsuccess <- list(c(rep(0,5),352,479,530,291,101,17)) ntrials <- list(c(rep(10,11))) parameter <- c(0.06363398,-0.47085362) LL.Regression.Binary(parameter, model.type = "p and scale-factor", model.name = "EPPM extended binomial", link, ntrials, nsuccess, covariates.matrix.p = matrix(c(1), nrow=1), covariates.matrix.scalef = matrix(c(1), nrow=1), offset.p = c(0), offset.scalef = c(0), weights = list(c(rep(1,11))))
link <- 'cloglog' attr(link, which="p") <- make.link(link) nsuccess <- list(c(rep(0,5),352,479,530,291,101,17)) ntrials <- list(c(rep(10,11))) parameter <- c(0.06363398,-0.47085362) LL.Regression.Binary(parameter, model.type = "p and scale-factor", model.name = "EPPM extended binomial", link, ntrials, nsuccess, covariates.matrix.p = matrix(c(1), nrow=1), covariates.matrix.scalef = matrix(c(1), nrow=1), offset.p = c(0), offset.scalef = c(0), weights = list(c(rep(1,11))))
This function is generic. It is a method for extracting the log-likelihood for objects of class "BinaryEPPM".
## S3 method for class 'BinaryEPPM' logLik(object, ...)
## S3 method for class 'BinaryEPPM' logLik(object, ...)
object |
fitted model object of class "BinaryEPPM". |
... |
some methods for this generic function require additional arguments |
logLik is most commonly used for a model fitted by maximum likelihood as is done here.
The log likelihood value for the fitted model object.
David M. Smith <[email protected]>
Computes the loglog link function, including its inverse.
loglog()
loglog()
Same link function as in Cribari-Neto and Zeileis (2010).
The loglog of theta where the logarithms are to base e.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
Calculates the probabilities for beta and correlated binomials given values for p's and scale-factors.
Model.BCBinProb(parameter, model.type, model.name, link, ntrials, covariates.matrix.p, covariates.matrix.scalef = matrix(c(rep(1, nrow(covariates.matrix.p))), ncol = 1), offset.p = c(rep(0, length(ntrials))), offset.scalef = c(rep(0, length(ntrials))))
Model.BCBinProb(parameter, model.type, model.name, link, ntrials, covariates.matrix.p, covariates.matrix.scalef = matrix(c(rep(1, nrow(covariates.matrix.p))), ncol = 1), offset.p = c(rep(0, length(ntrials))), offset.scalef = c(rep(0, length(ntrials))))
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
model.type |
Takes one of two values i.e. 'p only' or 'p and scale-factor'. The 'p only' value fits a linear predictor function to the parameter p which is the 'm(1)' in equation (6) of Faddy and Smith (2012) divided by 'N'. The 'p and scale-factor' value fits linear predictor functions to both p and the scale-factor. |
model.name |
The model being fitted is one of the two 'beta binomial' or 'correlated binomial'. |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
ntrials |
This is a scalar representing the denominator i.e., the length of the probability mass function returned is this scalar + 1. |
covariates.matrix.p |
A matrix of covariates for p where rows are the number of values in listbinary and columns the covariates. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
covariates.matrix.scalef |
A matrix of covariates for the scale-factor where rows are the number of values in listbinary and columns the covariates. The default is a vector of ones. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
offset.p |
An offset vector for p. The default is a vector of ones. |
offset.scalef |
An offset vector for the scale-factor. The default is a vector of ones. |
List of arguments input together with a list of probabilities vectors and a data frame of values of p, theta (beta binomial) or rho (correlated binomial) and the limits for theta or rho.
model |
The model is either 'beta binomial' or 'correlated binomial'. |
link |
The link is either 'logit' or 'cloglog'. |
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
probabilities |
A list of the vectors of probabilities of the model. |
probabilities |
A data frame of values of p, theta (beta binomial) or rho (correlated binomial) and the limits for theta or rho. |
David M. Smith <[email protected]>
Hughes G, Madden L (1995). Some methods allowing for aggregated patterns of disease incidence in the analysis of data from designed experiments. Plant Pathology, 44, 927-943.
Kupper L, Haseman J (1978). The use of a correlated binomial model for the analysis of toxicological epxeriments. Biometrics, 34(1), 69-76.
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(-0.68294630,0.03451481) names(parameter) <- c('p','rho') model.type <- 'p and scale-factor' model.name <- 'correlated binomial' ntrials <- list(c(rep(10,11))) Model.BCBinProb(parameter, model.type, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),nrow=1), covariates.matrix.scalef = matrix(c(1),nrow=1), offset.p = c(0), offset.scalef = c(0))
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(-0.68294630,0.03451481) names(parameter) <- c('p','rho') model.type <- 'p and scale-factor' model.name <- 'correlated binomial' ntrials <- list(c(rep(10,11))) Model.BCBinProb(parameter, model.type, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),nrow=1), covariates.matrix.scalef = matrix(c(1),nrow=1), offset.p = c(0), offset.scalef = c(0))
Produces output of model, parameters and probabilities from the various models.
Model.Binary(parameter, model.type, model.name, link, ntrials, covariates.matrix.p, covariates.matrix.scalef, offset.p, offset.scalef)
Model.Binary(parameter, model.type, model.name, link, ntrials, covariates.matrix.p, covariates.matrix.scalef, offset.p, offset.scalef)
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
model.type |
Takes one of two values i.e. 'p only' or 'p and scale-factor'. The 'p only' value fits a linear predictor function to the parameter p which is the 'm(1)' in equation (6) of Faddy and Smith (2012) divided by 'N'. The 'p and scale-factor' value fits linear predictor functions to both p and the scale-factor. |
model.name |
If model.type is 'p only' the model being fitted is one of the six 'binomial', 'over-dispersed-one', 'over-dispersed-two', 'EPPM binomial', 'beta binomial' or 'correlated binomial'. If model.type is 'p and scale-factor' the model being fitted is one of the three 'EPPM binomial', 'beta binomial' or 'correlated binomial'. |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
ntrials |
This is a scalar representing the denominator i.e., the length of the probability mass function returned is this scalar + 1. |
covariates.matrix.p |
A matrix of covariates for p where rows are the number of values in listbinary and columns the covariates. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
covariates.matrix.scalef |
A matrix of covariates for the scale-factor where rows are the number of values in listbinary and columns the covariates. The default is a vector of ones. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
offset.p |
An offset vector for p. The default is a vector of ones. |
offset.scalef |
An offset vector for the scale-factor. The default is a vector of ones. |
The output from either Model.BCBinProb, Model.GB, Model.Binary, Model.JMVGB, or Model.ODB.
David M. Smith <[email protected]>
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(-0.68294630,0.03451481) names(parameter) <- c('p','rho') model.type <- 'p and scale-factor' model.name <- 'correlated binomial' ntrials <- list(c(rep(10,11))) Model.Binary(parameter, model.type, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),nrow=1), covariates.matrix.scalef = matrix(c(1),nrow=1), offset.p = c(0), offset.scalef = c(0))
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(-0.68294630,0.03451481) names(parameter) <- c('p','rho') model.type <- 'p and scale-factor' model.name <- 'correlated binomial' ntrials <- list(c(rep(10,11))) Model.Binary(parameter, model.type, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),nrow=1), covariates.matrix.scalef = matrix(c(1),nrow=1), offset.p = c(0), offset.scalef = c(0))
Calculates the probabilities for binomial and EPPM extended binomial given values for p's and b.
Model.GB(parameter, model.name, link, ntrials, covariates.matrix.p, offset.p = c(rep(0, length(ntrials))))
Model.GB(parameter, model.name, link, ntrials, covariates.matrix.p, offset.p = c(rep(0, length(ntrials))))
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
model.name |
The model being fitted is one of the two 'binomial' or 'EPPM extended binomial'. |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
ntrials |
This is a scalar representing the denominator i.e., the length of the probability mass function returned is this scalar + 1. |
covariates.matrix.p |
A matrix of covariates for p where rows are the number of values in listbinary and columns the covariates. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
offset.p |
An offset vector for p. The default is a vector of ones. |
List of arguments input together with a list of probabilities vectors and a data frame of values of a and b of Equation (5) of Faddy and Smith (2012).
model |
The model is either 'binomial' or 'EPPM extended binomial'. |
link |
The link is either 'logit' or 'cloglog'. |
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
probabilities |
A list of the vectors of probabilities of the model. |
Dparameters |
A data frame of values of a and b of Equation (5) of Faddy and Smith (2012). |
David M. Smith <[email protected]>
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(0.9423342,0.5846321) names(parameter) <- c('p','b') model.name <- 'EPPM extended binomial' ntrials <- list(c(rep(10,11))) Model.GB(parameter, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),ncol=1), offset.p = c(0))
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(0.9423342,0.5846321) names(parameter) <- c('p','b') model.name <- 'EPPM extended binomial' ntrials <- list(c(rep(10,11))) Model.GB(parameter, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),ncol=1), offset.p = c(0))
Calculates the probabilities for binomial and generalized binomial given values for p's and scale-factors.
Model.JMVGB(parameter, model.name, link, ntrials, covariates.matrix.p, covariates.matrix.scalef, offset.p = c(rep(0, length(ntrials))), offset.scalef = c(rep(0, length(ntrials))))
Model.JMVGB(parameter, model.name, link, ntrials, covariates.matrix.p, covariates.matrix.scalef, offset.p = c(rep(0, length(ntrials))), offset.scalef = c(rep(0, length(ntrials))))
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
model.name |
The model being fitted is one of the two 'binomial' or 'EPPM extended binomial'. |
link |
Takes one of nine values i.e., 'logit', 'probit', 'cloglog', 'cauchit', 'log', 'loglog', 'double exponential', 'double reciprocal', 'power logit'. The default is 'cloglog'. The 'power logit' has an attribute of 'power' for which the default is 1 i.e., a logit link. |
ntrials |
This is a scalar representing the denominator i.e., the length of the probability mass function returned is this scalar + 1. |
covariates.matrix.p |
A matrix of covariates for p where rows are the number of values in listbinary and columns the covariates. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
covariates.matrix.scalef |
A matrix of covariates for the scale-factor where rows are the number of values in listbinary and columns the covariates. The default is a vector of ones. This matrix is extracted from the formulae in function BinaryEPPM. However, in the accompanying example it is shown how it can be constructed independently of function BinaryEPPM. |
offset.p |
An offset vector for p. The default is a vector of ones. |
offset.scalef |
An offset vector for the scale-factor. The default is a vector of ones. |
List of arguments input together with a list of probabilities vectors and a data frame of values of a and b of Equation (5) of Faddy and Smith (2012).
model |
The model is either 'binomial' or 'EPPM extended binomial'. |
link |
The link is either 'logit' or 'cloglog'. |
parameter |
A vector of the parameters of the model which is set to initial estimates on function call. |
probabilities |
A list of the vectors of probabilities of the model. |
Dparameters |
A data frame of values of a and b of Equation (5) of Faddy and Smith (2012). |
David M. Smith <[email protected]>
Faddy M, Smith D. (2012). Extended Poisson Process Modeling and Analysis of Grouped Binary Data. Biometrical Journal, 54, 426-435. doi:10.1002/bimj.201100214.
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(-0.68294630,0.03451481) names(parameter) <- c('p','scale-factor') model.name <- 'EPPM extended binomial' ntrials <- list(c(rep(10,11))) Model.JMVGB(parameter, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),nrow=1), covariates.matrix.scalef = matrix(c(1),nrow=1), offset.p = c(0), offset.scalef = c(0))
link <- 'cloglog' attr(link, which="p") <- make.link(link) parameter <- c(-0.68294630,0.03451481) names(parameter) <- c('p','scale-factor') model.name <- 'EPPM extended binomial' ntrials <- list(c(rep(10,11))) Model.JMVGB(parameter, model.name, link, ntrials, covariates.matrix.p = matrix(c(1),nrow=1), covariates.matrix.scalef = matrix(c(1),nrow=1), offset.p = c(0), offset.scalef = c(0))
Computes the negative complementary log-log link function, including its inverse.
negcomplog()
negcomplog()
The negative complementary log-log of theta.
David M. Smith <[email protected]>
Tibshirani RJ, Ciampi A (1983). "A Family of Proportional- and Additive-Hazards Models for Survival Data". Biometrics 39(1), 141-147.
The data are arranged as a list of binomial frequency distributions where the listing is by litter size which is included both as a variate (vsize) and as a factor (fsize)
data("Parkes.litters")
data("Parkes.litters")
The format is: List of 3 $ fsize : Factor w/ 7 levels " size 5"," size 6",..: 1 2 3 4 5 6 7 $ vsize : int [1:7] 5 6 7 8 9 10 11 $ number.success:List of 7 ..$ : num [1:6] 2 20 41 35 14 4 ..$ : num [1:7] 3 16 53 78 53 18 0 ..$ : num [1:8] 0 21 63 117 104 46 21 2 ..$ : num [1:9] 1 8 37 81 162 77 30 5 1 ..$ : num [1:10] 0 2 23 72 101 83 46 12 7 0 ..$ : num [1:11] 0 7 8 19 79 82 48 24 10 0 ... ..$ : num [1:12] 0 1 3 15 15 33 13 12 8 1 ...
Brooks, R.J., James, W.H., Gray, E. (1993). Modelling Sub-Binomial Variation in the Frequency of Sex Combinations in Litters of Pigs. Biometrics 47, 403-417.
data("Parkes.litters")
data("Parkes.litters")
This function is generic. Various types of standard diagnostic plots can be produced, involving various types of residuals, influence measures etc. It is a minorly modified version of the generic plot function of betareg with details of the displays given in Cribari-Neto and Zeileis (2010). The same six displays and arguments list as in Cribari-Neto and Zeileis (2010) are used. The six displays are "Residuals vs indices of obs", "Cook's distance plot", "Leverage vs predicted values", "Residuals vs linear predictor", "Normal Q-Q plot of residuals", "Predicted vs observed values".
## S3 method for class 'BinaryEPPM' plot(x, which = 1:4, caption = c("Residuals vs indices of obs.", "Cook's distance plot", "Leverage vs predicted values", "Residuals vs linear predictor", "Normal Q-Q plot of residuals", "Predicted vs observed values"), sub.caption = " ", main = "", ask = prod(par("mfcol"), 1) < length(which) && dev.interactive(), ..., type = "spearson")
## S3 method for class 'BinaryEPPM' plot(x, which = 1:4, caption = c("Residuals vs indices of obs.", "Cook's distance plot", "Leverage vs predicted values", "Residuals vs linear predictor", "Normal Q-Q plot of residuals", "Predicted vs observed values"), sub.caption = " ", main = "", ask = prod(par("mfcol"), 1) < length(which) && dev.interactive(), ..., type = "spearson")
x |
fitted model object of class "BinaryEPPM". |
which |
numeric. If a subset of plots is required, specify a subset of the numbers 1:6. |
caption |
character. Captions to appear above the plots. |
sub.caption |
character. Common title-above figures if there are multiple. |
main |
character. Title to each plot in addition to the above caption. |
ask |
logical. If true, the user is asked before each plot. |
... |
other parameters to be passed through to plotting functions. |
type |
character indicating type of residual to be used, see residuals.BinaryEPPM. |
The plot method for BinaryEPPM objects produces various plots of diagnostic plots similar to those produced by betareg. See Cribari-Neto and Zeileis (2010) for further details of the displays of betareg.
No return value.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') plot.BinaryEPPM(output.fn, which = 1, type= "sdeviance")
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') plot.BinaryEPPM(output.fn, which = 1, type= "sdeviance")
Computes the power logit link function, including its inverse.
powerlogit(power = 1)
powerlogit(power = 1)
power |
power value for the power logit link function. |
The power logit transformation of theta. All logarithms are natural ones, i.e., to base e.
David M. Smith <[email protected]>
Gaudard MA, Karson MJ, Linder E, Tse Sk (1993). Efficient Designs for Estimation in the Power Logistic Quantal Response Model." Statistica Sinica, 3, 233-243.
Extract various types of predictions from BinaryEPPM regression models.
## S3 method for class 'BinaryEPPM' predict(object, newdata = NULL, type = c("response", "linear.predictor.p", "linear.predictor.scale.factor", "p", "scale.factor", "scale.factor.limits", "mean", "variance", "distribution", "distribution.parameters"), na.action = na.pass, ...)
## S3 method for class 'BinaryEPPM' predict(object, newdata = NULL, type = c("response", "linear.predictor.p", "linear.predictor.scale.factor", "p", "scale.factor", "scale.factor.limits", "mean", "variance", "distribution", "distribution.parameters"), na.action = na.pass, ...)
object |
fitted model object of class "BinaryEPPM". |
newdata |
optionally, a data frame in which to look for variables with which to predict. If omitted, the original observations are used. |
type |
character indicating type of predictions: fitted means of responses ("response"), linear predictors ("linear.predictor.p", "linear.predictor.scale.factor"), fitted value of probability of success ("p"), fitted value of scale-factor ("scale.factor"), fitted value of mean ("mean"), scale factor limits ("scale.factor.limits"), fitted value of variance ("variance"), fitted probability distribution ("distribution"), parameters of fitted distributions ("distribution.parameters") |
na.action |
function determining what should be done with missing values in newdata. The default is to predict NA. |
... |
some methods for this generic function require additional arguments. |
A vector or list of the predicted values from the fitted model object.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') predict(output.fn, type = "response") predict(output.fn, type = "linear.predictor.p")
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') predict(output.fn, type = "response") predict(output.fn, type = "linear.predictor.p")
Prints objects of class "BinaryEPPM".
## S3 method for class 'BinaryEPPM' print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'BinaryEPPM' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
fitted model object of class "BinaryEPPM". |
digits |
digits of printed output. |
... |
not currently used. |
An object of class "BinaryEPPM" is constructed. This object has the following attributes.
data.type |
Indicator of the type of data either 0 "data.frame" or 1 "list". |
list.data |
Regardless of the "data.type", the data in list form. |
call |
The "call" to the function "BinaryEPPM". |
formula |
The model formula in "call". |
model.type |
The model type in "call". |
model.name |
The model name in "call". |
link |
The link function in "call". |
covariates.matrix.p |
The matrix of covariates for the model for p. |
covariates.matrix.scalef |
The matrix of covariates for the model for scale-factor. |
offset.p |
The vector of offsets for the model for p. |
offset.scalef |
The vector of offsets for the model for scale-factor. |
coefficients |
The coefficients of the fitted model. |
loglik |
The log-likelihood of the fitted model. |
vcov |
The variance-covariance matrix of the fitted model. |
n |
The number of observations. Relabelled duplication of "nobs" needed when calling function "lrtest". |
nobs |
The number of observations. |
df.null |
The degrees of freedom of the null model. |
df.residual |
The degrees of freedom of the residual model. |
vnmax |
Vector of number of "trials" in each observation. |
weights |
Vector of weights for observation. |
converged |
Indicator of convergence. |
method |
Method used to calculate pseudo.r.squared. |
pseudo.r.squared |
The value of the coefficient of determination r squared. |
start |
Initial estimates. |
optim |
Final model fit. |
control |
Control parameters for optimization function "optim". |
fitted.values |
The fitted values. |
y |
The dependent variable in the model. |
terms |
The terms in the model. |
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial')
data("ropespores.case") BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial')
Prints the objects of class "summaryBinaryEPPM".
## S3 method for class 'summaryBinaryEPPM' print(x, ...)
## S3 method for class 'summaryBinaryEPPM' print(x, ...)
x |
object output by |
... |
not currently used. |
No return value.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') print(summary(output.fn))
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') print(summary(output.fn))
This function is generic. Extract various types of residuals from objects of class "BinaryEPPM".
## S3 method for class 'BinaryEPPM' residuals(object, type = c("spearson", "deviance", "pearson", "response", "likelihood", "sdeviance"), ...)
## S3 method for class 'BinaryEPPM' residuals(object, type = c("spearson", "deviance", "pearson", "response", "likelihood", "sdeviance"), ...)
object |
Fitted model object of class "BinaryEPPM". |
type |
Type of residuals wanted i.e., standardized Pearson "spearson", deviance "deviance", Pearson "pearson",response "response", likelihood "likelihood", standardized deviance "sdeviance". |
... |
Some methods for this generic function require additional arguments. |
Residuals as Cribari-Neto and Zeileis (2010).
An vector of class "numeric" of residuals of a specified type from the object of class "BinaryEPMM".
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
Dilution series where at each dilution of a suspension of potato flour a number of samples were examined for the presence of rope spores. These data are in data frame form.
data("ropespores.case")
data("ropespores.case")
A data frame with 10 observations on the following 5 variables.
vdilution
a numeric vector
fdilution
a factor with levels 0.25
0.5
1
2
4
8
16
32
64
128
logdilution
a numeric vector
number.spores
a numeric vector
number.tested
a numeric vector
Finney, D.J. (1971). Statistical Methods in Biological Assay. Griffin, London, 2nd edition.
data("ropespores.case")
data("ropespores.case")
Dilution series where at each dilution of a suspension of potato flour a number of samples were examined for the presence of rope spores. These data are in list form.
data("ropespores.grouped")
data("ropespores.grouped")
The format is: List of 4 $ vdilution : num [1:10] 0.25 0.5 1 2 4 8 16 32 64 128 $ fdilution : Factor w/ 10 levels "0.25","0.5","1",..: 1 2 3 4 5 6 7 8 9 10 $ offset.p : num [1:10] 1.386 0.693 0 -0.693 -1.386 ... $ number.spores:List of 10 ..$ : num [1:6] 0 0 0 0 0 1 ..$ : num [1:6] 0 0 0 0 0 1 ..$ : num [1:6] 0 0 0 0 0 1 ..$ : num [1:6] 0 0 0 0 0 1 ..$ : num [1:6] 0 0 0 0 1 0 ..$ : num [1:6] 0 0 0 1 0 0 ..$ : num [1:6] 0 0 1 0 0 0 ..$ : num [1:6] 0 0 1 0 0 0 ..$ : num [1:6] 1 0 0 0 0 0 ..$ : num [1:6] 1 0 0 0 0 0
Finney, D.J. (1971). Statistical Methods in Biological Assay. Griffin, London, 2nd edition.
data("ropespores.grouped")
data("ropespores.grouped")
This function is generic. Summary of objects of class "BinaryEPPM".
## S3 method for class 'BinaryEPPM' summary(object, ...)
## S3 method for class 'BinaryEPPM' summary(object, ...)
object |
Fitted model object of class "BinaryEPPM". |
... |
some methods for this generic function require additional arguments. |
Similar output to that of summary.glm
"summary.glm" and summary.betareg
Cribari-Neto and Zeileis (2010).
An object of class "summaryBinaryEPPM" is constructed. This object has the following attributes.
data.type |
Indicator of the type of data either 0 "data.frame" or 1 "list". |
call |
The "call" to the function "BinaryEPPM". |
formula |
The model formula in "call". |
model.type |
The model type in "call". |
model.name |
The model name in "call". |
link |
The link function in "call". |
offset.p |
The vector of offsets for the model for p. |
offset.scalef |
The vector of offsets for the model for scale-factor. |
coeff.table.p |
The coefficients of the fitted model for p. |
coeff.table.scalef |
The coefficients of the fitted model for scale-factor. |
loglik |
The log-likelihood of the fitted model. |
n |
The number of observations. Relabelled duplication of "nobs" needed when calling function "lrtest". |
nobs |
The number of observations. |
df.null |
The degrees of freedom of the null model. |
df.residual |
The degrees of freedom of the residual model. |
vnmax |
Vector of number of "trials" in each observation. |
weights |
Vector of weights for observation. |
converged |
Indicator of convergence. |
method |
Method used to calculate pseudo.r.squared. |
pseudo.r.squared |
The value of the coefficient of determination r squared. |
optim |
Final model fit. |
control |
Control parameters for optimization function "optim". |
fitted.values |
The fitted values. |
y |
The dependent variable in the model. |
terms |
The terms in the model. |
npar |
The number of parameters in the model. |
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
summary.betareg
print.summaryBinaryEPPM
Variance/covariance matrix for coefficients of fitted model.
## S3 method for class 'BinaryEPPM' vcov(object, model = c("full", "p", "scale.factor"), ...)
## S3 method for class 'BinaryEPPM' vcov(object, model = c("full", "p", "scale.factor"), ...)
object |
fitted model object of class "BinaryEPPM". |
model |
character indicating variance/covariance matrix for all coefficients to be output: all coefficients ("full"), variance/covariance matrix for coefficients of probability of success ("p"), variance/covariance matrix for coefficients of scale-factor ("scale.factor") |
... |
other parameters to be passed through to plotting functions. |
The variance/covariance matrix of the parameters of the fitted model object.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') vcov(output.fn)
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') vcov(output.fn)
waldtest
is a generic function for comparisons of nested (generalized) linear models via Wald tests.
## S3 method for class 'BinaryEPPM' waldtest(object, ..., vcov = NULL, test = c("Chisq", "F"))
## S3 method for class 'BinaryEPPM' waldtest(object, ..., vcov = NULL, test = c("Chisq", "F"))
object |
an object of class "BinaryEPPM". |
... |
further object specifications passed to methods. See below for details. |
vcov |
a function for estimating the covariance matrix of the regression coefficients. If only two models are compared it can also be the covariance matrix of the more general model. |
test |
character specifying whether to compute the large sample Chi-squared statistic (with asymptotic Chi-squared distribution) or the finite sample F statistic (with approximate F distribution). |
waldtest
is a generic function for comparisons of nested (generalized)linear models via Wald tests. It does not have the same functionality as the versions of betareg and lmtest with a reduced list of arguments. With these caveats, more details can be obtained from the Details pages of those packages.
An object of class "anova"
which contains the residual degrees of freedom, the difference in degrees of freedom, Wald statistic (either "Chisq"
or "F"
) and corresponding p value.
David M. Smith <[email protected]>
Cribari-Neto F, Zeileis A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1-24. doi:10.18637/jss.v034.i02.
Zeileis A, Hothorn T. (2002). Diagnostic Checking in Regression Relationships. R News, 2(3), 7-10. https://CRAN.R-project.org/doc/Rnews/.
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') output.fn.one <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'beta binomial') waldtest.BinaryEPPM(output.fn, output.fn.one, test = c("Chisq", "F"), vcov = vcov)
data("ropespores.case") output.fn <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'binomial') output.fn.one <- BinaryEPPM(data = ropespores.case, number.spores / number.tested ~ 1 + offset(logdilution), model.type = 'p only', model.name = 'beta binomial') waldtest.BinaryEPPM(output.fn, output.fn.one, test = c("Chisq", "F"), vcov = vcov)
The data are the number of occurences of an article in five-word and ten-word samples from Macaulay's 'Essay on Milton' and G.K. Chesterton's essay 'About the workers'.
data("wordcount.case")
data("wordcount.case")
A data frame with 340 observations on the following 5 variables.
author
a factor with levels Macaulay
Chesterton
fsize
a factor with levels 5
10
vsize
a numeric vector
number.words
a numeric vector
number.tested
a numeric vector
Bailey, B.J.R. (1990). A model for Function Word Counts. Appl. Statist. 39(1), 107-114.
Sellers, K.F., Swift, A.W., Weems, K.S. (2017). A flexible distribution class for count data. Journal of Statistical Distributions and Applications 41(12), 2616-2626.
data(wordcount.case)
data(wordcount.case)
The data are the number of occurences of an article in five-word and ten-word samples from Macaulay's 'Essay on Milton' and G.K. Chesterton's essay 'About the workers'.
data("wordcount.grouped")
data("wordcount.grouped")
The format is: List of 4 $ author : Factor w/ 2 levels " Macaulay"," Chesterton": 1 1 2 2 $ fsize : Factor w/ 2 levels "5","10": 1 2 1 2 $ vsize : num [1:4] 5 10 5 10 $ number.words:List of 4 ..$ : num [1:6] 45 49 6 0 0 0 ..$ : num [1:11] 27 44 26 3 0 0 0 0 0 0 ... ..$ : num [1:6] 32 35 3 0 0 0 ..$ : num [1:11] 14 38 16 2 0 0 0 0 0 0 ...
Bailey, B.J.R. (1990). A model for Function Word Counts. Appl. Statist. 39(1), 107-114.
Sellers, K.F., Swift, A.W., Weems, K.S. (2017). A flexible distribution class for count data. Journal of Statistical Distributions and Applications 41(12), 2616-2626.
data(wordcount.grouped)
data(wordcount.grouped)
The data are arranged as a list of binomial frequency distributions where the listing is by litter size which is included both as a variate (vsize) and as a factor (fsize)
data("Yorkshires.litters")
data("Yorkshires.litters")
The format is: List of 3 $ fsize : Factor w/ 9 levels " size 5"," size 6",..: 1 2 3 4 5 6 7 8 9 $ vsize : int [1:9] 5 6 7 8 9 10 11 12 13 $ number.success:List of 9 ..$ : num [1:6] 3 22 30 37 13 5 ..$ : num [1:7] 7 18 44 62 27 17 4 ..$ : num [1:8] 2 14 25 63 69 41 12 5 ..$ : num [1:9] 2 15 32 70 127 90 45 18 1 ..$ : num [1:10] 0 8 33 63 106 115 62 30 11 1 ..$ : num [1:11] 0 3 20 49 79 119 91 59 23 4 ... ..$ : num [1:12] 0 0 7 20 60 94 100 47 31 9 ... ..$ : num [1:13] 0 1 6 16 29 52 66 43 34 22 ... ..$ : num [1:14] 0 2 2 2 14 19 44 45 22 13 ...
Brooks, R.J., James, W.H., Gray, E. (1993). Modelling Sub-Binomial Variation in the Frequency of Sex Combinations in Litters of Pigs. Biometrics 47, 403-417.
data("Yorkshires.litters")
data("Yorkshires.litters")