Debian Codegraph @

R/p.res.2x.formula.R

raw
1 if(FALSE) ##: This is not yet ready for prime time
2 ## NOTE we have had p.res.2x(x,y,z, ...) forever in --> ./p.res.2x.WSt.R
3 ## --- ~~~~~~~~~ ------- ~~~~~~~~~~~~~~~
4 p.res.2x.formula <- ## Change the name ; no 'lm'
5 ## take graphics:::mosaicplot.formula() as example
6 function(formula = ~., data, restricted = NULL, size = 1,
7 slwd = 1, scol = 2,
8 xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, ...)
9 {
10 ## Purpose: plot residuals vs. two x's
11 ## Author: ARu , Date: 11/Jun/91
12 ## Aenderungen: MMae, 30/Jan/92, Dez.94 / WSt
13 ## --------------------------------------------------------------------------
14 ## Arguments:
15 ## formula formula defining the variables zu be used, either
16 ## z ~ x + y
17 ## ~ x + y in this case, data must inherit from lm ,
18 ## and the residuals of data will be used as z .
19 ## data a data.frame or an lm or aov object.
20 ## In the latter case, g.rex2x will look for the data
21 ## that was used to fit the model.
22 ## restricted absolute value which truncates the size.
23 ## The corresponding symbols are marked by stars.
24 ## size the symbols are scaled so that 'size' is the size of
25 ## the largest symbol in cm.
26 ## slwd, scol line width and color to be used for the symbols
27 ## ... additional arguments for the S-function 'plot'
28 ## EXAMPLE :
29 ## g.res2x(zz~.,data=data.frame(xx=rep(1:10,7),yy=rep(1:7, rep(10,7)),
30 ## zz=rnorm(70)), restr = 2, main = "i.i.d. N(0,1) random residuals")
31 ## --------------------------------------------------------------------------
32 formula <- as.formula(formula)
33 if (inherits(data,"lm")) {
34 t.d <- get(as.character(data$call[3]))
35 if (length(formula) < 3) {
36 formula <- update.formula(formula,residuals~.)
37 t.d <- f.merge1(t.d,resid(data),namefrom = "residuals")
38 }
39 } else t.d <- data
40 if (!is.data.frame(t.d)) {
41 if(is.matrix(data)) data <- as.data.frame(data) else
42 stop("data is not a data frame or 'lm' object")
43 }
44 t.d <- na.omit(model.frame(formula, t.d))
45 z <- t.d[,1]
46 x <- as.numeric(t.d[,2])
47 y <- as.numeric(t.d[,3])
48 if(is.null(xlab)) xlab <- names(t.d)[2]
49 if(is.null(ylab)) ylab <- names(t.d)[3]
50
51 p.res.2x.numeric(x,y,z, restricted=restricted, size=size, slwd=slwd, scol=scol,
52 xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim, ...)
53 }
54