residuals.Mort2Dsmooth: Extract 2D P-splines Model Residuals

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Extracting different types of residuals from a Mort2Dsmooth object.

Usage

1
2
3
4
## S3 method for class 'Mort2Dsmooth'
residuals(object,
          type = c("deviance", "pearson",
                   "anscombe", "working"), ...)

Arguments

object

An object of class "Mort2Dsmooth", usually, a result of a call to Mort2Dsmooth.

type

The type of residuals which should be returned. The alternatives are: "deviance" (default), "anscombe", "pearson" and "working".

...

Further arguments passed to or from other methods. Not in used. Not in use.

Details

The references define the types of residuals.

The way of computing the residuals are described in Section 2.4 of McCullagh and Nelder's book. The working residuals are merely the differences between fitted and actual counts.

Value

A matrix of the selected type of residuals over both the x and the y axes in the Mort2Dsmooth object.

Author(s)

Carlo G Camarda

References

Davison, A. C. and Snell, E. J. (1991). Residuals and diagnostics. In: Statistical Theory and Modelling. In Honour of Sir David Cox, FRS, eds. Hinkley, D. V., Reid, N. and Snell, E. J., Chapman & Hall.

McCullagh P. and Nelder, J. A. (1989). Generalized Linear Models. London: Chapman & Hall.

See Also

Mort2Dsmooth for computing Mort2Dsmooth.object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## selected data
ages <- 30:80
years <- 1970:2006
death <- selectHMDdata("Switzerland", "Deaths",
                       "Males",
                       ages = ages, years = years) 
exposure <- selectHMDdata("Switzerland", "Exposures",
                          "Males",
                          ages = ages, years = years)
## fit
fit <- Mort2Dsmooth(x=ages, y=years, Z=death,
                    offset=log(exposure),
                    method=3, lambdas=c(300,10))

## extracting residuals
devR <- resid(fit, type="deviance")
ansR <- resid(fit, type="anscombe")
peaR <- resid(fit, type="pearson")
worR <- resid(fit, type="working")

## plotting deviance residuals over age and years
res.list <- list(ages=ages, years=years)
res.grid <- expand.grid(res.list)
res.grid$dev <- c(devR)
levelplot(dev~years*ages, res.grid,
          at=c(min(devR), -2, -1, 1, 2, max(devR)))

Example output

Loading required package: svcm
Loading required package: Matrix
Loading required package: splines
Loading required package: lattice

MortalitySmooth documentation built on May 2, 2019, 6:07 a.m.