missing value definition

108 views
Skip to first unread message

EB

unread,
Apr 2, 2015, 5:19:08 AM4/2/15
to nwcom...@googlegroups.com
Dear Thomas,

recently I discovered your nice work for an implementation of network analysis tools to STATA. Thanks for your effort.

Regarding also the implementation of ERGM´s I  wonder if within the nwcommands are any options to specify/define missing values (e.g. for the dependent Variable: the adjacency matrix) and if yes, whether dealing with missing values at the dependent variable for ERGM simulations are based on the same methodological procedure as it is with ERGM´s with R?

Do you have some dofile/script examples how to link/combine node attribute data/lists with network data to one joint STATA network file/project? What I have is seperate attribute lists and seperate adjacency matrixes (in .txt format)  for each network and would like to bring them together directly in STATA using the nwcommands....


thanks again,
bye
Enis      


------------
EMPAS - Institute for Empirical and Applied Sociology
Universität Bremen

Thomas Grund

unread,
Apr 14, 2015, 12:37:16 PM4/14/15
to nwcom...@googlegroups.com
Actually, it works exactly like in R, because nwergm uses R in the background. Essentially, it saves the network data as a normal Stata dataset, loads the Stata dataset in R (and makes a network object out of it) and runs the necessary ERGM code before feeding the result back to Stata. Hence, when R opens a Stata dataset with missing values, these missing values show up in the network and your ERGM analysis.

Within Stata, there is no special treatment of missing values other than the one provided by Stata. For example, you can declare the edge value between node 2 and node 3 of a random network as missing like this:

. nwrandom 10, prob(.2) name(mynetwork) // this generates the random network mynetwork
. nwreplace mynetwork[2,3] = .

Concerning the combination of attribute data with networks, just do what Peter suggested. First, build a complete attribute file with "merge". This is normal Stata code and should not be too difficult. Below is the syntax that does something like this when your attribute files are simple text files with one column.


local attributes "age sex"
local maxN = 0

// Transform your .txt in .dta files and add a _id
foreach a in `attributes' {
import delimited "`a'.txt", clear
rename v1 `a'
gen _id = _n
save `a'.dta, replace
if `maxN' < `=_N' {
local maxN = _N 
}
}

// Merge all attribute files together
clear
set obs `maxN'
gen _id = _n

foreach a in `attributes' {
merge 1:1 _id using `a'.dta, nogenerate
}

// Import or use your network
nwuse...
nwimport...


Best,
Thomas
Reply all
Reply to author
Forward
0 new messages