Learn R Programming

varycoef (version 0.3.0)

plot.SVC_mle: Plotting Residuals of SVC_mle model

Description

Method to plot the residuals from an SVC_mle object. For this, save.fitted has to be TRUE in SVC_mle_control.

Usage

# S3 method for SVC_mle
plot(x, which = 1:3, legend.pos = "bottomright", ...)

Arguments

x

SVC_mle object

which

numeric, indicating which of the 3 plots should be plotted

legend.pos

character describing the position of the legend in the spatial residual plot, see legend

...

further arguments

Value

a maximum 3 plots

  • Tukey-Anscombe plot, i.e. residuals vs. fitted

  • QQ-plot

  • spatial residuals

See Also

legend SVC_mle

Examples

Run this code
# NOT RUN {
#' ## ---- toy example ----
## sample data
# setting seed for reproducibility
set.seed(123)
m <- 7
# number of observations
n <- m*m
# number of SVC
p <- 3
# sample data
y <- rnorm(n)
X <- matrix(rnorm(n*p), ncol = p)
# locations on a regular m-by-m-grid
locs <- expand.grid(seq(0, 1, length.out = m),
                    seq(0, 1, length.out = m))

## preparing for maximum likelihood estimation (MLE)
# controls specific to MLE
control <- SVC_mle_control(
  # initial values of optimization
  init = rep(0.1, 2*p+1),
  # using profile likelihood
  profileLik = TRUE
)

# controls specific to optimization procedure, see help(optim)
opt.control <- list(
  # number of iterations (set to one for demonstration sake)
  maxit = 1,
  # tracing information
  trace = 6
)

## starting MLE
fit <- SVC_mle(y = y, X = X, locs = locs,
               control = control,
               optim.control = opt.control)

## output: convergence code equal to 1, since maxit was only 1
summary(fit)

## plot residuals
# only QQ-plot
plot(fit, which = 2)

# all three plots next to each other
oldpar <- par(mfrow = c(1, 3))
plot(fit)
par(oldpar)

# }

Run the code above in your browser using DataLab