s-news
[Top] [All Lists]

Re: Problem with matrix

To: "Saadi, Samir" <Saadi@telfer.uottawa.ca>
Subject: Re: Problem with matrix
From: Bill Dunlap <bill@insightful.com>
Date: Sun, 6 Apr 2008 17:57:52 -0700 (PDT)
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <EBEF03D341A7544EA1481BB1B64FA6760122CF72@SoM-Exchange.management.uottawa.ca>
References: <20080318102725.aa8924c5d28ca71e2a043bb294e795eb.c614248f21.wbe@email.secureserver.net> <EBEF03D341A7544EA1481BB1B64FA6760122CF72@SoM-Exchange.management.uottawa.ca>
On Fri, 4 Apr 2008, Saadi, Samir wrote:

> Below is the problem I met after running  three commands in sequence.
> It says "Unable to obtain requested dynamic memory ". What am I doing
> wrong?
>
> The following three commands are used to generate one simulated
> sample (a matrix of 2283 rows and 10 columns)
>
> Run : VAsia10.sim=array(0, c(2283,10))
>   (Implementing this line generates a matrix with 2283 rows and 10 columns,
>    each element is set initial value 0)
>
> Run: tmp=simulate(VAsia10.dvec, n=2283)
>  ( This is used to simulate 10 variable time series of length 2283.
>    the following is the summary result for tmp
>
> summary(tmp)
>     Length Class    Mode
>  et  22830       numeric
> V.t 228300       numeric
>
> Run: VAsia10.sim=matrix(tmp, byrow=F, nrow=2283, ncol=10)
>   (transform the simulated series (tmp) into a matrix defined above
>    in the first command as VAsia10.sim. Implementing this line however
>    displays the error: Problem: Unable to obtain requested dynamic memory

tmp is a list of length 2, with elements of length 22830 and 228300.
Applying matrix(tmp, myrow=FALSE, nrow=2283, ncol=10) extends, by
repetition, this list to length 22830 so it will have 22830/2 *
(22830+228300) 2866648950 numbers in it.  At 8 bytes/number this is
more than 2^34 bytes, more than a 32-bit machine and handle.

You probably wanted to make a matrix out of one or both of the elements
of tmp, not tmp itself.  E.g.,
    z <- matrix(tmp$et, byrow=F, nrow=2283, ncol=10)

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."

<Prev in Thread] Current Thread [Next in Thread>