I was surprised by the following (R 1.8.0): R> lm.fit = lm(y~x, data.frame(x=1:10, y=1:10)) R> predict(lm.fit, data.frame(x = rep(NA, 10))) 1 2 3 4 5 -1.060998e-314 -1.060998e-314 -1.060998e-314 -1.060998e-314 -1.060998e-314 6 7 8 9 10 0.000000e+00 1.406440e-269 6.715118e-265 4.940656e-323 1.782528e-265 R> predict(lm.fit, data.frame(x = as.numeric(rep(NA, 10)))) 1 2 3 4 5 6 7 8 9 10 NA NA NA NA NA NA NA NA NA NA shouldn't the first predict() call return NA's, or else issue an error message? -- Edzer
On Mon, 10 Nov 2003, Edzer J. Pebesma wrote:> I was surprised by the following (R 1.8.0): > > R> lm.fit = lm(y~x, data.frame(x=1:10, y=1:10)) > R> predict(lm.fit, data.frame(x = rep(NA, 10))) > 1 2 3 4 5 > -1.060998e-314 -1.060998e-314 -1.060998e-314 -1.060998e-314 -1.060998e-314 > 6 7 8 9 10 > 0.000000e+00 1.406440e-269 6.715118e-265 4.940656e-323 1.782528e-265 > R> predict(lm.fit, data.frame(x = as.numeric(rep(NA, 10)))) > 1 2 3 4 5 6 7 8 9 10 > NA NA NA NA NA NA NA NA NA NA > > shouldn't the first predict() call return NA's, or else issue an error > message?The prediction methods do not in general check that new variables you give are of the correct type: the type used in the fit is not recorded in the model object. In this case a logical column will `work' provided it has two values (even with NAs). We can probably trap this exact case, but there will remain a lot of scope for user error. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hello, How do I tell R not to place a label on an axis when using the "plot" command? Thank you, Ann Loraine
Spencer Graves
2003-Nov-11 01:20 UTC
[R] plot w/o axes [was: predict.lm with (logical) NA vector]
e.g.: plot(1:2, axes=F) axis(1) spencer graves Ann Loraine wrote:> Hello, > > How do I tell R not to place a label on an axis when using the "plot" > command? > > Thank you, > > Ann Loraine > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Thomas W Blackwell
2003-Nov-11 02:34 UTC
[R] plot w/o axes [was: predict.lm with (logical) NA vector]
Ann - Maybe you are looking for plot( ..., xlab="", ylab="") followed by title(xlab="the real x axis label") title(ylab="the real y axis label", mgp=c(2.5,0.5,0)) This is a construction that I use all, all, all the time. - tom blackwell - u michigan medical school - ann arbor - On Mon, 10 Nov 2003, Ann Loraine wrote:> How do I tell R not to place a label on an axis when using the "plot" > command?