## Animations generated in R version 2.15.2 (2012-10-26) using the package animation
library(scales)
library(animation)
library(ggplot2)
library(devtools)
library(nnet)
library(clusterGeneration)
library(MASS)
for (i in 1:num.it) {
    par(mfrow = c(1, 2), mar = c(0, 0, 1, 0), family = "serif")
    set.seed(5)
    mod.tmp <- nnet(rand.vars[train.dat, ], y[train.dat, 
        , drop = F], size = 10, linout = T, maxit = i, trace = F)
    rel.rsc.tmp <- 1 + 6 * max(abs(mod.tmp$wts))/max(max.wts)
    plot.nnet(mod.tmp, nid = T, rel.rsc = rel.rsc.tmp, alpha.val = 0.8, 
        pos.col = "darkgreen", neg.col = "darkblue", circle.col = "brown", 
        xlim = c(0, 100))
    plot(seq(0, num.it)[c(1:i)], err.dat[, 2][c(1:i)], type = "l", 
        col = "darkgrey", bty = "n", ylim = c(-0.1, 0.4), 
        xlim = c(-15, num.it + 15), axes = F, ylab = "RMSE", 
        xlab = "Iteration", lwd = 2, cex.lab = 1.3)
    axis(side = 1, at = seq(0, num.it, length = 5), line = -4)
    mtext(side = 1, "Iteration", line = -2)
    axis(side = 2, at = c(seq(0, 0.3, length = 4)), line = -3)
    mtext(side = 2, "RMSE", line = -1)
    lines(seq(0, num.it)[c(1:i)], err.dat[c(1:i), 1], type = "l", 
        col = "red", lwd = 2)
    lines(seq(0, num.it)[c(1:i)], err.dat[c(1:i), 2], type = "l", 
        col = "green", lwd = 2)
    title(paste("Iteration", i, "of", num.it), outer = T, 
        line = -2)
}
## R version 2.15.2 (2012-10-26)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Other packages: scales 0.2.3, animation 2.1,
## ggplot2 0.9.3, devtools 1.1, nnet 7.3-5,
## clusterGeneration 1.3.1, MASS 7.3-23