Announcement

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

  • Network matrix

    Hello everyone,

    I’d like to build a network matrix G, where Gij = ni-1, in which ni is the size of the group of individuals (excluding the individual himself). The information about the size of the group is given by the variable “tamanho”. We consider students belonging to the same group only those who are in the same class. The classes are identified by a code given by the variable “turma”. Moreover, we have 5 distincts periods, identified by the variable “onda”. Thus, I want to build a matrix G for each one of the periods. The individuals are identified by the variable “idaluno”. The shape of the database is the following:


    (id student) (id class) (period) (class size)
    idaluno turma onda tamanho
    1 100 1 2
    1 101 2 2
    1 700 3 3
    1 900 4 1
    1 540 5 1
    2 100 1 2
    2 101 2 2
    2 700 3 4
    2 870 4 3
    2 450 5 3
    3 200 1 2
    3 201 2 2
    3 700 3 4
    3 870 4 3
    3 450 5 3
    4 200 1 2
    4 201 2 2
    4 700 3 4
    4 870 4 3
    4 450 5 3

    Thank you for any help!

  • #2
    In other words, I want a code that if i (idaluno) and j (other idaluno) are in the same class (turma), defines gij = 1/tamanho and if i and j are not in the same class,gij = 0 .

    Comment


    • #3
      So you want something like a weighted adjacency matrix?
      1. Maybe this set of tools for network analysis can help (it has utilities that create adj matrices, etc.): https://nwcommands.wordpress.com/getting-started/
      2. How big is your problem? you can probably brute force it with Mata and asarray() if it's not huge

      Comment


      • #4
        Thank you Sergio!

        Yes, I want a wighted adjacency matrix.
        I've tried some nwcommands but it did not work until now.
        My dataset have more than 100,000 observations and the dimension of each matrix will be approximately 20,000 x 20,000. I was trying to create these matrices with brute force with Mata, but I need some help with it.

        thank you again.

        Comment


        • #5
          What will you use these matrices for? There is an example in the help for -asarray- of using it to create a sparse matriz, which might be what you want given the size of your problem.

          Comment


          • #6
            I'm studying the peer effects over academic achievement. So, I want to use these matrices for the estimation of the reduced form of equation: (I-G)Y=β(I-G)GY+γ(I-G)X+δ(I-G)GX+(I-G)ε, under the hypothesis that students interact through a network. I will try -asarray- command.

            Thanks!!

            Comment


            • #7
              Perhaps consider netsis, by Miura (2012) http://econpapers.repec.org/article/...p_3a94-129.htm

              Comment

              Working...
              X