Calculates a modified 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.
Usage
modifiedGreg(
y,
xsample,
xpop,
domains,
pi = NULL,
pi2 = NULL,
datatype = "raw",
model = "linear",
var_est = F,
var_method = "LinHB",
modelselect = FALSE,
lambda = "lambda.min",
domain_col_name = NULL,
estimation_domains = NULL,
N = NULL,
B = 1000,
fpc = TRUE,
messages = TRUE
)
Arguments
- y
A vector of the response values from the sample
- xsample
A data frame of the auxiliary data in the sample.
- xpop
A data frame of population level auxiliary information. It must contain all of the names from 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 and must include a column labeled N with the population sizes for each domain. Default is "raw".
- domains
A vector of the specific domain that each row of xsample belongs to.
- pi
First order inclusion probabilities.
- pi2
Second order inclusion probabilities.
- datatype
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".
- model
A string that specifies the regression model to utilize. Options are "linear" or "logistic".
- var_est
A logical value that specifies whether variance estimation should be performed.
- var_method
A string that specifies the variance method to utilize.
- modelselect
A logical for whether or not to run lasso regression first and then fit the model using only the predictors with non-zero lasso coefficients. Default is FALSE.
- lambda
A string specifying how to tune the lasso 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.
- domain_col_name
A string that specifies the name of the column that contains the domain values in xpop.
- estimation_domains
A vector of domain values over which to produce estimates. If NULL, estimation will be performed over all of the domains included in xpop.
- N
The total population size.
- B
The number of bootstrap iterations to perform when var_method = "bootstrapSRS"
- fpc
Default to TRUE, logical for whether or not the variance calculation should include a finite population correction when calculating the "LinHTSRS" or the "SRSbootstrap" variance estimator.
- messages
A logical indicating whether to output the messages internal to mase. Default is TRUE.
Examples
library(dplyr)
data(IdahoPop)
data(IdahoSamp)
modifiedGreg(y = IdahoSamp$BA_TPA_ADJ,
xsample = IdahoSamp[c("tcc", "elev")],
xpop = IdahoPop[c("COUNTYFIPS","tcc", "elev", "npixels")] |> rename(N = npixels),
domains = IdahoSamp$COUNTYFIPS,
datatype = "means",
N = sum(IdahoPop$npixels),
var_est = TRUE)
#> domain_col_name is not directly specified. COUNTYFIPS is being used.
#> Assuming simple random sampling
#> Domain 16001 does not contain enough points for variance estimation
#> Domain 16051 does not contain enough points for variance estimation
#> $population_res
#> pop_total pop_totalvar
#> 1.494800e+09 6.481801e+14
#>
#> $raw_res
#> $raw_res[[1]]
#> $raw_res[[1]]$domain
#> [1] "16001"
#>
#> $raw_res[[1]]$domain_total
#> [1] 11148697
#>
#> $raw_res[[1]]$domain_mean
#> [1] 32.87072
#>
#> $raw_res[[1]]$domain_total_var
#> [1] NA
#>
#> $raw_res[[1]]$domain_mean_var
#> [1] NA
#>
#>
#> $raw_res[[2]]
#> $raw_res[[2]]$domain
#> [1] "16003"
#>
#> $raw_res[[2]]$domain_total
#> [1] 36136191
#>
#> $raw_res[[2]]$domain_mean
#> [1] 82.47278
#>
#> $raw_res[[2]]$domain_total_var
#> [1] 2.502825e+13
#>
#> $raw_res[[2]]$domain_mean_var
#> [1] 130.3668
#>
#>
#> $raw_res[[3]]
#> $raw_res[[3]]$domain
#> [1] "16005"
#>
#> $raw_res[[3]]$domain_total
#> [1] 18865322
#>
#> $raw_res[[3]]$domain_mean
#> [1] 51.35783
#>
#> $raw_res[[3]]$domain_total_var
#> [1] 3.294784e+12
#>
#> $raw_res[[3]]$domain_mean_var
#> [1] 24.4181
#>
#>
#> $raw_res[[4]]
#> $raw_res[[4]]$domain
#> [1] "16007"
#>
#> $raw_res[[4]]$domain_total
#> [1] 17153139
#>
#> $raw_res[[4]]$domain_mean
#> [1] 51.12648
#>
#> $raw_res[[4]]$domain_total_var
#> [1] 7.170751e+12
#>
#> $raw_res[[4]]$domain_mean_var
#> [1] 63.70438
#>
#>
#> $raw_res[[5]]
#> $raw_res[[5]]$domain
#> [1] "16009"
#>
#> $raw_res[[5]]$domain_total
#> [1] 28880619
#>
#> $raw_res[[5]]$domain_mean
#> [1] 114.7641
#>
#> $raw_res[[5]]$domain_total_var
#> [1] 2.826804e+13
#>
#> $raw_res[[5]]$domain_mean_var
#> [1] 446.3699
#>
#>
#> $raw_res[[6]]
#> $raw_res[[6]]$domain
#> [1] "16011"
#>
#> $raw_res[[6]]$domain_total
#> [1] 23868654
#>
#> $raw_res[[6]]$domain_mean
#> [1] 35.17343
#>
#> $raw_res[[6]]$domain_total_var
#> [1] 1.666521e+12
#>
#> $raw_res[[6]]$domain_mean_var
#> [1] 3.618965
#>
#>
#> $raw_res[[7]]
#> $raw_res[[7]]$domain
#> [1] "16013"
#>
#> $raw_res[[7]]$domain_total
#> [1] 38464093
#>
#> $raw_res[[7]]$domain_mean
#> [1] 45.22001
#>
#> $raw_res[[7]]$domain_total_var
#> [1] 1.028533e+13
#>
#> $raw_res[[7]]$domain_mean_var
#> [1] 14.2157
#>
#>
#> $raw_res[[8]]
#> $raw_res[[8]]$domain
#> [1] "16015"
#>
#> $raw_res[[8]]$domain_total
#> [1] 34545570
#>
#> $raw_res[[8]]$domain_mean
#> [1] 56.46888
#>
#> $raw_res[[8]]$domain_total_var
#> [1] 2.300525e+13
#>
#> $raw_res[[8]]$domain_mean_var
#> [1] 61.46962
#>
#>
#> $raw_res[[9]]
#> $raw_res[[9]]$domain
#> [1] "16017"
#>
#> $raw_res[[9]]$domain_total
#> [1] 62332114
#>
#> $raw_res[[9]]$domain_mean
#> [1] 101.6486
#>
#> $raw_res[[9]]$domain_total_var
#> [1] 3.91777e+13
#>
#> $raw_res[[9]]$domain_mean_var
#> [1] 104.188
#>
#>
#> $raw_res[[10]]
#> $raw_res[[10]]$domain
#> [1] "16019"
#>
#> $raw_res[[10]]$domain_total
#> [1] 29660427
#>
#> $raw_res[[10]]$domain_mean
#> [1] 48.79002
#>
#> $raw_res[[10]]$domain_total_var
#> [1] 1.025721e+13
#>
#> $raw_res[[10]]$domain_mean_var
#> [1] 27.75469
#>
#>
#> $raw_res[[11]]
#> $raw_res[[11]]$domain
#> [1] "16021"
#>
#> $raw_res[[11]]$domain_total
#> [1] 50850795
#>
#> $raw_res[[11]]$domain_mean
#> [1] 124.4345
#>
#> $raw_res[[11]]$domain_total_var
#> [1] 1.898234e+13
#>
#> $raw_res[[11]]$domain_mean_var
#> [1] 113.6674
#>
#>
#> $raw_res[[12]]
#> $raw_res[[12]]$domain
#> [1] "16023"
#>
#> $raw_res[[12]]$domain_total
#> [1] 33390413
#>
#> $raw_res[[12]]$domain_mean
#> [1] 46.67638
#>
#> $raw_res[[12]]$domain_total_var
#> [1] 5.146715e+12
#>
#> $raw_res[[12]]$domain_mean_var
#> [1] 10.05729
#>
#>
#> $raw_res[[13]]
#> $raw_res[[13]]$domain
#> [1] "16025"
#>
#> $raw_res[[13]]$domain_total
#> [1] 20381358
#>
#> $raw_res[[13]]$domain_mean
#> [1] 59.08154
#>
#> $raw_res[[13]]$domain_total_var
#> [1] 5.070713e+12
#>
#> $raw_res[[13]]$domain_mean_var
#> [1] 42.60949
#>
#>
#> $raw_res[[14]]
#> $raw_res[[14]]$domain
#> [1] "16029"
#>
#> $raw_res[[14]]$domain_total
#> [1] 34052766
#>
#> $raw_res[[14]]$domain_mean
#> [1] 59.19718
#>
#> $raw_res[[14]]$domain_total_var
#> [1] 9.856026e+12
#>
#> $raw_res[[14]]$domain_mean_var
#> [1] 29.78511
#>
#>
#> $raw_res[[15]]
#> $raw_res[[15]]$domain
#> [1] "16031"
#>
#> $raw_res[[15]]$domain_total
#> [1] 36203932
#>
#> $raw_res[[15]]$domain_mean
#> [1] 43.79824
#>
#> $raw_res[[15]]$domain_total_var
#> [1] 6.741815e+12
#>
#> $raw_res[[15]]$domain_mean_var
#> [1] 9.866853
#>
#>
#> $raw_res[[16]]
#> $raw_res[[16]]$domain
#> [1] "16033"
#>
#> $raw_res[[16]]$domain_total
#> [1] 24572332
#>
#> $raw_res[[16]]$domain_mean
#> [1] 43.54681
#>
#> $raw_res[[16]]$domain_total_var
#> [1] 7.685923e+12
#>
#> $raw_res[[16]]$domain_mean_var
#> [1] 24.13882
#>
#>
#> $raw_res[[17]]
#> $raw_res[[17]]$domain
#> [1] "16035"
#>
#> $raw_res[[17]]$domain_total
#> [1] 98481213
#>
#> $raw_res[[17]]$domain_mean
#> [1] 123.7993
#>
#> $raw_res[[17]]$domain_total_var
#> [1] 5.828789e+13
#>
#> $raw_res[[17]]$domain_mean_var
#> [1] 92.11022
#>
#>
#> $raw_res[[18]]
#> $raw_res[[18]]$domain
#> [1] "16037"
#>
#> $raw_res[[18]]$domain_total
#> [1] 81507568
#>
#> $raw_res[[18]]$domain_mean
#> [1] 51.62275
#>
#> $raw_res[[18]]$domain_total_var
#> [1] 3.00394e+13
#>
#> $raw_res[[18]]$domain_mean_var
#> [1] 12.04974
#>
#>
#> $raw_res[[19]]
#> $raw_res[[19]]$domain
#> [1] "16039"
#>
#> $raw_res[[19]]$domain_total
#> [1] 32799941
#>
#> $raw_res[[19]]$domain_mean
#> [1] 33.09816
#>
#> $raw_res[[19]]$domain_total_var
#> [1] 9.814802e+12
#>
#> $raw_res[[19]]$domain_mean_var
#> [1] 9.994084
#>
#>
#> $raw_res[[20]]
#> $raw_res[[20]]$domain
#> [1] "16041"
#>
#> $raw_res[[20]]$domain_total
#> [1] 10259815
#>
#> $raw_res[[20]]$domain_mean
#> [1] 48.04139
#>
#> $raw_res[[20]]$domain_total_var
#> [1] 1.96309e+12
#>
#> $raw_res[[20]]$domain_mean_var
#> [1] 43.04198
#>
#>
#> $raw_res[[21]]
#> $raw_res[[21]]$domain
#> [1] "16043"
#>
#> $raw_res[[21]]$domain_total
#> [1] 37157299
#>
#> $raw_res[[21]]$domain_mean
#> [1] 61.26856
#>
#> $raw_res[[21]]$domain_total_var
#> [1] 7.535957e+12
#>
#> $raw_res[[21]]$domain_mean_var
#> [1] 20.48922
#>
#>
#> $raw_res[[22]]
#> $raw_res[[22]]$domain
#> [1] "16045"
#>
#> $raw_res[[22]]$domain_total
#> [1] 8965137
#>
#> $raw_res[[22]]$domain_mean
#> [1] 50.18465
#>
#> $raw_res[[22]]$domain_total_var
#> [1] 2.198882e+12
#>
#> $raw_res[[22]]$domain_mean_var
#> [1] 68.90169
#>
#>
#> $raw_res[[23]]
#> $raw_res[[23]]$domain
#> [1] "16049"
#>
#> $raw_res[[23]]$domain_total
#> [1] 223291985
#>
#> $raw_res[[23]]$domain_mean
#> [1] 82.12561
#>
#> $raw_res[[23]]$domain_total_var
#> [1] 1.472581e+14
#>
#> $raw_res[[23]]$domain_mean_var
#> [1] 19.92004
#>
#>
#> $raw_res[[24]]
#> $raw_res[[24]]$domain
#> [1] "16051"
#>
#> $raw_res[[24]]$domain_total
#> [1] 11666225
#>
#> $raw_res[[24]]$domain_mean
#> [1] 32.98647
#>
#> $raw_res[[24]]$domain_total_var
#> [1] NA
#>
#> $raw_res[[24]]$domain_mean_var
#> [1] NA
#>
#>
#> $raw_res[[25]]
#> $raw_res[[25]]$domain
#> [1] "16055"
#>
#> $raw_res[[25]]$domain_total
#> [1] 37528677
#>
#> $raw_res[[25]]$domain_mean
#> [1] 89.64791
#>
#> $raw_res[[25]]$domain_total_var
#> [1] 1.899839e+13
#>
#> $raw_res[[25]]$domain_mean_var
#> [1] 108.4103
#>
#>
#> $raw_res[[26]]
#> $raw_res[[26]]$domain
#> [1] "16057"
#>
#> $raw_res[[26]]$domain_total
#> [1] 19931463
#>
#> $raw_res[[26]]$domain_mean
#> [1] 58.03731
#>
#> $raw_res[[26]]$domain_total_var
#> [1] 1.837492e+13
#>
#> $raw_res[[26]]$domain_mean_var
#> [1] 155.7979
#>
#>
#> $raw_res[[27]]
#> $raw_res[[27]]$domain
#> [1] "16059"
#>
#> $raw_res[[27]]$domain_total
#> [1] 75358021
#>
#> $raw_res[[27]]$domain_mean
#> [1] 51.61837
#>
#> $raw_res[[27]]$domain_total_var
#> [1] 3.4372e+13
#>
#> $raw_res[[27]]$domain_mean_var
#> [1] 16.12703
#>
#>
#> $raw_res[[28]]
#> $raw_res[[28]]$domain
#> [1] "16061"
#>
#> $raw_res[[28]]$domain_total
#> [1] 5230292
#>
#> $raw_res[[28]]$domain_mean
#> [1] 34.13093
#>
#> $raw_res[[28]]$domain_total_var
#> [1] 1.494249e+12
#>
#> $raw_res[[28]]$domain_mean_var
#> [1] 63.63082
#>
#>
#> $raw_res[[29]]
#> $raw_res[[29]]$domain
#> [1] "16065"
#>
#> $raw_res[[29]]$domain_total
#> [1] 5760668
#>
#> $raw_res[[29]]$domain_mean
#> [1] 38.11831
#>
#> $raw_res[[29]]$domain_total_var
#> [1] 635571310951
#>
#> $raw_res[[29]]$domain_mean_var
#> [1] 27.82825
#>
#>
#> $raw_res[[30]]
#> $raw_res[[30]]$domain
#> [1] "16069"
#>
#> $raw_res[[30]]$domain_total
#> [1] 9876316
#>
#> $raw_res[[30]]$domain_mean
#> [1] 36.02483
#>
#> $raw_res[[30]]$domain_total_var
#> [1] 797245583586
#>
#> $raw_res[[30]]$domain_mean_var
#> [1] 10.60733
#>
#>
#> $raw_res[[31]]
#> $raw_res[[31]]$domain
#> [1] "16071"
#>
#> $raw_res[[31]]$domain_total
#> [1] 14729506
#>
#> $raw_res[[31]]$domain_mean
#> [1] 38.35439
#>
#> $raw_res[[31]]$domain_total_var
#> [1] 975141453494
#>
#> $raw_res[[31]]$domain_mean_var
#> [1] 6.611827
#>
#>
#> $raw_res[[32]]
#> $raw_res[[32]]$domain
#> [1] "16073"
#>
#> $raw_res[[32]]$domain_total
#> [1] 82351228
#>
#> $raw_res[[32]]$domain_mean
#> [1] 33.46803
#>
#> $raw_res[[32]]$domain_total_var
#> [1] 5.880778e+12
#>
#> $raw_res[[32]]$domain_mean_var
#> [1] 0.9713034
#>
#>
#> $raw_res[[33]]
#> $raw_res[[33]]$domain
#> [1] "16077"
#>
#> $raw_res[[33]]$domain_total
#> [1] 18995353
#>
#> $raw_res[[33]]$domain_mean
#> [1] 41.31095
#>
#> $raw_res[[33]]$domain_total_var
#> [1] 3.809997e+12
#>
#> $raw_res[[33]]$domain_mean_var
#> [1] 18.02023
#>
#>
#> $raw_res[[34]]
#> $raw_res[[34]]$domain
#> [1] "16079"
#>
#> $raw_res[[34]]$domain_total
#> [1] 127353126
#>
#> $raw_res[[34]]$domain_mean
#> [1] 150.7328
#>
#> $raw_res[[34]]$domain_total_var
#> [1] 7.022966e+13
#>
#> $raw_res[[34]]$domain_mean_var
#> [1] 98.38233
#>
#>
#> $raw_res[[35]]
#> $raw_res[[35]]$domain
#> [1] "16081"
#>
#> $raw_res[[35]]$domain_total
#> [1] 8492730
#>
#> $raw_res[[35]]$domain_mean
#> [1] 59.01828
#>
#> $raw_res[[35]]$domain_total_var
#> [1] 1.943679e+12
#>
#> $raw_res[[35]]$domain_mean_var
#> [1] 93.86486
#>
#>
#> $raw_res[[36]]
#> $raw_res[[36]]$domain
#> [1] "16083"
#>
#> $raw_res[[36]]$domain_total
#> [1] 20815687
#>
#> $raw_res[[36]]$domain_mean
#> [1] 33.8516
#>
#> $raw_res[[36]]$domain_total_var
#> [1] 511073650680
#>
#> $raw_res[[36]]$domain_mean_var
#> [1] 1.351638
#>
#>
#> $raw_res[[37]]
#> $raw_res[[37]]$domain
#> [1] "16085"
#>
#> $raw_res[[37]]$domain_total
#> [1] 43930238
#>
#> $raw_res[[37]]$domain_mean
#> [1] 36.77054
#>
#> $raw_res[[37]]$domain_total_var
#> [1] 2.847346e+13
#>
#> $raw_res[[37]]$domain_mean_var
#> [1] 19.94863
#>
#>
#> $raw_res[[38]]
#> $raw_res[[38]]$domain
#> [1] "16087"
#>
#> $raw_res[[38]]$domain_total
#> [1] 19810651
#>
#> $raw_res[[38]]$domain_mean
#> [1] 42.06583
#>
#> $raw_res[[38]]$domain_total_var
#> [1] 2.948423e+12
#>
#> $raw_res[[38]]$domain_mean_var
#> [1] 13.29387
#>
#>
#>