fullnormal: This function makes a full normal plot of the elements of the...

Description Usage Arguments Author(s) Examples

View source: R/fullnormal.R

Description

This function makes a full normal plot of the elements of the vector called effects

Usage

1
fullnormal(effects, labs, alpha = 0.05, refline = "TRUE")

Arguments

effects

input - vector of effects to be plotted

labs

input - vector of labels of the effects to be plotted

alpha

input - alpha level for labeling of significant effects using Lenth statistic

refline

input - logical variable that indicates whether a reference line is added to the plot (default is "TRUE")

Author(s)

John Lawson

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Example Separate Normal plots of whole and split plot effects from an unreplicated split-plot 
data(plasma)
sol<-lm(y~A*B*C*D*E,data=plasma)
summary(sol)
# get whole plot effects and split plot effects
effects<-coef(sol)
effects<-effects[c(2:32)]
Wpeffects<-effects[c(1:4, 6:11, 16:19, 26)]
Speffects<-effects[c(5,12:15,20:25,27:31)]

#make separate normal plots
fullnormal(Wpeffects,names(Wpeffects),alpha=.10)
fullnormal(Speffects,names(Speffects),alpha=.05)


## The function is currently defined as
function (effects, labs, alpha = 0.05, refline = "TRUE") 
{
    crit <- LenthPlot(effects, alpha = alpha, plt = FALSE)["ME"]
    names <- names(effects)
    names <- gsub(":", "", names)
    names <- gsub("1", "", names)
    le <- length(effects)
    for (i in 1:le) {
        logc <- (abs(effects[i]) <= crit)
        if (logc) {
            names[i] <- " "
        }
    }
    qqnorm(effects, ylab = "Estimated Effects", xlab = "Normal Scores")
    x <- qqnorm(effects, plot = FALSE)
    zscr <- (x$x)
    effp <- effects[zscr > 0]
    zp <- zscr[zscr > 0]
    namep <- names[zscr > 0]
    effn <- effects[zscr < 0]
    zn <- zscr[zscr < 0]
    namen <- names[zscr < 0]
    text(zp, effp, namep, pos = 1)
    text(zn, effn, namen, pos = 3)
    ahe <- abs(effects)
    s0 <- 1.5 * median(ahe)
    selhe <- ahe < (2.5 * s0)
    pse = 1.5 * median(ahe[selhe])
    if (refline) {
        abline(0, pse)
    }
  }

Example output

Registered S3 method overwritten by 'DoE.base':
  method           from       
  factorize.factor conf.design

Call:
lm(formula = y ~ A * B * C * D * E, data = plasma)

Residuals:
ALL 32 residuals are 0: no residual degrees of freedom!

Coefficients:
               Estimate Std. Error t value Pr(>|t|)
(Intercept)    40.98125         NA      NA       NA
A1              5.91250         NA      NA       NA
B1              2.11250         NA      NA       NA
C1             -1.69375         NA      NA       NA
D1             -7.55000         NA      NA       NA
E1              1.56875         NA      NA       NA
A1:B1          -2.10625         NA      NA       NA
A1:C1           1.48750         NA      NA       NA
B1:C1          -0.42500         NA      NA       NA
A1:D1           8.28125         NA      NA       NA
B1:D1          -1.65625         NA      NA       NA
C1:D1           0.83750         NA      NA       NA
A1:E1          -2.95000         NA      NA       NA
B1:E1          -0.15000         NA      NA       NA
C1:E1          -0.06875         NA      NA       NA
D1:E1           0.51250         NA      NA       NA
A1:B1:C1        1.43125         NA      NA       NA
A1:B1:D1       -1.65000         NA      NA       NA
A1:C1:D1       -1.15625         NA      NA       NA
B1:C1:D1        0.61875         NA      NA       NA
A1:B1:E1        0.05625         NA      NA       NA
A1:C1:E1       -0.08750         NA      NA       NA
B1:C1:E1        0.45000         NA      NA       NA
A1:D1:E1       -0.40625         NA      NA       NA
B1:D1:E1       -0.09375         NA      NA       NA
C1:D1:E1        0.16250         NA      NA       NA
A1:B1:C1:D1     3.42500         NA      NA       NA
A1:B1:C1:E1    -0.21875         NA      NA       NA
A1:B1:D1:E1     0.13750         NA      NA       NA
A1:C1:D1:E1    -0.13125         NA      NA       NA
B1:C1:D1:E1     0.44375         NA      NA       NA
A1:B1:C1:D1:E1  0.12500         NA      NA       NA

Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared:      1,	Adjusted R-squared:    NaN 
F-statistic:   NaN on 31 and 0 DF,  p-value: NA

function (effects, labs, alpha = 0.05, refline = "TRUE") 
{
    crit <- LenthPlot(effects, alpha = alpha, plt = FALSE)["ME"]
    names <- names(effects)
    names <- gsub(":", "", names)
    names <- gsub("1", "", names)
    le <- length(effects)
    for (i in 1:le) {
        logc <- (abs(effects[i]) <= crit)
        if (logc) {
            names[i] <- " "
        }
    }
    qqnorm(effects, ylab = "Estimated Effects", xlab = "Normal Scores")
    x <- qqnorm(effects, plot = FALSE)
    zscr <- (x$x)
    effp <- effects[zscr > 0]
    zp <- zscr[zscr > 0]
    namep <- names[zscr > 0]
    effn <- effects[zscr < 0]
    zn <- zscr[zscr < 0]
    namen <- names[zscr < 0]
    text(zp, effp, namep, pos = 1)
    text(zn, effn, namen, pos = 3)
    ahe <- abs(effects)
    s0 <- 1.5 * median(ahe)
    selhe <- ahe < (2.5 * s0)
    pse = 1.5 * median(ahe[selhe])
    if (refline) {
        abline(0, pse)
    }
}

daewr documentation built on March 13, 2021, 3:01 a.m.