r-spatial / gstat

Spatial and spatio-temporal geostatistical modelling, prediction and simulation
http://r-spatial.github.io/gstat/
GNU General Public License v2.0
195 stars 49 forks source link

A error in "use krige" #69

Open OrdinarySK opened 4 years ago

OrdinarySK commented 4 years ago

kr.lst <- krige(formula = lst~longtitude+latitude+slope+evelation, data=sa, newdata=grid.grid, model=fvlst)

error information: Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘krige’ for signature ‘"formula", "missing"’

my sa contains longtitude,latitude,slope,evelation,lst and so on column grid.grid contains longtitude,latitude fvlst is fit.variogram result

edzer commented 4 years ago

Try not naming the arguments, as in

krige(lst~longtitude+latitude+slope+evelation, sa, grid.grid, model=fvlst)
OrdinarySK commented 4 years ago

I tried again as you said. error:"Error in eval(predvars, data, env) : not find object 'slope' " “slope” is include in sa, why such error occurs?

edzer commented 4 years ago

It needs to be in grid.grid as well.

OrdinarySK commented 4 years ago

I don't quite understand. user manual example krige(log(zinc)~1, meuse, meuse.grid, model = m) The example data "meuse and meuse.grid", meuse.grid as a GRID data not contains zinc, zinc is include in meuse. why is this ok? As far as i am concerned, In my data, "sa" is the sampling points, including other environmental covariates and target variable. “grid.grid” is the gridded study area GRID data, only contains longtitude and latitude. why "slope" needs to be in "grid.grid" as well? So, Is this my idea wrong?

edzer commented 4 years ago

slope is on the RHS of the formula, meaning it is a predictor; for prediction, you need to have all predictors at prediction locations.

OrdinarySK commented 4 years ago

Okay, I understand roughly, thank you.

OrdinarySK commented 4 years ago

Excuse me, I have the other question. How do I determine the size of the parameter range when using fit.lmc. Because of my three target variables have different range base on “Spherical” model.