Re: [Rd] Randomness not due to seed

From: William Dunlap <wdunlap_at_tibco.com>
Date: Tue, 19 Jul 2011 22:06:11 +0000

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

> -----Original Message-----
> From: r-devel-bounces_at_r-project.org [mailto:r-devel-bounces_at_r-project.org] On Behalf Of jeroen00ms
> Sent: Tuesday, July 19, 2011 6:13 AM
> To: r-devel_at_r-project.org
> Subject: [Rd] Randomness not due to seed
>
> I am working on a reproducible computing platform for which I would like to
> be able to _exactly_ reproduce an R object. However, I am experiencing
> unexpected randomness in some calculations. I have a hard time finding out
> exactly how it occurs. The code below illustrates the issue.
>
> mylm1 <- lm(dist~speed, data=cars);
> mylm2 <- lm(dist~speed, data=cars);
> identical(mylm1, mylm2); #TRUE
>
> makelm <- function(){
> return(lm(dist~speed, data=cars));
> }
>
> mylm1 <- makelm();
> mylm2 <- makelm();
> identical(mylm1, mylm2); #FALSE
>
> When inspecting both objects there seem to be some rounding differences.
> Setting a seed does not make a difference. Is there any way I can remove
> this randomness and exactly reproduce the object every time?

>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Randomness-not-due-to-seed-
> tp3678082p3678082.html
> Sent from the R devel mailing list archive at Nabble.com.
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 19 Jul 2011 - 22:10:01 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Jul 2011 - 01:40:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive