envelope.glm | R Documentation |
Produces a normal QQ-plot with simulated envelope of residuals for generalized linear models.
## S3 method for class 'glm'
envelope(
object,
rep = 25,
conf = 0.95,
type = c("quantile", "deviance", "pearson"),
standardized = FALSE,
plot.it = TRUE,
identify,
...
)
object |
an object of the class glm. |
rep |
an (optional) positive integer which allows to specify the number of replicates which should be used to build the simulated envelope. As default, |
conf |
an (optional) value in the interval (0,1) indicating the confidence level which should be used to build the pointwise confidence intervals, which form the envelope. As default, |
type |
an (optional) character string indicating the type of residuals which should be used. The available options are: randomized quantile ("quantile"), deviance ("deviance") and pearson ("pearson") residuals. As default, |
standardized |
an (optional) logical switch indicating if the residuals should be standardized by dividing by the square root of |
plot.it |
an (optional) logical switch indicating if the normal QQ-plot with simulated envelope of residuals is required or just the data matrix in which it is based. As default, |
identify |
an (optional) positive integer indicating the number of individuals to identify on the QQ-plot with simulated envelope of residuals. This is only appropriate if |
... |
further arguments passed to or from other methods. If |
In order to construct the simulated envelope, rep
independent realizations of the response variable for each individual are simulated, which is
done by considering (1) the model assumption about the distribution of the response variable; (2) the estimation of the linear predictor parameters; and (3)
the estimation of the dispersion parameter. Each time, the vector of observed responses is replaced with one of the simulated samples, re-fitting the interest
model rep
times. For each i=1,2,...,n
, where n
is the number of individuals in the sample, the i
-th order statistic of the
type
-type residuals is computed and then sorted for each replicate, giving a random sample of size rep
of the i
-th order statistic. In
other words, the simulated envelope is comprised of the quantiles (1 - conf
)/2 and (1 + conf
)/2 of the random sample of size rep
of the
i
-th order statistic of the type
-type residuals for i=1,2,...,n
.
A matrix with the following four columns:
Lower limit | the quantile (1 - conf )/2 of the random sample of size rep of the i -th order |
statistic of the type -type residuals for i=1,2,...,n , |
|
Median | the quantile 0.5 of the random sample of size rep of the i -th order |
statistic of the type -type residuals for i=1,2,...,n , |
|
Upper limit | the quantile (1 + conf )/2 of the random sample of size rep of the i -th order |
statistic of the type -type residuals for i=1,2,...,n , |
|
Residuals | the observed type -type residuals, |
Atkinson A.C. (1985) Plots, Transformations and Regression. Oxford University Press, Oxford.
Davison A.C., Gigli A. (1989) Deviance Residuals and Normal Scores Plots. Biometrika 76, 211-221.
Dunn P.K., Smyth G.K. (1996) Randomized Quantile Residuals. Journal of Computational and Graphical Statistics 5, 236-244.
Pierce D.A., Schafer D.W. (1986) Residuals in Generalized Linear Models. Journal of the American Statistical Association 81, 977-986.
Wei B.C. (1998). Exponential Family Nonlinear Models. Springer, Singapore.
envelope.lm, envelope.gnm, envelope.overglm
###### Example 1:
burn1000 <- aplore3::burn1000
burn1000 <- within(burn1000, death <- factor(death, levels=c("Dead","Alive")))
fit1 <- glm(death ~ age*inh_inj + tbsa*inh_inj, family=binomial("logit"), data=burn1000)
envelope(fit1, rep=50, conf=0.95, type="pearson", col="red", pch=20, col.lab="blue",
col.axis="blue", col.main="black", family="mono", cex=0.8)
###### Example 2: Fuel consumption of automobiles
Auto <- ISLR::Auto
fit2 <- glm(mpg ~ horsepower*weight, family=inverse.gaussian("log"), data=Auto)
envelope(fit2, rep=50, conf=0.95, type="pearson", col="red", pch=20, col.lab="blue",
col.axis="blue", col.main="black", family="mono", cex=0.8)
###### Example 3: Skin cancer in women
data(skincancer)
fit3 <- glm(cases ~ city + ageC, offset=log(population), family=poisson, data=skincancer)
envelope(fit3, rep=100, conf=0.95, type="quantile", col="red", pch=20,col.lab="blue",
col.axis="blue",col.main="black",family="mono",cex=0.8)
###### Example 4: Self diagnozed ear infections in swimmers
data(swimmers)
fit4 <- glm(infections ~ frequency + location, family=poisson(log), data=swimmers)
envelope(fit4, rep=100, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
col.axis="blue", col.main="black", family="mono", cex=0.8)
###### Example 5: Agents to stimulate cellular differentiation
data(cellular)
fit5 <- glm(cbind(cells,200-cells) ~ tnf + ifn, family=binomial(logit), data=cellular)
envelope(fit5, rep=100, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
col.axis="blue", col.main="black", family="mono", cex=0.8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.