Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matsize too small.

    Dear All,

    I want to initiate an empty column vector with #rows= number of observations. I permanently set the matsize to the maximum, but still get an error saying that the matzise is too small.
    Code:
    .
    .         *initialize the residual variable
    .         gen n=_n
    
    .         egen maxn=max(n)
    
    .         scalar nobs=maxn
    
    .         set matsize 11000, permanently
    (set matsize preference recorded)
    
    .         matrix e2 = J(nobs,1,.)
    matsize too small
        You have attempted to create a matrix with too many rows or columns or attempted to
        fit a model with too many variables.  You need to increase matsize; it is currently
        11000.  Use set matsize; see help matsize.
    
        If you are using factor variables and included an interaction that has lots of
        missing cells, either increase matsize or set emptycells drop to reduce the
        required matrix size; see help set emptycells.
    
        If you are using factor variables, you might have accidentally treated a continuous
        variable as a categorical, resulting in lots of categories.  Use the c. operator on
        such variables.
    r(908);
    
    end of do-file
    
    r(908);
    What am I doing wrong?

    Thanks,
    Sumedha.

  • #2
    Hi Sumedha
    Keep in mind that using Standard Stata interface you can only create matrix up to 11000x11000. So anything larger than that will give you the problem that you have.
    It seems to me that "nobs" must be something larger than this upper limit.
    HTH

    Comment


    • #3
      Hi Fernando,

      You are right . Thank you. So, how should I proceed for :
      Code:
      display nobs
      88012
      ?

      Thank you so much.

      Comment


      • #4
        It depends.
        What is it you want to do?

        Comment


        • #5
          I want to store residuals from predictions in it, followed by calculation of the mean of the residuals stored in the vector. Thank you so much.

          Comment


          • #6
            The purpose in #5 is much better handled by putting residuals in a variable. In any case you would need Stata MP to hold a matrix that big. See

            Code:
            help limits

            Comment


            • #7
              Thank you. I have Stats 16.0 MP. Would MATA be a better approach? I am an experienced user of matrix programming (Ox and Gauss; I know I am dating myself) but new to Stata programming.

              Comment


              • #8
                No. Regardless of Mata, and your experience elsewhere, on the information given my Stata advice is exactly the same. Simple calculations with residuals are best done using variables in Stata.

                The mean residual is usually zero, but leave that on one side, as the point is amplified. If you're looking at groups of residuals, for which the mean may not be zero, that in turn is easily done in Stata with variables.

                Comment

                Working...
                X