ucsd-lo-group / social-network-analysis

Social Network Analysis in small groups to measure student performance at the University of California San Diego
MIT License
1 stars 0 forks source link

[R] Undirected Weights #2

Closed albertchai01 closed 6 years ago

albertchai01 commented 7 years ago

Errors with undirected data set, all weighted values are doubled for all sets.

Alee4738 commented 7 years ago

I haven't run it myself yet, but my guess is that since the edges are undirected, the same edge shows up twice in any given data set (e.g. edge (1,2) is the same as (2,1)), so that edge gets processed twice.

Could you help me reproduce the error by posting the steps you took and the relevant output?

albertchai01 commented 7 years ago

Script was executed in RStudio as source('~/GitHub/ucsd-sna-lo-lab/main_current.R', echo = FALSE) Using sample_data/case6_data in the repo As prompted by the script, the following requested input was entered: Name of project; Case 6 Matlab processing: 0 Directed lists: 0 Weighted list: 1 Self-interactions allowed: 0 Plot network: 1 Projection: 0 Export results: 1 Console clear: 0

Below attached are the network projections and the output as a .txt file. The results as shown in the matrix are doubled than what they should be.

Case 6.txt case6

Alee4738 commented 6 years ago

I looked at the sample data and how the igraph library is using it, and it does not seem like a bug at all. The problem is that the same undirected edge is listed twice, so its weight gets added twice. For example, according to case6-st.csv and case6-weights,csv, there are edges

(1,8) (weight 37)
...
(8,1) (weight 37)

(1,8) and (8,1) are distinct edges in a directed graph, but they are the same edge in an undirected graph. So, when we interpret the data as undirected, the R script gives the edge (1,8) a weight of 37+37 = 74. The problem is with interpretation of the data.

One way I think we can solve this is by labeling each sample case file as either directed or undirected. That way, we don't interpret a single file as directed, then as undirected. Format of Directed vs. Undirected files: In directed files, we can have edges like (1,8) and (8,1), but in undirected files, we should only have a single edge (1,8).

albertchai01 commented 6 years ago

No you’re right. This is not a bug, we didn’t know at the time if it was, but you’re right. We have been doing that after we realized that, but we never bothered to go back to the pending issues on it. I recommend that we close the case then and make adjustments to the code as necessary. I know we modified the code where we still got like density on a scale from 0 to 1, else it would from 0 to 2 with undirected (like divided it by 2).

From: Andrew Lee [mailto:notifications@github.com] Sent: Tuesday, February 13, 2018 7:48 PM To: ucsd-lo-group/social-network-analysis social-network-analysis@noreply.github.com Cc: Albert Chai albertchai@chaisystems.net; Author author@noreply.github.com Subject: Re: [ucsd-lo-group/social-network-analysis] [R] Undirected Weights (#2)

I looked at the sample data and how the igraph library is using it, and it does not seem like a bug at all. The problem is that the same undirected edge is listed twice, so its weight gets added twice. For example, according to case6-st.csv and case6-weights,csv, there are edges

(1,8) (weight 37)

...

(8,1) (weight 37)

(1,8) and (8,1) are distinct edges in a directed graph, but they are the same edge in an undirected graph. The problem is with interpretation of the data.

One way I think we can solve this is by labeling each sample case file as either directed or undirected. That way, we don't interpret a single file as directed, then as undirected. Format of Directed vs. Undirected files: In directed files, we can have edges like (1,8) and (8,1), but in undirected files, we should only have a single edge (1,8).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fucsd-lo-group%2Fsocial-network-analysis%2Fissues%2F2%23issuecomment-365487640&data=01%7C01%7Calbertchai%40chaisystems.net%7Cba28b271d94145daf3ca08d5735dc209%7Cc4fc4e406ffd45f5a7dcbee3e0f2741b%7C0&sdata=pE7VQX%2FyzDm0IJ3snzkx7APgWhdhws4q1aTKv6PqLvg%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAXzI8fuVAoDBCaDgApikjspwng2j8vO-ks5tUld1gaJpZM4P6HJK&data=01%7C01%7Calbertchai%40chaisystems.net%7Cba28b271d94145daf3ca08d5735dc209%7Cc4fc4e406ffd45f5a7dcbee3e0f2741b%7C0&sdata=7OMJRx12dOOM8dIaloeo6HH5lhmTTLxt7Wk%2FBJwbKrc%3D&reserved=0.