Skip to content

Documentation examples for lm and glm

2 messages · John Fox, Heinz Tuechler

#
Dear Martin,

I think that everyone agrees that it?s generally preferable to use the data argument to lm() and I have nothing significant to add to the substance of the discussion, but I think that it?s a mistake not to add to the current examples, for the following reasons:

(1) Relegating examples using the data argument to ?see also? doesn?t suggest that using the argument is a best practice. Most users won?t bother to click the links.

(2) In my opinion, an new initial example using the data argument would more clearly suggest that this is the normally the best option.

(3) I think that it would also be desirable to add a remark to the explanation of the data argument, something like, ?Although the argument is optional, it's generally preferable to specify it explicitly.? And similarly on the help page for glm().

My two (or three) cents.

John

  -------------------------------------------------
  John Fox, Professor Emeritus
  McMaster University
  Hamilton, Ontario, Canada
  Web: http::/socserv.mcmaster.ca/jfox
#
Dear All,

do you think that use of a data argument is best practice in the example 
below?

regards,

Heinz

### trivial example
plotwithline <- function(x, y) {
     plot(x, y)
     abline(lm(y~x)) ## data argument?
}

set.seed(25)
df0 <- data.frame(x=rnorm(20), y=rnorm(20))

plotwithline(df0[['x']], df0[['y']])



Fox, John wrote/hat geschrieben on/am 17.12.2018 15:21: