Announcement

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

  • Creating a column vector from 5 variables.

    I'm looking to convert 5 separate variables into a single vector and store that vector in a new column. I've uploaded my data below, the idea is at the end I would have a new column named vector_supportpoints that would contain a vector under the following format: "var1 var2 var3 var4 var5". I would then like to calculate the Euclidean Norm of that vector as well as the inner product between vector_supportpoints and a vector that I will create later on which will be named vector_probabilities.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(FSALEGR_LOWEST FSALEGR_LOW FSALEGR_MEDIUM FSALEGR_HIGH FSALEGR_HIGHEST)
     0   1 2.5 5  7
     0   1   5 7 10
     0 1.5   3 7 10
    -3   2   3 7 10
     1   2   4 6 10
    end


    Thanks,
    Matt

  • #2
    You could use Mata for this. Here's a start:

    Code:
    clear
    input float(FSALEGR_LOWEST FSALEGR_LOW FSALEGR_MEDIUM FSALEGR_HIGH FSALEGR_HIGHEST)
     0   1 2.5 5  7
     0   1   5 7 10
     0 1.5   3 7 10
    -3   2   3 7 10
     1   2   4 6 10
    end
    
    mata
    mycol = vec(st_data(. ,  "FSALEGR_LOWEST FSALEGR_LOW FSALEGR_MEDIUM FSALEGR_HIGH FSALEGR_HIGHEST"))
    mycol
    end

    Comment

    Working...
    X