The R Project SVN R-packages

Rev

Rev 5793 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5793 Rev 5830
Line 124... Line 124...
124
grav.z <- (grav.boot$t[, 1]-grav.boot$t0[1])/sqrt(grav.boot$t[, 2])
124
grav.z <- (grav.boot$t[, 1]-grav.boot$t0[1])/sqrt(grav.boot$t[, 2])
125
plot(grav.boot, t = grav.z, t0 = 0)
125
plot(grav.boot, t = grav.z, t0 = 0)
126
 
126
 
127
# In this example we look at the one of the partial correlations for the
127
# In this example we look at the one of the partial correlations for the
128
# head dimensions in the dataset frets.
128
# head dimensions in the dataset frets.
129
pcorr <- function(x) { 
-
 
130
#  Function to find the correlations and partial correlations between
-
 
131
#  the four measurements.
-
 
132
     v <- cor(x)
-
 
133
     v.d <- diag(var(x))
-
 
134
     iv <- solve(v)
-
 
135
     iv.d <- sqrt(diag(iv))
-
 
136
     iv <- - diag(1/iv.d) \%*\% iv \%*\% diag(1/iv.d)
-
 
137
     q <- NULL
-
 
138
     n <- nrow(v)
-
 
139
     for (i in 1:(n-1)) 
-
 
140
          q <- rbind( q, c(v[i, 1:i], iv[i, (i+1):n]) )
-
 
141
     q <- rbind( q, v[n, ] )
-
 
142
     diag(q) <- round(diag(q))
-
 
143
     q
-
 
144
}
-
 
145
 
-
 
146
frets.fun <- function(data, i) {
129
frets.fun <- function(data, i) {
-
 
130
    pcorr <- function(x) { 
-
 
131
    #  Function to find the correlations and partial correlations between
-
 
132
    #  the four measurements.
-
 
133
         v <- cor(x)
-
 
134
         v.d <- diag(var(x))
-
 
135
         iv <- solve(v)
-
 
136
         iv.d <- sqrt(diag(iv))
-
 
137
         iv <- - diag(1/iv.d) \%*\% iv \%*\% diag(1/iv.d)
-
 
138
         q <- NULL
-
 
139
         n <- nrow(v)
-
 
140
         for (i in 1:(n-1)) 
-
 
141
              q <- rbind( q, c(v[i, 1:i], iv[i,(i+1):n]) )
-
 
142
         q <- rbind( q, v[n, ] )
-
 
143
         diag(q) <- round(diag(q))
-
 
144
         q
-
 
145
    }
147
     d <- data[i, ]
146
    d <- data[i, ]
148
     v <- pcorr(d)
147
    v <- pcorr(d)
149
     c(v[1, ], v[2, ], v[3, ], v[4, ])
148
    c(v[1,], v[2,], v[3,], v[4,])
150
}
149
}
151
frets.boot <- boot(log(as.matrix(frets)),  frets.fun,  R = 999)
150
frets.boot <- boot(log(as.matrix(frets)),  frets.fun,  R = 999)
152
plot(frets.boot, index = 7, jack = TRUE, stinf = FALSE, useJ = FALSE)
151
plot(frets.boot, index = 7, jack = TRUE, stinf = FALSE, useJ = FALSE)
153
}
152
}
154
\keyword{hplot}
153
\keyword{hplot}