| Title: | Generate and Analyze Nonlinear Networks |
|---|---|
| Description: | Creates and detects nonlinear relations using the methods described in Slipetz, Qiu, Sun, and Henry (2026) <doi:10.48550/arXiv.2411.02763>. Use the netgen() function to generate a nonlinear network and the dcor_res() function for a residualization procedure for detecting nonlinear relations. |
| Authors: | Lindley Slipetz [aut, cre], Teague Henry [ctb] |
| Maintainer: | Lindley Slipetz <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-09-16 12:29:05 UTC |
| Source: | https://github.com/sliplr19/nonnet |
Residualizes two random variables with respect to a set of covariates using generalized additive models, then tests the association between the residualized variables using a permutation-based distance correlation test.
dcor_res(dat, A, C, B_variables, nperm)dcor_res(dat, A, C, B_variables, nperm)
dat |
A data frame |
A |
Character string specifying the name of the first variable to be used in the distance correlation. |
C |
Character string specifying the name of the second variable to be used in the distance correlation. |
B_variables |
Character vector containing the names of the covariates
used as predictors when residualizing |
nperm |
Integer. Number of permutations used in the distance correlation test. |
A numeric value giving the permutation p-value from
energy::dcor.test().
dat <- data.frame("A" = c(2,3,4), "C" = c(4,9,16), "B" = c(1,1,1), "D" = c(1,1,1)) res <- dcor_res(dat, "A", "C", c("B", "D"), 1000) resdat <- data.frame("A" = c(2,3,4), "C" = c(4,9,16), "B" = c(1,1,1), "D" = c(1,1,1)) res <- dcor_res(dat, "A", "C", c("B", "D"), 1000) res
Simulates a dataset containing a central variable, peripheral variables, and a target variable under different functional relationships.
netgen( n, mean_cent, sd_cent, mean_peri_non, mean_peri_lin, sd_peri_non, sd_peri_lin, mean_target, sd_target, beta_peri_lin, beta_cent_lin, beta_lin, beta_non, beta_cent_non, beta_peri_non, inter_cent_lin, beta_con, func, con_func )netgen( n, mean_cent, sd_cent, mean_peri_non, mean_peri_lin, sd_peri_non, sd_peri_lin, mean_target, sd_target, beta_peri_lin, beta_cent_lin, beta_lin, beta_non, beta_cent_non, beta_peri_non, inter_cent_lin, beta_con, func, con_func )
n |
Integer. Number of observations to generate. |
mean_cent |
Mean of the central variable |
sd_cent |
Standard deviation of the central variable |
mean_peri_non |
Numeric vector. Means of the peripheral nonlinear variables. |
mean_peri_lin |
Numeric vector. Means of the peripheral linear variables. |
sd_peri_non |
Numeric vector. Standard deviations of the peripheral nonlinear variables. |
sd_peri_lin |
Numeric vector. Standard deviations of the peripheral linear variables. |
mean_target |
Mean of the random error term for the target variable |
sd_target |
Standard deviation of the random error term for the target variable |
beta_peri_lin |
Numeric vector. Regression coefficients for effects of the peripheral linear variables on |
beta_cent_lin |
Numeric vector. Regression coefficients for effects of |
beta_lin |
Coefficient for the linear effect of |
beta_non |
Coefficient for the nonlinear effect of |
beta_cent_non |
Numeric vector. Regression coefficients for effects of |
beta_peri_non |
Numeric vector. Regression coefficients for effects of the peripheral nonlinear variables on |
inter_cent_lin |
Integer vector. Indices identifying peripheral variables involved in interactions with |
beta_con |
Regression coefficient for the confounding effect. |
func |
Character. Functional form relating |
con_func |
Character. Functional form relating |
A data frame containing A, C, linear peripheral variables
B1, B2, ..., and nonlinear peripheral variables D1, D2, ....
set.seed(123) dat <- netgen( n = 100, mean_cent = 0, sd_cent = 1, mean_peri_non = rep(0, 4), mean_peri_lin = rep(0, 3), sd_peri_non = rep(1, 4), sd_peri_lin = rep(1, 3), mean_target = 0, sd_target = 1, beta_peri_lin = c(0.3, 0.4, 0.5), beta_cent_lin = rep(0.5, 3), beta_lin = 0.5, beta_non = 0.75, beta_cent_non = c(0.5, 0.6, 0.7, 0.8), beta_peri_non = c(0.3, 0.4, 0.5, 0.6), inter_cent_lin = c(1, 2, 3), beta_con = 0, func = "quad", con_func = "quad" ) head(dat)set.seed(123) dat <- netgen( n = 100, mean_cent = 0, sd_cent = 1, mean_peri_non = rep(0, 4), mean_peri_lin = rep(0, 3), sd_peri_non = rep(1, 4), sd_peri_lin = rep(1, 3), mean_target = 0, sd_target = 1, beta_peri_lin = c(0.3, 0.4, 0.5), beta_cent_lin = rep(0.5, 3), beta_lin = 0.5, beta_non = 0.75, beta_cent_non = c(0.5, 0.6, 0.7, 0.8), beta_peri_non = c(0.3, 0.4, 0.5, 0.6), inter_cent_lin = c(1, 2, 3), beta_con = 0, func = "quad", con_func = "quad" ) head(dat)