% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dpit_tweedie.R
\name{dpit_tweedie}
\alias{dpit_tweedie}
\title{Residuals for regression models with tweedie outcomes}
\usage{
dpit_tweedie(y, mu, xi, phi, plot=TRUE, scale="normal", line_args=list(), ...)
}
\arguments{
\item{y}{Observed outcome vector.}

\item{mu}{Vector of fitted mean values of each outcomes.}

\item{xi}{Value of \eqn{\xi} such that the variance is \eqn{Var[Y] = \phi\mu^\xi}}

\item{phi}{Dispersion parameter \eqn{\phi}.}

\item{plot}{A logical value indicating whether or not to return QQ-plot
The sample quantiles of the residuals are plotted against}

\item{scale}{You can choose the scale of the residuals among \code{normal} and \code{uniform}.
the theoretical quantiles of a standard normal distribution under the normal scale,
and against the theoretical quantiles of a uniform (0,1) distribution under the uniform scale.
The default scale is \code{normal}.}

\item{line_args}{A named list of graphical parameters passed to
\code{graphics::abline()} to modify the reference (red) 45° line
in the QQ plot. If left empty, a default red dashed line is drawn.}

\item{...}{Additional graphical arguments passed to
\code{stats::qqplot()} for customizing the QQ plot (e.g., \code{pch},
\code{col}, \code{cex}, \code{xlab}, \code{ylab}).}
}
\value{
DPIT residuals.
}
\description{
Computes DPIT residuals for Tweedie-distributed outcomes using the observed responses (\code{y}),
their fitted mean values (\code{mu}), the variance power parameter
(\eqn{\xi}), and the dispersion parameter (\eqn{\phi}).
}
\details{
For formulation details on semicontinuous outcomes, see \code{\link{dpit}}.
}
\examples{
## Tweedie model
library(tweedie)
library(statmod)
n <- 300
x11 <- rnorm(n)
x12 <- rnorm(n)
beta0 <- 5
beta1 <- 1
beta2 <- 1
lambda1 <- exp(beta0 + beta1 * x11 + beta2 * x12)
y1 <- rtweedie(n, mu = lambda1, xi = 1.6, phi = 10)
# Choose parameter p
# True model
model1 <-
  glm(y1 ~ x11 + x12,
    family = tweedie(var.power = 1.6, link.power = 0)
  )
y1 <- model1$y
p.max <- get("p", envir = environment(model1$family$variance))
lambda1f <- model1$fitted.values
phi1f <- summary(model1)$dis
resid.tweedie <- dpit_tweedie(y= y1, mu=lambda1f, xi=p.max, phi=phi1f)
}
