glmpred | R Documentation |
This function is for generating spatial predictions using 'glm' method in 'stats' package.
glmpred(formula = NULL, trainxy, longlatpredx, predx, family = "gaussian", ...)
formula |
a formula defining the response variable and predictive variables. |
trainxy |
a dataframe contains predictive variables and the response variable of point samples. The location information, longitude (long), latitude (lat), need to be included in the 'trainx' for spatial predictive modeling, need to be named as 'long' and 'lat'. |
longlatpredx |
a dataframe contains longitude and latitude of point locations (i.e., the centers of grids) to be predicted. |
predx |
a dataframe or matrix contains columns of predictive variables for the grids to be predicted. |
family |
a description of the error distribution and link function to be used in the model. See '?glm' for details. |
... |
other arguments passed on to 'glm'. |
A dataframe of longitude, latitude and predictions.
Jin Li
library(spm)
data(petrel)
data(petrel.grid)
gravel <- petrel[, c(1, 2, 6:9, 5)]
model <- log(gravel + 1) ~ lat + bathy + I(long^3) + I(lat^2) + I(lat^3)
glmpred1 <- glmpred(formula = model, trainxy = gravel,
longlatpredx = petrel.grid[, c(1:2)], predx = petrel.grid)
names(glmpred1)
# Back transform 'glmpred1$pred.glm1' to generate the final predictions
glm.predictions <- exp(glmpred1$pred.glm1) - 1
range(glm.predictions)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.