Announcement

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

  • Data management for Network Analysis

    Dear All,
    I am new to this forum but I have been consulting your usefull answers since years. I hope someone has already dealt with my issue.
    I have a large unbalanced panel on international trade and I would like to set up my dataset in order to run a network analysis. I have an ID variable for each observation (Country A exporting a certain "Value" to country B in a given year). The matrix is not symmetric and has from and to columns which give the link "from each from to each to".
    The best routine for my dataset was provided by Fink https://simonfink.files.wordpress.co...h-stata-v1.pdf but unfortunately SONIA software does not exist anymore.

    When I try to follow Cerulli and Zinilli by using datanet, STATA reports a type mismatch error. I have coded
    Code:
    datanet reporter_name partner_name
    , which are both string variables because STATA does not allow me to use numeric variables with datanet.

    Then, I have tried to follow these procedures
    https://stats.idre.ucla.edu/stata/fa...ysis-in-stata/
    https://stats.idre.ucla.edu/stata/co...acency-matrix/
    but I could not find SNA package.

    Finally, I am trying to apply nwcommands. I was able to set up my dataset with command
    Code:
    nwset Reporter_Code Partner_Code Value, name(mynet) edgelist
    but STATA creates a matrix with null values and I cannot change the zeros with my values, neither with dichotomous values. When I try to load and change these values
    Code:
    nwvalue mynet
    I have the error " <istmt>: 3499 nw_mata1 not found r(3499)".

    How can I deal with this?
    Many thanks for every suggestions you give me!

    Giulia
    Last edited by Giulia Rap; 18 Apr 2018, 03:56.

  • #2
    The chances of getting good help here are pretty low if you don't show an example of your data, as is requested in the FAQ all new members are asked to read. Relatively few people can clearly describe data in the abstract. What would help people help you is if you gave an example, using -dataex- per the FAQ, that showed what your input data is like, and another example that shows how you would like your output data to be.

    Comment


    • #3
      Sorry, you are right
      .
      On STATA 14 my dataset looks like this:
      Code:
      input int Reporter_Code str5 Reporter_Name int Partner_Code str59 Partner_Name int Year long Value
      325 "Italy" -700 "Europe"        2015      1049
      325 "Italy"   -2 "All Countries" 1996  12135734
      325 "Italy"   -2 "All Countries" 1996  16496136
      325 "Italy"   -2 "All Countries" 1996   1866896
      325 "Italy"   -2 "All Countries" 1996   8709646
      325 "Italy"   -2 "All Countries" 1996  39684096
      325 "Italy"   -2 "All Countries" 1996  33180888
      325 "Italy"   -2 "All Countries" 1996 135116624
      325 "Italy"   -2 "All Countries" 1996  10616158
      325 "Italy"   -2 "All Countries" 1996  14816319
      325 "Italy"   -2 "All Countries" 1996  27276840
      325 "Italy"   -2 "All Countries" 1996   6339390
      325 "Italy"   -2 "All Countries" 1997  12039440
      325 "Italy"   -2 "All Countries" 1997  28061022
      325 "Italy"   -2 "All Countries" 1997  30396436
      325 "Italy"   -2 "All Countries" 1997  16359505
      325 "Italy"   -2 "All Countries" 1997   4859512
      325 "Italy"   -2 "All Countries" 1997  24725010
      325 "Italy"   -2 "All Countries" 1997  24654734
      325 "Italy"   -2 "All Countries" 1997  32058072
      325 "Italy"   -2 "All Countries" 1997   8949463
      325 "Italy"   -2 "All Countries" 1997   1570326
      325 "Italy"   -2 "All Countries" 1997 113602288
      325 "Italy"   -2 "All Countries" 1998  16664998
      325 "Italy"   -2 "All Countries" 1998   2466358
      325 "Italy"   -2 "All Countries" 1998 125001568
      325 "Italy"   -2 "All Countries" 1998   7844284
      325 "Italy"   -2 "All Countries" 1998   5057721
      325 "Italy"   -2 "All Countries" 1998  10813799
      325 "Italy"   -2 "All Countries" 1998  20930092
      325 "Italy"   -2 "All Countries" 1998  34056452
      325 "Italy"   -2 "All Countries" 1998  27965268
      325 "Italy"   -2 "All Countries" 1998  17472562
      325 "Italy"   -2 "All Countries" 1998  11405440
      325 "Italy"   -2 "All Countries" 1999   9920088
      325 "Italy"   -2 "All Countries" 1999   9785445
      325 "Italy"   -2 "All Countries" 1999   3721668
      325 "Italy"   -2 "All Countries" 1999   1702807
      325 "Italy"   -2 "All Countries" 1999  19663404
      325 "Italy"   -2 "All Countries" 1999  34185067
      325 "Italy"   -2 "All Countries" 1999  15519351
      325 "Italy"   -2 "All Countries" 1999   8841025
      325 "Italy"   -2 "All Countries" 1999  32614163
      325 "Italy"   -2 "All Countries" 1999  18176453
      325 "Italy"   -2 "All Countries" 1999 119233460
      325 "Italy"   -2 "All Countries" 2000  18292983
      325 "Italy"   -2 "All Countries" 2000   3010643
      end
      and I need to transform it into an adjacency matrix in order ro run a network analysis.

      As I said, my attempt was
      Code:
       nwset Reporter_Code Partner_Code Value, name(mynet) edgelist
      and what I get is:

      Code:
      input str4 _nodelab str6 _nodevar int net1 float net2 int net3
      "-700" "net1"      0       0    0
      "-2"   "net2"      0       0    0
      "-1"   "net3"      0       0    0
      "2"    "net4"      0       0    0
      "10"   "net5"      0       0    0
      "11"   "net6"      0       0    0
      "20"   "net7"      0       0    0
      "30"   "net8"      0       0    0
      "31"   "net9"      0       0    0
      "40"   "net10"     0       0    0
      "41"   "net11"     0       0    0
      "42"   "net12"     0       0    0
      "51"   "net13"     0       0    0
      "52"   "net14"     0       0    0
      "53"   "net15"     0       0    0
      "56"   "net16"     0       0    0
      "60"   "net17"     0       0    0
      "68"   "net18"     0       0    0
      "70"   "net19"     0       0    0
      "90"   "net20"     0       0    0
      "91"   "net21"     0       0    0
      "92"   "net22"     0       0    0
      "93"   "net23"     0       0    0
      "94"   "net24"     0       0    0
      "95"   "net25"     0       0    0
      "100"  "net26"     0       0    0
      "101"  "net27"     0       0    0
      "110"  "net28"     0       0    0
      "115"  "net29"     0       0    0
      "130"  "net30"     0       0    0
      "135"  "net31"     0       0    0
      "140"  "net32"     0       0    0
      "145"  "net33"     0       0    0
      "150"  "net34"     0       0    0
      "155"  "net35"     0       0    0
      "160"  "net36"     0       0    0
      "165"  "net37"     0       0    0
      "200"  "net38"     0       0    0
      "205"  "net39"     0       0    0
      "210"  "net40"     0       0    0
      "211"  "net41"     0       0    0
      "212"  "net42"     0       0    0
      "220"  "net43"     0       0    0
      "225"  "net44"     0       0    0
      "230"  "net45"     0       0    0
      "231"  "net46"     0       0    0
      "232"  "net47"     0       0    0
      "235"  "net48"     0       0    0
      "255"  "net49"     0       0    0
      "290"  "net50"     0       0    0
      end
      Instead of zero values, I would like to have the corresponding variable named "Value" or a dichotomous variable taking 1 when the two countries trade.
      Last edited by Giulia Rap; 18 Apr 2018, 08:43.

      Comment


      • #4
        Have you installed all of the different subcommands from nwcommands? I suspect that might be the root of your problem with the mata error.

        Comment

        Working...
        X