Announcement

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

  • Evaluating multivariable functions in Stata

    I'm wondering if Stata can evaluate multivariable functions. Specifically, I have a function that has 5 variables with each variable taking 5 values each. Can Stata generate all the possible values (combination of 5 variables with 5 possible values each results to 625 values) of the function?

    Thanks.

  • #2
    Why not? First you need a dataset or matrix with 625 observations or rows. If a dataset, note that fillin can be a time-saver.

    Comment


    • #3
      Welcome to Statalist.

      5 variables with 5 possible values each results in 5^5 = 3125 combinations. Here is an example of generating all 3125 combinations.
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(v1 v2 v3 v4 v5)
      11 21 31 41 51
      12 22 32 42 52
      13 23 33 43 53
      14 24 34 44 54
      15 25 35 45 55
      end
      fillin v1 v2 v3 v4 v5
      drop _fillin
      describe
      list if _n<=5 | _n>3120
      Code:
      . describe
      
      Contains data
        obs:         3,125                          
       vars:             5                          
       size:        62,500                          
      ------------------------------------------------------------------------------------------------
                    storage   display    value
      variable name   type    format     label      variable label
      ------------------------------------------------------------------------------------------------
      v1              float   %9.0g                 
      v2              float   %9.0g                 
      v3              float   %9.0g                 
      v4              float   %9.0g                 
      v5              float   %9.0g                 
      ------------------------------------------------------------------------------------------------
      Sorted by: v1  v2  v3  v4  v5
           Note: Dataset has changed since last saved.
      
      . list if _n<=5 | _n>3120
      
            +------------------------+
            | v1   v2   v3   v4   v5 |
            |------------------------|
         1. | 11   21   31   41   51 |
         2. | 11   21   31   41   52 |
         3. | 11   21   31   41   53 |
         4. | 11   21   31   41   54 |
         5. | 11   21   31   41   55 |
            |------------------------|
      3121. | 15   25   35   45   51 |
      3122. | 15   25   35   45   52 |
      3123. | 15   25   35   45   53 |
      3124. | 15   25   35   45   54 |
      3125. | 15   25   35   45   55 |
            +------------------------+

      Comment

      Working...
      X