Title: | Grouped Weighted Quantile Sum Regression |
---|---|
Description: | Fits weighted quantile sum (WQS) regressions for one or more chemical groups with continuous or binary outcomes. Wheeler D, Czarnota J.(2016) <doi:10.1289/isee.2016.4698>. |
Authors: | David Wheeler, Matthew Carli |
Maintainer: | Matthew Carli <[email protected]> |
License: | GPL-3 |
Version: | 0.0.3 |
Built: | 2024-11-15 06:48:12 UTC |
Source: | CRAN |
This function fits a grouped weighted quantile sum (GWQS) regression model.
gwqs.fit( y, y.train = NULL, x, x.train = NULL, z = NULL, z.train = NULL, x.s, B = 100, n.quantiles = 4, pars = NULL, func, ineqLB = NULL, ineqUB = NULL, tol = 1e-06, delta = 1e-06 )
gwqs.fit( y, y.train = NULL, x, x.train = NULL, z = NULL, z.train = NULL, x.s, B = 100, n.quantiles = 4, pars = NULL, func, ineqLB = NULL, ineqUB = NULL, tol = 1e-06, delta = 1e-06 )
y |
A vector containing outcomes for validation. |
y.train |
A vector containing outcomes for training. If left as NULL the validation data will be used for training as well. |
x |
A matrix of component data for validation. |
x.train |
A matrix of component data for training. If left as NULL the validation data will be used for training as well. |
z |
A vector or matrix of covariates for validation. |
z.train |
A vector or matrix of covariates for training. If left as NULL the validation data will be used for training as well. |
x.s |
A vector of the number of components in each index. |
B |
The number of bootstrap samples, must be 1 or more. |
n.quantiles |
The number of quantiles to apply to data. |
pars |
A vector of initial values, listed in order: beta naught intercept and group index beta coefficients, individual chemical weight coefficients, and covariate coefficients. |
func |
The objective function to be used (must match outcome data type); currently only fun args "continuous" or "binary" are supported. |
ineqLB |
Vector of lower bounds for betas and weights, set to -2 by default. |
ineqUB |
Vector of upper bounds for betas and weights, set to 2 be default. |
tol |
Tolerance level for bootstrap convergence. |
delta |
Step size for bootstrap procedure. |
A list of 3 containing the GWQS estimate based on calculated weights, the GWQS model fit to validation data, and weight estimates
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) x.s <- make.x.s(WQSdata, 3, group_list) X <- make.X(WQSdata, 3, group_list) Y <- WQSdata$y results <- gwqs.fit(y = Y, x = X, x.s = x.s, B=1, func = "continuous")
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) x.s <- make.x.s(WQSdata, 3, group_list) X <- make.X(WQSdata, 3, group_list) Y <- WQSdata$y results <- gwqs.fit(y = Y, x = X, x.s = x.s, B=1, func = "continuous")
This function returns a matrix of component variables, X. The user can specify the desired chemicals and order by creating a list of string vectors, each vector containing the variable names of all desired elements of that group.
make.X(df, num.groups, groups)
make.X(df, num.groups, groups)
df |
A dataframe containing named component variables |
num.groups |
An integer representing the number of component groups desired |
groups |
A list, each item in the list being a string vector of variable names for one component group |
A matrix of component variables
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) X <- make.X(WQSdata, 3, group_list) X
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) X <- make.X(WQSdata, 3, group_list) X
This function returns a vector which lets WQS.fit know the size and order of groups in X
make.x.s(df, num.groups, groups)
make.x.s(df, num.groups, groups)
df |
A dataframe containing named component variables |
num.groups |
An integer representing the number of component groups desired |
groups |
A list, each item in the list being a string vector of variable names for one component group |
A vector of integers, each integer relating how many columns are in each group
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) x.s <- make.x.s(WQSdata, 3, group_list) x.s
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) x.s <- make.x.s(WQSdata, 3, group_list) x.s
Data simulated to have .7 in-group correlation and .3 between-group correlation. There are three groups, the third being significantly correlated to the outcome variable
simdata
simdata
A data frame with 1000 rows and 15 variables:
a numeric vector; part of group 1
a numeric vector; part of group 1
a numeric vector; part of group 1
a numeric vector; part of group 1
a numeric vector; part of group 1
a numeric vector; part of group 2
a numeric vector; part of group 2
a numeric vector; part of group 2
a numeric vector; part of group 2
a numeric vector; part of group 3
a numeric vector; part of group 3
a numeric vector; part of group 3
a numeric vector; part of group 3
a numeric vector; part of group 3
a numeric vector; the outcome variable
This function takes the object created by the wqs.fit function and a vector of group names and generates a random forest variable importance plot for each group. The weights in each group are listed in descending order.
weight.plot(fit.object, group.names)
weight.plot(fit.object, group.names)
fit.object |
The object that is returned by the wqs.fit function |
group.names |
A string vector containing the name of each group included in the GWQS regression. Will be used for plot titles. |
A plot for each group of the GWQS regression
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) chem_groups <- c("PCBs", "Metals", "Insecticides") x.s <- make.x.s(WQSdata, 3, group_list) X <- make.X(WQSdata, 3, group_list) Y <- WQSdata$y results <- gwqs.fit(y = Y, x = X, x.s = x.s, B=1, func = "continuous") weight.plot(results, chem_groups)
data("WQSdata") group_list <- list(c("X1", "X2", "X3"), c("X4", "X7"), c("X5", "X6", "X9", "X8")) chem_groups <- c("PCBs", "Metals", "Insecticides") x.s <- make.x.s(WQSdata, 3, group_list) X <- make.X(WQSdata, 3, group_list) Y <- WQSdata$y results <- gwqs.fit(y = Y, x = X, x.s = x.s, B=1, func = "continuous") weight.plot(results, chem_groups)
Correlation and concentration patterns were loosely based on NHL data.
WQSdata
WQSdata
A data frame with 1000 rows and 10 variables:
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector; the outcome variable