VPSPulse Mirrors

High-Performance Open-Source Archive

README

svyVarSel

This package allows to fit linear and logistic LASSO and elastic net models to complex survey data.

This package depends on survey and glmnet packages.

Five functions are available in the package:

Installation

To install it from CRAN:

install.packages("svyVarSel")

To install the updated version of the package from GitHub:

devtools::install_github("aiparragirre/svyVarSel")

Example

Fit a logistic elastic net model as follows:

library(svyVarSel)
data(simdata_lasso_binomial)

mcv <- welnet(data = simdata_lasso_binomial,
              col.y = "y", col.x = 1:50,
              family = "binomial",
              alpha = 0.5,
              cluster = "cluster", strata = "strata", weights = "weights",  
              method = "dCV", k=10, R=20)

Or equivalently:

mydesign <- survey::svydesign(ids=~cluster, strata = ~strata, weights = ~weights,
                              nest = TRUE, data = simdata_lasso_binomial)
mcv <- welnet(col.y = "y", col.x = 1:50, design = mydesign,
              family = "binomial", alpha = 0.5,
              method = "dCV", k=10, R=20)

Then, plot the result as follows:

welnet.plot(mcv)

If you only aim to obtain replicate weights for other purposes, use the replicate.weights() function:

newdata <- replicate.weights(data = simdata_lasso_binomial,
                             method = "dCV",
                             cluster = "cluster",
                             strata = "strata",
                             weights = "weights",
                             k = 10, R = 20,
                             rw.test = TRUE)

Need mirroring services?
Contact our team at info@vpspulse.com.

Mirror powered by VPSpulse

Infrastructure sponsored by VPSPulse & Secure Payments by ArionPay.