代码代写|MY461/MY561 – Social Network Analysis

这是一篇来自英国的关于Hypothesis testing: Exponential random graph models(假设检验:指数随机图模型)的社交网络分析代码代写

 

Week 10 Problem Set

This week, we will revisit the dataset representing relationships between lawyers in an American law firm, gathered by Emmanuel Lazega (see Lazega, E. (2001). The collegial phenomenon: The social mechanisms of cooperation among peers in a corporate law partnership. Oxford University Press.). As a reminder…

Every lawyer in the firm was asked to nominate people from a full list of their colleagues in response to three prompts:

Advice: “Think back over the past year, consider all the lawyers in your Firm. To whom did you go for basic professional advice?

For instance, you want to make sure that you are handling a case right, making a proper decision, and you want to consult someone whose professional opinions are in general of great value to you. By advice I do not mean simply technical advice.”

Friendship: “Would you go through this list, and check the names of those you socialize with outside work. You know their family, they know yours, for instance. I do not mean all the people you are simply on a friendly level with, or people you happen to meet at Firm functions.”

Co-Work: “Because most firms like yours are also organized very informally, it is difficult to get a clear idea of how the members really work together. Think back over the past year, consider all the lawyers in your Firm. Would you go through this list and check the names of those with whom you have worked with. [By “worked with” I mean that you have spent time together on at least one case, that you have been assigned to the same case, that they read or used your work product or that you have read or used their work product; this includes professional work done within the Firm like Bar association work, administration, etc.]”

The responses to these questions form the basis of the edge lists provided. We also provide you with another file that includes information about each of the lawyers. There are 8 attributes:

ID: The ID for each lawyer

Status: (1 = partner (a more senior position); 2=associate (a more junior position))

Gender: (1 = male; 2 = female)

Office: (1 = Boston; 2 = Hartford; 3 = Providence)

Seniority: number of years with the firm

Age

Practice: (1 = litigation; 2 = corporate)

LawSchool: (1 = Harvard or Yale; 2 = University of Connecticut; 3 = Other)

Our primary focus this week will be on the advice network, and we will also make use of the friendship network. I am providing you with the code below to generate the network objects (please do use this code — there is a quirk with how statnet would otherwise generate the networks which could lead to some unnecessary complication):

require(igraph)

require(intergraph)

el_ad <- read.csv(“Law_Advice.csv”, header = TRUE, as.is = TRUE)

el_fr <- read.csv(“Law_Friendship.csv”, header = TRUE, as.is = TRUE)

law_att <- read.csv(“Law_NodeAtt.csv”, header = TRUE, as.is = TRUE)

net_ad <- graph_from_edgelist(as.matrix(el_ad), directed = TRUE)

net_fr <- graph_from_edgelist(as.matrix(el_fr), directed = TRUE)

attify <- function(n_net){

V(n_net)$names <- V(n_net)

V(n_net)$Status <- law_att$Status

V(n_net)$Gender <- law_att$Gender

V(n_net)$Office <- law_att$Office

V(n_net)$Seniority <- law_att$Seniority

V(n_net)$Age <- law_att$Age

V(n_net)$Practice <- law_att$Practice

V(n_net)$LawSchool <- law_att$LawSchool

return(n_net)

}

net_ad <- attify(net_ad)

net_co <- attify(net_co)

net_fr <- attify(net_fr)

snet_ad <- intergraph::asNetwork(net_ad)

snet_fr <- intergraph::asNetwork(net_fr)

detach(package:igraph)

require(ergm)

require(sna)

As we are going to be using the ergm() function in the ergm package of the statnet suite of packages, you should be using the statnet versions of the network objects (i.e., you should be using snet_ad not net_ad).

With this in hand…

1. Fit an ERG model including terms for: the effect of age (overall activity, i.e., ignoring tie directionality), status on incoming ties, status on outgoing ties, gender homophily, office homophily, and practice homophily. Print the model results with summary(). [1 point]

2. Interpret each of the terms (except the first “edges” term) of the ERGM. Report the odds ratio associated with each. Do so in prose, so that we can check your comprehension. [2 points]

3. Report the expected probability of a tie between two lawyers with the following characteristics [1 point]:

  1. both with the median age of 39, both associates (i.e., both with a coding of 2), both of the same gender, working in the same office, and both practicing the same type of law;
  1. both with the median age of 39, both associates (i.e., both with a coding of 2), both of the same gender, working in different offices, and both practicing the same type of law;
  1. both with the median age of 39, one being an associate (i.e., one with a coding of 2) and one a partner (i.e., with a coding of 1),both of the same gender, working in the same office, and both practicing the same type of law

4. Fit a new ERGM with all of the same terms as above, but additionally with a reciprocity term (include mutual), a shared partners term (include gwesp(0.8, fixed = TRUE)), and a term for the friendship network (include edgecov(snet_fr)). Give explicit interpretations of the new terms. Compare the results of this new ERGM to the one previously run – how have things changed? [3 points]

–> Because it can take a few moments for this to run, please (1) include but comment out the lines of code that would run and summarize the model, (2) include the summary output for the model as a commented out chunk of text in your R file (to do this easily, you should just copy the summary output, paste it into your R file, highlight those lines and then select “Comment/Uncomment Lines” from the Code dropdown menu in RStudio – this should put a # in front of each of the lines). (If you are using RMarkdown and want to in some other way include this code without evaluating it and include the output of the results,you are free to do so).

5. Now consider how well we are matching the structure of the network with our two ERG models. Look at the goodness of fit plots, including these as part of your submission. How are we doing in modelling the observed network? Are you satisfied with this? What are we not getting well? Consider how you might change the model. This could be by including other terms involving the attributes we are already including, or could involve attributes that we haven’t included yet (look back to the metadata file to see what other covariates exist). Give a rationale for an alternative term that you propose for inclusion in the ERGM. Run this new third ERGM that includes your proposed reformulation. How do the model results change (comparing to the ERGM from question #4)? Does your term have a strong effect on the likelihood of a tie? How does it affect the other terms in the model? [3 points]

–> Include the GOF plots either as stand-alone PDF files or as part of a knitted PDF resulting from your RMarkdown file. Again,comment out the line that would define this new ERGM, and include the summary output of the model (or otherwise ensure that we do not need to run the ERGM to see the results), as done for question 4.


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: itcsdx@outlook.com  微信:itcsdx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论