From minka at stat.cmu.edu  Wed Jun 25 03:51:26 2003
From: minka at stat.cmu.edu (minka@stat.cmu.edu)
Date: Wed Jun 25 02:51:29 2003
Subject: [Rd] loess "method" bugfix (PR#3332)
Message-ID: <200306250051.h5P0pQJH009641@pubhealth.ku.dk>

There appears to be a bug in loess.  It fails when you specify
"method".  For example:

data(cars)
cars.lo <- loess(dist ~ speed, cars)
# works, and should be the same as:
cars.lo <- loess(dist ~ speed, cars, method="loess")
# but this fails with:
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  : 
        invalid variable type

Included is a possible fix (only one line is added).

Tom


loess <-
function(formula, data=NULL, weights, subset, na.action, model = FALSE,
		   span = 0.75, enp.target, degree = 2, parametric = FALSE,
		    drop.square = FALSE, normalize = TRUE,
		     family = c("gaussian", "symmetric"),
		      method = c("loess", "model.frame"),
		       control = loess.control(...), ...)
{
    family <- match.arg(family)
    method <- match.arg(method)
    mt <- terms(formula, data = data)
    mf <- match.call(expand.dots=FALSE)
    mf$model <- mf$span <- mf$enp.target <- mf$degree <-
      mf$parametric <- mf$drop.square <- mf$normalize <- mf$family <-
        mf$control <- mf$... <- NULL
    # minka: bugfix
    mf$method <- NULL
    mf[[1]] <- as.name("model.frame")
    mf <- eval(mf, parent.frame())
[rest is the same]
}


[Rd] loess "method" bugfix (PR#3332)
minka@stat.cmu.edu