linkLin {glmxdiag} | R Documentation |
Checking linearity of link function
Description
According to Lovison (2014), if the link function is correctly specified then there is a linear relationship between the working response variable z and the linear predictor eta. This plot suggests if the link function is appropriate.
Usage
linkLin(model, smooth = TRUE, xlab, ylab, main, pch, lcol, lwd, ...)
Arguments
model |
a model supported by |
smooth |
logical, whether to plot a smoothing spline. |
xlab |
title for the x axis. |
ylab |
title for the y axis. |
main |
an overall title for the plot. |
pch |
type of points. |
lcol |
color of the smoothing line. |
lwd |
size of the smoothing line. |
... |
further arguments passed to |
Details
The assumption behind the output plot is that the model is correctly specified. In the y-axis there is the working response variable while on the x-axis there is the linear predictor: the more their relationship is linear the more appropriate the link function should be.
Value
Doesn't return a value, called for side effects.
Author(s)
Giuseppe Reale
Examples
## Simulate the data
set.seed(5)
n.obs <- 100
x <- rnorm(n.obs)
shape <- 25
mu <- exp(1 + .5* x)
y <- rgamma(n.obs, rate = shape / mu, shape = shape)
true.mod <- glm(y ~ x, family = Gamma(link = 'log'))
wrong1 <- glm(y ~ x, family = Gamma(link = 'inverse'))
wrong2 <- glm(y ~ x, family = Gamma(link = 'identity'))
par(mfrow = c(2, 2))
linkLin(true.mod)
linkLin(wrong1)
linkLin(wrong2)
par(mfrow = c(1, 1))