knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "90%", fig.align = "center", fig.asp = 0.61 )
sdlrm
: Modified SDL Regression for Integer-Valued and Paired Count DataRodrigo M. R. de Medeiros
Universidade Federal do Rio Grande do Norte, UFRN rodrigo.matheus@ufrn.br
Implementation of the modified SDL regression model proposed by Medeiros and Bourguignon (2025). The sdlrm
package provide a set of functions for a complete analysis of integer-valued data, in which it is assumed that the dependent variable follows a modified skew discrete Laplace (SDL) distribution. This regression model is useful for the analysis of integer-valued data and experimental studies in which paired discrete observations are collected.
You can install the current development version of sdlrm
from GitHub with:
devtools::install_github("rdmatheus/sdlrm")
To run the above command, it is necessary that the devtools
package is previously installed on R. If not, install it using the following command:
install.packages("devtools")
After installing the devtools package, if you are using Windows, install the most current RTools program. Finally, run the command devtools::install_github("rdmatheus/sdlrm")
, and then the package will be installed on your computer.
This package provide complete estimation and inference for the parameters as well as normal probability plots of residuals with a simulated envelope, useful for assessing the goodness-of-fit of the model. The implementation is straightforward and similar to other popular packages, like betareg
and glm
, where the main function is sdlrm()
. Below is an example of some functions usage and available methods.
# Loading the sdlrm package library(sdlrm) # Data visualization (Description: ?pss)
# Fit a double model (mean and dispersion) fit0 <- sdlrm(difference ~ group | group, data = pss) # Print fit0 # Summary summary(fit0)
By default, the mode ($\xi$) of the modified SDL distribution is fixed at $\xi = 0$. It is possible to specify a non-zero mode (it must be an integer value) using the xi
argument. Alternatively, this parameter can be estimated via profile likelihood using the choose_mode()
function:
## Mode estimation via profile likelihood mode_estimation <- choose_mode(fit0)
The mode_estimation
object, of class “choose_mode”
, consists of a list whose elements represent a modified SDL regression fit for each value specified for the mode (by default, the sequence $-5, -4, \ldots, 4, 5$). We see that $\xi = 1$ generates the highest profiled likelihood.
## Double model with xi = 1 fit1 <- mode_estimation[[1]]
The constant dispersion test in the modified SDL regression can be performed with the disp_test()
function:
## Test for constant dispersion disp_test(fit1)
The tests do not reject the null hypothesis of constant dispersion. We can then specify an adjustment with regressors only on the mean:
## Fit with constant dispersion and mode = 1 fit <- sdlrm(difference ~ group, data = pss, xi = 1) ## Summary summary(fit)
Currently, the methods implemented for "sdlrm"
objects are
methods(class = "sdlrm")
The plot()
method provides diagnostic plots of the residuals. By default, randomized quantile residuals are used:
par(mfrow = c(1, 2)) plot(fit, ask = FALSE) par(mfrow = c(1, 1))
The envelope()
function plots the normal probability of the residuals with a simulated envelope:
## Building the envelope plot envel <- envelope(fit, plot = FALSE) par(mfrow = c(1, 2)) # Plot for the randomized quantile residuals (default) plot(envel) # Plot for the Pearson residuals plot(envel, type = "pearson") par(mfrow = c(1, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.