[R] Plots spanning columns

David Scott d.scott at auckland.ac.nz
Thu Aug 28 15:34:13 CEST 2008


On Thu, 28 Aug 2008, Jose Luis Aznarte M. wrote:

>   Hi! I want to plot three graphs (residuals, ACF and PACF of a model). 
> Ideally I would use a c(2,2) disposition where the residuals plot would start 
> at position 1,1 and span to position 1,2. Then I would plot the ACF in 
> position 2,1 and the PACF in position 2,2. Maybe is clearer like this:
>
> --------------------------
> |                        |
> |       residuals        |
> |                        |
> --------------------------
> ------------ -------------
> |          | |           |
> |    ACF   | |   PACF    |
> |          | |           |
> ------------ -------------
>
> Does anyone know if that is possible at all? Cheers!
>


I happened to do virtually that plot just recently. Just had data rather 
than residuals:

### Function to display plot, ACF and PACF
displayTimeSeries <- function(x, heading = NULL,
                               heights = NULL, ...){
     defaultPars <- par(no.readonly = TRUE)
     if (is.null(heading)) {
         heading <- paste("Series: ", deparse(substitute(x)))
     }
     if (is.null(heights)) heights <- c(1,1)
     layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE), heights = heights)
     plot(x, main = heading)
     par(mar = c(5,4,1,2) + 0.1)
     acfVal <-  acf(x, main = "")$acf
     pacfVal <- acf(x, type = "partial", main = "")$acf
     par(defaultPars)
     invisible(list(acf = acfVal, pacf = pacfVal))
}

If you add a line which calculates the residuals and plots them instead of 
the data, then you should have what you want.

David Scott


_________________________________________________________________
David Scott	Department of Statistics, Tamaki Campus
 		The University of Auckland, PB 92019
 		Auckland 1142,    NEW ZEALAND
Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
Email:	d.scott at auckland.ac.nz

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics



More information about the R-help mailing list