gof-package: Model-diagnostics based on cumulative residuals

Description Author(s) References See Also Examples

Description

Model-diagnostics based on cumulative residuals

Author(s)

Klaus K. Holst <kkho@biostat.ku.dk>

References

D.Y. Lin and L.J. Wei and Z. Ying (2002) Model-Checking Techniques Based on Cumulative Residuals. Biometrics, Volume 58, pp 1-12.

John Q. Su and L.J. Wei (1991) A lack-of-fit test for the mean function in a generalized linear model. Journal. Amer. Statist. Assoc., Volume 86, Number 414, pp 420-426.

See Also

cox.aalen in the timereg-package for similar GoF-methods for survival-data.

Examples

1

Example output

Loading 'gof' version 0.9.1

cumres> sim1 <- function(n=100, f=function(x1,x2) {10+x1+x2^2}, sd=1, seed=1) {
cumres+   if (!is.null(seed))
cumres+     set.seed(seed)
cumres+   x1 <- rnorm(n);
cumres+   x2 <- rnorm(n)
cumres+   X <- cbind(1,x1,x2)
cumres+   y <- f(x1,x2) + rnorm(n,sd=sd)
cumres+   d <- data.frame(y,x1,x2)
cumres+   return(d)
cumres+ }

cumres> d <- sim1(100); l <- lm(y ~ x1 + x2,d)

cumres> system.time(g <- cumres(l, R=100, plots=50))
   user  system elapsed 
  0.086   0.003   0.100 

cumres> g

Kolmogorov-Smirnov-test: p-value=0.32
Cramer von Mises-test: p-value=0.36
Based on 100 realizations. Cumulated residuals ordered by predicted-variable.
---
Kolmogorov-Smirnov-test: p-value=0.51
Cramer von Mises-test: p-value=0.26
Based on 100 realizations. Cumulated residuals ordered by x1-variable.
---
Kolmogorov-Smirnov-test: p-value=0
Cramer von Mises-test: p-value=0
Based on 100 realizations. Cumulated residuals ordered by x2-variable.
---

cumres> ## No test: 
cumres> ##D plot(g)
cumres> ## End(No test)
cumres> g1 <- cumres(l, c("y"), R=100, plots=50)

cumres> g1

Kolmogorov-Smirnov-test: p-value=0.26
Cramer von Mises-test: p-value=0.32
Based on 100 realizations. Cumulated residuals ordered by predicted-variable.
---

cumres> g2 <- cumres(l, c("y"), R=100, plots=50, b=0.5)

cumres> g2

Kolmogorov-Smirnov-test: p-value=0.39
Cramer von Mises-test: p-value=0.21
Based on 100 realizations. Cumulated residuals ordered by predicted-variable.
---

gof documentation built on May 2, 2019, 5:52 p.m.