Skip to content
Prev 40812 / 63421 Next

Randomness not due to seed

Did you actually see some rounding differences?

The lm objects made in the calls to maklm will
differ in the environments attached to the formula
(because you made the formula in the function).  If
I change both copies of that .Environment attribute
to .GlobalEnv (or any other environment), then identical
reports the objects are the same:

  > attr(attr(mylm1$model, "terms"), ".Environment") <- .GlobalEnv
  > attr(mylm1$terms, ".Environment") <- .GlobalEnv
  > attr(attr(mylm2$model, "terms"), ".Environment") <- .GlobalEnv
  > attr(mylm2$terms, ".Environment") <- .GlobalEnv
  > identical(mylm1, mylm2)
  [1] TRUE 

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com