Fit a geographically weighted lasso with the selected bandwidth
Arguments
- bw
Bandwidth
- x.var
input matrix, of dimension nobs x nvars; each row is an observation vector. x should have 2 or more columns.
- y.var
response variable for the lasso
- kernel
the geographical kernel shape to compute the weight. passed to
GWmodel::gw.weight()
Can begaussian
,exponential
,bisquare
,tricube
,boxcar
- dist.mat
a distance matrix. can be generated by
compute_distance_matrix()
- alpha
the elasticnet mixing parameter. set 1 for lasso, 0 for ridge. see
glmnet::glmnet()
- adaptive
TRUE or FALSE Whether to perform an adaptive bandwidth search or not. A fixed bandwidth means that samples are selected if they fit a determined fixed radius around a location. In a adaptive bandwidth, the radius around a location varies to gather a fixed number of samples around the investigated location
- progress
TRUE/FALSE whether to display a progress bar or not
- nfolds
the number f folds for the glmnet cross validation
Examples
predictors <- matrix(data = rnorm(2500), 50,50)
y_value <- sample(1:1000, 50)
coords <- data.frame("Lat" = rnorm(50), "Long" = rnorm(50))
distance_matrix <- compute_distance_matrix(coords)
my.gwl.fit <- gwl_fit(bw = 20,
x.var = predictors,
y.var = y_value,
kernel = "bisquare",
dist.mat = distance_matrix,
alpha = 1,
adaptive = TRUE,
progress = TRUE,
nfolds = 5)
my.gwl.fit
#> Bandwidth : 20
#> adaptive : TRUE
#> Number of models : 50
#> RMSPE : 393.2292
#> Number of predictors : 50