## Pages

### One-dimensional interpolation with R

The function approx() and spline() provide one-dimensional linear and non-linear interpolation with R, respectively. Syntax of them are similar, for example,

x.old <- 1:10
y.old <- rnorm(10)
x.new <- seq(1, 10, 0.001)

# Linear interpolation
y.new.linear <- approx(x.old, y.old, xout = x.new)$y # Forsythe, Malcolm and Moler's spline (default of spline) y.new.fmm <- spline(x.old, y.old, xout = x.new, method = "fmm")$y

# Natural splines
y.new.natural <-
spline(x.old, y.old, xout = x.new, method = "natural")$y # Periodic splines y.new.periodic <- spline(x.old, y.old, xout = x.new, method = "periodic")$y

# Plot
plot(
y.new.fmm ~ x.new,
type="l", col=2, xlab="x", ylab="y",
main="One-dimensional Interpolation with R"
)
lines(y.new.periodic ~ x.new, col=3)
lines(y.new.natural ~ x.new, col=4)
lines(y.new.linear ~ x.new, col=5)
points(y.old ~ x.old)
legend(8, 2, c("fmm", "periodic", "natural", "linear", "old"),
col = c(2:5,1), lty = c(1,1,1,1,0), pch = c(NA,NA,NA,NA,1), merge = T
)

### Nested ANOVA permutation test in R

A R function for the permutation test for onw-way nested design ANOVA.

This work is inspired by Dr. David C. Howell, University of Vermont. In Dr. Howell’s webpage “Permutation Tests for Factorial ANOVA Designs” (http://www.uvm.edu/~dhowell/StatPages/More_Stuff/Permutation%20Anova/PermTestsAnova.html [access on May 28, 2012]), he described the algorithm of permutation test for a one-way nested design ANOVA by using R language. I followed this algorithm and made a R function to do this test.

## Example

dat <- read.csv(textConnection("
trt , unit , obs
1 , 1 , 11
1 , 1 ,  9
1 , 1 ,  9
1 , 2 ,  8
1 , 2 ,  7
1 , 2 ,  6
1 , 3 ,  8
1 , 3 , 10
1 , 3 , 11
2 , 4 , 11
2 , 4 ,  8
2 , 4 ,  7
2 , 5 , 10
2 , 5 , 14
2 , 5 , 12
2 , 6 ,  9
2 , 6 , 10
2 , 6 ,  8
"))