Learn R Programming

LaMa (version 2.0.5)

plot.LaMaResiduals: Plot pseudo-residuals

Description

Plot pseudo-residuals computed by pseudo_res.

Usage

# S3 method for LaMaResiduals
plot(x, hist = FALSE, col = "darkblue", lwd = 1.5, main = NULL, ...)

Value

NULL, plots the pseudo-residuals in a 2- or 3-panel layout

Arguments

x

pseudo-residuals as returned by pseudo_res

hist

logical, if TRUE, adds a histogram of the pseudo-residuals

col

character, color for the QQ-line (and density curve if histogram = TRUE)

lwd

numeric, line width for the QQ-line (and density curve if histogram = TRUE)

main

optional character vector of main titles for the plots of length 2 (or 3 if histogram = TRUE)

...

currently ignored. For method consistency

Examples

Run this code
## pseudo-residuals for the trex data
step = trex$step[1:200]

nll = function(par){
  getAll(par)
  Gamma = tpm(logitGamma)
  delta = stationary(Gamma)
  mu = exp(logMu); REPORT(mu)
  sigma = exp(logSigma); REPORT(sigma)
  allprobs = matrix(1, length(step), 2)
  ind = which(!is.na(step))
  for(j in 1:2) allprobs[ind,j] = dgamma2(step[ind], mu[j], sigma[j])
  -forward(delta, Gamma, allprobs)
}

par = list(logitGamma = c(-2,-2), 
           logMu = log(c(0.3, 2.5)), 
           logSigma = log(c(0.3, 0.5)))
           
obj = MakeADFun(nll, par)
opt = nlminb(obj$par, obj$fn, obj$gr)

mod = obj$report()

pres = pseudo_res(step, "gamma2", list(mean = mod$mu, sd = mod$sigma),
                  mod = mod)
                  
plot(pres)

Run the code above in your browser using DataLab