Calculates a lasso, ridge or elastic net generalized regression estimator for a finite population mean/proportion or total based on sample data collected from a complex sampling design and auxiliary population data.
gregElasticNet(
y,
xsample,
xpop,
pi = NULL,
alpha = 1,
model = "linear",
pi2 = NULL,
var_est = FALSE,
var_method = "LinHB",
datatype = "raw",
N = NULL,
lambda = "lambda.min",
B = 1000,
cvfolds = 10
)
A list of output containing:
pop_total:Estimate of population total
coefficients: Elastic net coefficient estimates
pop_mean:Estimate of the population mean (or proportion)
pop_total_var:Estimated variance of population total estimate
pop_mean_var:Estimated variance of population mean estimate
A numeric vector of the sampled response variable.
A data frame of the auxiliary data in the sample.
A data frame of population level auxiliary information. It must contain the same names as xsample. If datatype = "raw", must contain unit level data. If datatype = "totals" or "means", then contains one row of aggregated, population totals or means for the auxiliary data. Default is "raw".
A numeric vector of inclusion probabilities for each sampled unit in y. If NULL, then simple random sampling without replacement is assumed.
A numeric value between 0 and 1 which signifies the mixing parameter for the lasso and ridge penalties in the elastic net. When alpha = 1, only a lasso penalty is used. When alpha = 0, only a ridge penalty is used. Default is alpha = 1.
A string that specifies the regression model to utilize. Options are "linear" or "logistic".
A square matrix of the joint inclusion probabilities. Needed for the "LinHT" variance estimator.
A logical indicating whether or not to compute a variance estimator. Default is FALSE.
The method to use when computing the variance estimator. Options are a Taylor linearized technique: "LinHB"= Hajek-Berger estimator, "LinHH" = Hansen-Hurwitz estimator, "LinHTSRS" = Horvitz-Thompson estimator under simple random sampling without replacement, and "LinHT" = Horvitz-Thompson estimator or a resampling technique: "bootstrapSRS" = bootstrap variance estimator under simple random sampling without replacement. The default is "LinHB".
A string that specifies the form of population auxiliary data. The possible values are "raw", "totals" or "means" for whether the user is providing population data at the unit level, aggregated to totals, or aggregated to means. Default is "raw".
A numeric value of the population size. If NULL, it is estimated with the sum of the inverse of the pis.
A string specifying how to tune the lambda hyper-parameter. Only used if modelselect = TRUE and defaults to "lambda.min". The possible values are "lambda.min", which is the lambda value associated with the minimum cross validation error or "lambda.1se", which is the lambda value associated with a cross validation error that is one standard error away from the minimum, resulting in a smaller model.
The number of bootstrap samples if computing the bootstrap variance estimator. Default is 1000.
The number of folds for the cross-validation to tune lambda.
mcc17mase
library(survey)
data(api)
gregElasticNet(y = apisrs$api00,
xsample = apisrs[c("col.grad", "awards", "snum", "dnum", "cnum", "pcttest", "meals", "sch.wide")],
xpop = apipop[c("col.grad", "awards", "snum", "dnum", "cnum", "pcttest", "meals", "sch.wide")],
pi = apisrs$pw^(-1), var_est = TRUE, alpha = .5)
Run the code above in your browser using DataLab