Examples for 'stats::proj'


Projections of Models

Aliases: proj proj.default proj.lm proj.aov proj.aovlist

Keywords: models

### ** Examples

N <- c(0,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0)
P <- c(1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0)
K <- c(1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0)
yield <- c(49.5,62.8,46.8,57.0,59.8,58.5,55.5,56.0,62.8,55.8,69.5,
55.0, 62.0,48.8,45.5,44.2,52.0,51.5,49.8,48.8,57.2,59.0,53.2,56.0)

npk <- data.frame(block = gl(6,4), N = factor(N), P = factor(P),
                  K = factor(K), yield = yield)
npk.aov <- aov(yield ~ block + N*P*K, npk)
proj(npk.aov)
   (Intercept)  block         N          P         K        N:P    N:K
1       54.875 -0.850 -2.808333 -0.5916667 -1.991667  0.9416667  1.175
2       54.875 -0.850  2.808333 -0.5916667  1.991667 -0.9416667  1.175
3       54.875 -0.850 -2.808333  0.5916667  1.991667 -0.9416667 -1.175
4       54.875 -0.850  2.808333  0.5916667 -1.991667  0.9416667 -1.175
5       54.875  2.575  2.808333  0.5916667  1.991667  0.9416667  1.175
6       54.875  2.575  2.808333 -0.5916667 -1.991667 -0.9416667 -1.175
7       54.875  2.575 -2.808333  0.5916667 -1.991667 -0.9416667  1.175
8       54.875  2.575 -2.808333 -0.5916667  1.991667  0.9416667 -1.175
9       54.875  5.900 -2.808333 -0.5916667  1.991667  0.9416667 -1.175
10      54.875  5.900  2.808333 -0.5916667 -1.991667 -0.9416667 -1.175
11      54.875  5.900  2.808333  0.5916667  1.991667  0.9416667  1.175
12      54.875  5.900 -2.808333  0.5916667 -1.991667 -0.9416667  1.175
13      54.875 -4.750  2.808333  0.5916667  1.991667  0.9416667  1.175
14      54.875 -4.750  2.808333 -0.5916667 -1.991667 -0.9416667 -1.175
15      54.875 -4.750 -2.808333  0.5916667 -1.991667 -0.9416667  1.175
16      54.875 -4.750 -2.808333 -0.5916667  1.991667  0.9416667 -1.175
17      54.875 -4.350  2.808333 -0.5916667  1.991667 -0.9416667  1.175
18      54.875 -4.350 -2.808333  0.5916667  1.991667 -0.9416667 -1.175
19      54.875 -4.350  2.808333  0.5916667 -1.991667  0.9416667 -1.175
20      54.875 -4.350 -2.808333 -0.5916667 -1.991667  0.9416667  1.175
21      54.875  1.475  2.808333  0.5916667 -1.991667  0.9416667 -1.175
22      54.875  1.475  2.808333 -0.5916667  1.991667 -0.9416667  1.175
23      54.875  1.475 -2.808333 -0.5916667 -1.991667  0.9416667  1.175
24      54.875  1.475 -2.808333  0.5916667  1.991667 -0.9416667 -1.175
          P:K   Residuals
1   0.1416667 -1.39166667
2  -0.1416667  4.47500000
3   0.1416667 -5.02500000
4  -0.1416667  1.94166667
5   0.1416667 -5.30000000
6   0.1416667  2.80000000
7  -0.1416667  2.16666667
8  -0.1416667  0.33333333
9  -0.1416667  3.80833333
10  0.1416667 -3.22500000
11  0.1416667  1.07500000
12 -0.1416667 -1.65833333
13  0.1416667  4.22500000
14  0.1416667  0.42500000
15 -0.1416667 -0.50833333
16 -0.1416667 -4.14166667
17 -0.1416667 -2.82500000
18  0.1416667  3.17500000
19 -0.1416667 -1.75833333
20  0.1416667  1.40833333
21 -0.1416667 -0.18333333
22 -0.1416667 -1.65000000
23  0.1416667 -0.01666667
24  0.1416667  1.85000000
attr(,"df")
(Intercept)       block           N           P           K         N:P 
          1           5           1           1           1           1 
        N:K         P:K   Residuals 
          1           1          12 
attr(,"formula")
yield ~ block + N * P * K
attr(,"onedf")
[1] FALSE
attr(,"factors")
attr(,"factors")$`(Intercept)`
[1] "(Intercept)"

attr(,"factors")$block
[1] "block"

attr(,"factors")$N
[1] "N"

attr(,"factors")$P
[1] "P"

attr(,"factors")$K
[1] "K"

attr(,"factors")$`N:P`
[1] "N" "P"

attr(,"factors")$`N:K`
[1] "N" "K"

attr(,"factors")$`P:K`
[1] "P" "K"

attr(,"factors")$Residuals
[1] "block"  "N"      "P"      "K"      "Within"

attr(,"call")
aov(formula = yield ~ block + N * P * K, data = npk)
attr(,"t.factor")
      block N P K N:P N:K P:K N:P:K
yield     0 0 0 0   0   0   0     0
block     1 0 0 0   0   0   0     0
N         0 1 0 0   1   1   0     1
P         0 0 1 0   1   0   1     1
K         0 0 0 1   0   1   1     1
attr(,"class")
[1] "aovproj"
## as a test, not particularly sensible
options(contrasts = c("contr.helmert", "contr.treatment"))
npk.aovE <- aov(yield ~  N*P*K + Error(block), npk)
proj(npk.aovE)
(Intercept) :
   (Intercept)
1       54.875
2       54.875
3       54.875
4       54.875
5       54.875
6       54.875
7       54.875
8       54.875
9       54.875
10      54.875
11      54.875
12      54.875
13      54.875
14      54.875
15      54.875
16      54.875
17      54.875
18      54.875
19      54.875
20      54.875
21      54.875
22      54.875
23      54.875
24      54.875
attr(,"df")
attr(,"df")$df
(Intercept) 
          1 

attr(,"onedf")
attr(,"onedf")$onedf
[1] FALSE

attr(,"factors")
attr(,"factors")$`(Intercept)`
[1] "(Intercept)"


block :
       N:P:K  Residuals
1  -1.241667  0.3916667
2  -1.241667  0.3916667
3  -1.241667  0.3916667
4  -1.241667  0.3916667
5   1.241667  1.3333333
6   1.241667  1.3333333
7   1.241667  1.3333333
8   1.241667  1.3333333
9   1.241667  4.6583333
10  1.241667  4.6583333
11  1.241667  4.6583333
12  1.241667  4.6583333
13  1.241667 -5.9916667
14  1.241667 -5.9916667
15  1.241667 -5.9916667
16  1.241667 -5.9916667
17 -1.241667 -3.1083333
18 -1.241667 -3.1083333
19 -1.241667 -3.1083333
20 -1.241667 -3.1083333
21 -1.241667  2.7166667
22 -1.241667  2.7166667
23 -1.241667  2.7166667
24 -1.241667  2.7166667
attr(,"df")
attr(,"df")$df
    N:P:K Residuals 
        1         4 

attr(,"onedf")
attr(,"onedf")$onedf
[1] FALSE

attr(,"factors")
attr(,"factors")$`N:P:K`
[1] "N" "P" "K"

attr(,"factors")$Residuals
[1] "block"


Within :
           N          P         K        N:P    N:K        P:K   Residuals
1  -2.808333 -0.5916667 -1.991667  0.9416667  1.175  0.1416667 -1.39166667
2   2.808333 -0.5916667  1.991667 -0.9416667  1.175 -0.1416667  4.47500000
3  -2.808333  0.5916667  1.991667 -0.9416667 -1.175  0.1416667 -5.02500000
4   2.808333  0.5916667 -1.991667  0.9416667 -1.175 -0.1416667  1.94166667
5   2.808333  0.5916667  1.991667  0.9416667  1.175  0.1416667 -5.30000000
6   2.808333 -0.5916667 -1.991667 -0.9416667 -1.175  0.1416667  2.80000000
7  -2.808333  0.5916667 -1.991667 -0.9416667  1.175 -0.1416667  2.16666667
8  -2.808333 -0.5916667  1.991667  0.9416667 -1.175 -0.1416667  0.33333333
9  -2.808333 -0.5916667  1.991667  0.9416667 -1.175 -0.1416667  3.80833333
10  2.808333 -0.5916667 -1.991667 -0.9416667 -1.175  0.1416667 -3.22500000
11  2.808333  0.5916667  1.991667  0.9416667  1.175  0.1416667  1.07500000
12 -2.808333  0.5916667 -1.991667 -0.9416667  1.175 -0.1416667 -1.65833333
13  2.808333  0.5916667  1.991667  0.9416667  1.175  0.1416667  4.22500000
14  2.808333 -0.5916667 -1.991667 -0.9416667 -1.175  0.1416667  0.42500000
15 -2.808333  0.5916667 -1.991667 -0.9416667  1.175 -0.1416667 -0.50833333
16 -2.808333 -0.5916667  1.991667  0.9416667 -1.175 -0.1416667 -4.14166667
17  2.808333 -0.5916667  1.991667 -0.9416667  1.175 -0.1416667 -2.82500000
18 -2.808333  0.5916667  1.991667 -0.9416667 -1.175  0.1416667  3.17500000
19  2.808333  0.5916667 -1.991667  0.9416667 -1.175 -0.1416667 -1.75833333
20 -2.808333 -0.5916667 -1.991667  0.9416667  1.175  0.1416667  1.40833333
21  2.808333  0.5916667 -1.991667  0.9416667 -1.175 -0.1416667 -0.18333333
22  2.808333 -0.5916667  1.991667 -0.9416667  1.175 -0.1416667 -1.65000000
23 -2.808333 -0.5916667 -1.991667  0.9416667  1.175  0.1416667 -0.01666667
24 -2.808333  0.5916667  1.991667 -0.9416667 -1.175  0.1416667  1.85000000
attr(,"df")
attr(,"df")$df
        N         P         K       N:P       N:K       P:K Residuals 
        1         1         1         1         1         1        12 

attr(,"onedf")
attr(,"onedf")$onedf
[1] FALSE

attr(,"factors")
attr(,"factors")$N
[1] "N"

attr(,"factors")$P
[1] "P"

attr(,"factors")$K
[1] "K"

attr(,"factors")$`N:P`
[1] "N" "P"

attr(,"factors")$`N:K`
[1] "N" "K"

attr(,"factors")$`P:K`
[1] "P" "K"

attr(,"factors")$Residuals
[1] "block"  "Within"

[Package stats version 4.2.3 Index]