opar = par(mar = c(5, 4, 0.5, 0.1))
oopt = ani.options(interval = 0.3, nmax = 50)
# default animation: with slope changing
least.squares()
# intercept changing
least.squares(ani.type = "i")
par(opar)
# save the animation in HTML pages
ani.options(ani.height = 450, ani.width = 600,
title = "Demonstration of Least Squares",
description = "We want to find an estimate for the slope
in 50 candidate slopes, so we just compute the RSS one by one. ")
ani.start()
par(mar = c(4, 4, 0.5, 0.1), mgp = c(2, 0.5, 0), tcl = -0.3)
least.squares()
ani.stop()
ani.options(oopt)
Run the code above in your browser using DataLab