GithubHelp home page GithubHelp logo

alexpghayes / latentnetmediate Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 202.16 MB

Estimate Latent Network Mediation Effects via Spectral Embeddings

Home Page: https://alexpghayes.github.io/latentnetmediate/

License: Other

R 100.00%

latentnetmediate's Introduction

netmediate

CRAN status Lifecycle: experimental .github/workflows/R-CMD-check

The goal of latentnetmediate is to โ€ฆ

Installation

You can install the development version of latentnetmediate from GitHub with:

# install.packages("devtools")
devtools::install_github("alexpghayes/latentnetmediate")

latentnetmediate's People

Contributors

alexpghayes avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

latentnetmediate's Issues

TODO: Get HC standard errors working

estimatr::lm_robust() is not a drop-replacement for lm(), in the sense that it sometimes gives NaN for covariance estimates when lm() does not. Need to investigate this and determine a fix, but for now just planning to drop lm() back in wherever there was an lm_robust() call. As a consequence, standard errors may not be heteroscedasticity robust until I figure out how to handle this.

Some sort of scoping issue

Programming around nodelm is somehow broken. Messy code dump below, not anything at all close to a reprex.

library(targets)
library(netmediate)

data_block2 <- tar_read(data_block2, 1)[[1]]
mediator_block2_models <- tar_read(mediator_block2_models, 1)[[1]]

length(data_block2)

purrr::map2(data_block2, mediator_block2_models, ~fit_mediator(graph = .x, k = .y$k))




fit_mediator <- function(graph, k) {
  nodelm_robust(US(A, k) ~ . - name - 1, graph = graph)
}


fit_mediator(data_block2[[1]], mediator_block2_models[[1]]$k)
k <- 5
nodelm_robust(US(A, k) ~ . - name - 1, graph = data_block2[[1]])
fit_mediator(data_block2[[1]], k)

fit_mediator <- function(graph, k) {
  formula <- as.formula(glue::glue("US(A, {k}) ~ . - name - 1"))
  nodelm_robust(formula, graph = graph)
}

fit_mediator <- function(graph, k) {
  netmediate::US  # hack for {targets} to track dependencies in formulas
  formula <- as.formula(glue::glue("US(A, {k}) ~ . - name - 1"))
  nodelm_robust(formula, graph = graph)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.