From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>

Date: Wed 07 Dec 2005 - 04:49:45 EST

%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Dec 07 05:32:41 2005

Date: Wed 07 Dec 2005 - 04:49:45 EST

On Tue, 2005-12-06 at 18:09 +0100, Leo GÃ¼rtler wrote:

> Dear altogether,

<snip>

*>
*

> # here is the difference!!

*> predict(mod, data.frame(x=X), se=TRUE)
**> predict(mod, x=X, se=TRUE)
**>
**>
**> <--- end of snip --->
**>
**> I assume this has some reason but I do not understand this reason.
**> Merci,
*

Not sure if this is the reason, but there is no argument x in predict.loess, and:

a <- predict(mod, se = TRUE)

gives you the same results as:

b <- predict(mod, x=X, se=TRUE)

so the x argument appears to be being passed on/in the ... arguments and ignored? As such, you have no newdata, so mod$x is used.

Now, when you do:

c <- predict(mod, data.frame(x=X), se=TRUE)

You have used an un-named argument in position 2. R takes this to be what you want to use for newdata and so works with this data rather than the one in mod$x as in the first case:

# now named second argument - gets ignored as in a and b d <- predict(mod, x = data.frame(x=X), se=TRUE)

all.equal(a, b) # TRUE all.equal(a, c) # FALSE all.equal(a, d) # TRUE

# this time we assign X to x by using (), the result is used as newdata e <- predict(mod, (x=X), se=TRUE)

all.equal(c, e) # TRUE

If in doubt, name your arguments and check the help! ?predict.loess would have quickly shown you where the problem lay.

**HTH
**
G

*>
**> best regards
**>
**> leo gÃ¼rtler
**>
*

> ______________________________________________

*> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
*

--

%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/London. WC1H 0AP.

%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Dec 07 05:32:41 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:41:30 EST
*