Learn R Programming

PLreg

The PLreg package allows fitting power logit regression models. Diagnostic tools associated with the fitted model, such as the residuals, local influence measures, leverage measures, and goodness-of- fit statistics, are implemented.

Installation

You can install the development version of PLreg from GitHub with:

# install.packages("devtools")
devtools::install_github("ffqueiroz/PLreg")

Main functions

dPL, pPL, qPL, and rPL

Currently, the package includes 7 members of the power logit class of distributions: the power logit normal, power logit Student-t, power logit type II logistic, power logit power exponential, power logit sinh-normal, power logit hyperbolic and power logit slash distributions. The package provides the dPL, pPL, and qPL functions to compute the probability density function, cumulative distribution function and quantile function of the power logit distribution. Also, the rPL function may be used to generate random samples from power logit distributions. The basic usages of these functions are:

dPL(x, mu, sigma, lambda, zeta = 2, family, log = FALSE)

pPL(q, mu, sigma, lambda, zeta = 2, family, lower.tail = TRUE, log.p = FALSE)

qPL(p, mu, sigma, lambda, zeta = 2, family, lower.tail = TRUE, log.p = FALSE)

rPL(n, mu, sigma, lambda, zeta = 2, family)

PLreg

The main function of the package is PLreg(), which allows to fitting power logit regression model to proportional data; this explains the name. The arguments of PLreg() are:

PLreg(formula, data, subset, na.action, family = c("NO", "LO", "TF", "PE", "SN", "SLASH", "Hyp"), 
      zeta = NULL, link = c("logit", "probit", "cloglog", "cauchit", "log", "loglog"), 
      link.sigma = NULL, type = c("pML", "ML"), control = PLreg.control(...), 
      model = TRUE, y = TRUE, x = FALSE, ...)

The PLreg() function returns an object of class “PLreg”, similar to “betareg” and “glm” objects, for which some methods available. The summary() method returns a standard output, with coefficient estimates, standard errors, partial Wald tests and p values for the regression coefficients, the overall goodness-of-fit measure, the pseudo , etc.. The type argument in summary() specifies the type of residuals included in the output; currently three residuals are supported: “standardized”, “quantile” and “deviance”. The plot() method draws graphs for diagnostic and influence analyses.

extra.parameter

An important function in the package is extra.parameter(). It can be used to estimate the extra parameter of some power logit models. The basic usage is:

extra.parameter(object, lower, upper, grid = 10)

Example

library(PLreg)
#> 
#> Attaching package: 'PLreg'
#> The following object is masked from 'package:stats':
#> 
#>     influence
## basic example code

In the following, an example is presented to illustrate the capacities of package. We use the bodyfat_Aeolus data set, available in the package.

help(bodyfat_Aeolus, package = "PLreg")

The response variable is percentfat and the covariates are the sex of the sampled bat (sex), the hibernation time (days) and the year that the bat was sampled (year). We start by fitting a power logit power exponential regression model with constant dispersion and . To select a suitable value for , use the extra.parameter() function as follows.

fitPL_PE_start <- PLreg(percentfat ~ days + sex + year, data = bodyfat_Aeolus,
              family = "PE", zeta = 2)
extra.parameter(fitPL_PE_start, lower = 1, upper = 2.5)

Then, fit the model with the chosen value for .

fitPL_PE <- PLreg(percentfat ~ days + sex + year, data = bodyfat_Aeolus,
              family = "PE", zeta = 1.7)
summary(fitPL_PE)
#> 
#> Call:
#> PLreg(formula = percentfat ~ days + sex + year, data = bodyfat_Aeolus, 
#>     family = "PE", zeta = 1.7)
#> 
#> Standardized residuals:
#>     Min      1Q  Median      3Q     Max 
#> -3.0006 -0.6000  0.0224  0.6353  2.5352 
#> 
#> Coefficients (median model with logit link):
#>               Estimate Std. Error z value Pr(>|z|)    
#> (Intercept) -1.1615018  0.0647074 -17.950   <2e-16 ***
#> days        -0.0092638  0.0005363 -17.273   <2e-16 ***
#> sexM        -0.0499217  0.0570871  -0.874    0.382    
#> year2016     0.5176694  0.0607028   8.528   <2e-16 ***
#> 
#> Sigma coefficients (dispersion model with log link):
#>         Estimate Std. Error z value Pr(>|z|)    
#> (sigma) -1.94446    0.07869  -24.71   <2e-16 ***
#> 
#> Lambda coefficient:
#>           Estimate Std. Error
#> (lambda) 0.0004124      0.067
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
#> 
#> Family: PL - PE ( 1.7 ) (Power logit power exponential)
#> Estimation method: pML (penalized maximum likelihood)
#> Log-likelihood:   320 on 6 Df
#> Pseudo R-squared: 0.6756
#> Upsilon statistic: 0.04852
#> AIC:  -628
#> Number of iterations in BFGS optimization: 20

The goodness of fit is assessed using diagnostic graphs through the plot method.

plot(fitPL_PE, which = 1:4)

Further details and examples on the R package can be found using the help on R by typing:

help("PLreg")

Reference

Queiroz, F. F. and Ferrari, S. L. P. (2022). Power logit regression for modeling bounded data. :2202.01697.

Copy Link

Version

Install

install.packages('PLreg')

Monthly Downloads

196

Version

0.4.1

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Felipe Queiroz

Last Published

February 16th, 2023

Functions in PLreg (0.4.1)

extra.parameter

Procedure to Select the Extra Parameter for PLreg Objects
PLreg

Power Logit Regression Models for Bounded Variables
influence

Influence Diagnostics for PLreg Objects
CI.lambda

Confidence Interval for the Skewness Parameter
Firm

Firm Cost
plot.PLreg

Diagnostic Plots for PLreg Objects
PLregcontrol

Auxiliary for Controlling PL Fitting
PL

Power Logit Distributions
envelope

Normal Probability Plots with Simulated Envelope of Residuals for PLreg Objects
methodsPLreg

Methods for PLreg Objects
PeruVotes

Peru Blank Votes
bodyfat_Aeolus

Body Fat of Little Brown Bat
residuals.PLreg

Residuals Method for PLreg Objects
sandwich

Sandwich Variance and Covariance Matrix for PLreg Objects