predict.gwlfit: Predict method for gwlfit objects

View source: R/predict.gwlfit.R

predict.gwlfitR Documentation

Predict method for gwlfit objects

Description

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.

Value

a vector of predicted values

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

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)


GWlasso documentation built on April 3, 2025, 7:08 p.m.