MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Slow performance gathering property data from fitted

  • To: mathgroup at
  • Subject: [mg101033] Re: [mg101013] Slow performance gathering property data from fitted
  • From: Bob Hanlon <hanlonr at>
  • Date: Sun, 21 Jun 2009 07:07:33 -0400 (EDT)
  • Reply-to: hanlonr at

Don't use Table

data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};

lm = LinearModelFit[data, x, x];

piedlrmodels = Table[lm, {10000}];

(piedlrRsquared = 
    Table[piedlrmodels[[i]]["RSquared"], {i, 1, 
      Length[piedlrmodels]}]); // Timing


(piedlrRsquared2 = (#["RSquared"] & /@ piedlrmodels)); // Timing


piedlrRsquared == piedlrRsquared2




Bob Hanlon

---- Todd Allen <genesplicer28 at> wrote: 


Hi All,

   During some recent research I asked Mathematica to calculate 70,000 simple linear regression fits to 70,000 small datasets.  This worked well and resulted in a list of 70,000 fitted model objects being finished in under 5 minutes.

  My next step was to collect the RSquared property for each of the 70,000 fits contained in the list, and Mathematica took over 3 hours to accomplish this.  This seems horrendously slow simply to gather values from a list.  Has anyone ran into a similar problem?  Any suggestions how I might be able to significantly speed the gathering of properties from large lists of fitted model objects?

  The snippet of code I was using to gather the RSquared values is below:

piedlrRsquared = 
  Table[piedlrmodels[[i]]["RSquared"], {i, 1, Length[piedlrmodels]}] //

   Thanks for any advice you might have!


  • Prev by Date: Re: Slow performance gathering property data from fitted objects
  • Next by Date: Re: compress lists with mean for equal elements
  • Previous by thread: Re: Number format
  • Next by thread: When to use Module inside Manipulate