jgscott/SSC383D — pull request #2 by capnrefsmmat (2013-02-25 18:47:16+00:00)
Title: add backfitting example code

Here's my backfitting code.

Note that in `poly-kernel-smoother.R` I added `force(xs)` and `force(ys)` on lines 21-22. This turned out to be necessary to get the code working. Lines 53-54 of `backfit.R` call the smoothing function with the appropriate data, but R passes the data by "promise" -- it doesn't evaluate `kthPartials` immediately. But `kthPartials` depends on the functions in `fs`, and so when I try to use the fit functions to evaluate the error in line 57, it tries to evaluate the fit functions and finds that first it needs to calculate `kthPartials`, and hence it needs to evaluate the fit functions. But to evaluate the fit functions it first needs to calculate `kthPartials`. Whoops. Hence it implodes.

`force()` tells R to evaluate the argument immediately, rather than later, and prevents the whole thing from happening.

Try removing the `force()` calls and you'll get the baffling error message I played with for a few hours yesterday.

(Make sure your working directory is set to the location of the source)

- Alex