Predict method for gwlfit objects
Usage
# S3 method for class 'gwlfit'
predict(object, newdata, newcoords, type = "response", verbose = FALSE, ...)
Arguments
- object
Object of class inheriting from "gwlfit"
- newdata
a data.frame or matrix with the same columns as the training dataset
- newcoords
a dataframe or matrix of coordinates of the new data
- type
the type of response. see
glmnet::predict.glmnet()
- verbose
TRUE
to print info about the execution of the function (useful for very large predictions)- ...
ellipsis for S3 compatibility. Not used in this function.
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 : 330.6282
#> Number of predictors : 50
new_predictors <- matrix(data = rnorm(500), 10,50)
new_coords <- data.frame("Lat" = rnorm(10), "Long" = rnorm(10))
predicted_values <- predict(my.gwl.fit,
newdata = new_predictors,
newcoords = new_coords)