mpleung / ARD

Code for 'Recovering Network Structure from Aggregated Relational Data Using Penalized Regression'
7 stars 3 forks source link

This repository contains code for simulation experiments and walkthroughs on using the estimator in Alidaee, Auerbach, and Leung (2020), "Recovering Network Structure from Aggregated Relational Data Using Penalized Regression." We provide implementations in Python and R, found in their respective folders. Walkthroughs are given in the notebook files walkthrough.ipynb. The file in the Python folder can be viewed in two ways.

  1. It can be opened in your browser using this binder link: Binder Note that this might take a little bit of time to start up.

  2. You can open the file on your desktop using the notebook viewer nteract. This method requires an installation of Python, the Python kernel, and the required modules (see instructions below), but it also allows you to use your own datasets instead of those provided in our example. To do so, save walkthrough.ipynb, nuclear_norm_module.py, and your datasets in CSV format to the same working directory, open the walkthrough file in nteract, and change the name of the CSVs in the walkthrough within the nteract user interface.

The file in the R folder can also be viewed in nteract after installation of R, the R kernel, and our R package. Instructions are given below.

Contents of Python folder

To run the .py files, we require Python 3 and installation of numpy, pandas, and scipy. See this walkthrough for installing Python via the Anaconda distribution, which also includes the required packages. If Python 3 is already installed on your machine, then you only need to install the packages, which can be done by entering into command line

python3 -m pip install --user numpy scipy pandas

If you are using nteract to view the walkthrough file, you also have to install an ipython kernel. See here for instructions.

To execute monte_carlo.py, download our Python folder and its contents, change your current working directory to the Python folder, and enter into command line

python3 monte_carlo.py

Contents of R folder

You can install R here. To install our R package, download our R folder, open the R console, change the working directory to the location of our R folder, and input the following command:

install.packages('nuclearARD_0.1.1.tar.gz', repos=NULL, type='source')

To view the walkthrough file in nteract, you also need to install the IRkernel. Follow the installation instructions here.