1

When working with the R package RandomFields you specify your model describing the spatial distribution of your data by adding different components.
E.g: Nearer points in your data are more familiar to each other than farer points are, so that they follow an exponential variogram. But there is still quite some noise, resulting in your variogram having a nugget effect. You would write:

RMexp(var = partial sill, scale = range) + RMnugget(var = nugget)

adding the nugget seperately.
Imagine your data values additionaly increase as a linear function of your x-coordinates. I'm quite sure you would still add + RMtrend() to the above model, specifying the trend.
And this is now where I get stuck. I really don't get the help(RMtrend)-page -- especially the examples leave me stranded (what does this R.p-function do? It's help page is completely gibberish to me, not knowing any C-language).

Anyway, RMtrend only takes one argument: mean, which can't be a formula, only a numeric vector or another RMmodel. It seems to me as if there was no RMmodel to define linear or polynomial trends, so that I could hand it over to RMtrend. I also tried to trick RMtrend into giving it a formula via

RMtrend(RFformula(response Variable ~ x))

which gives an error later, saying that RFformula was misused. And it seems not to be possible to give RMtrend() a vector with the length of the number of grid nodes of the simulation grid, specifying the "mean" (= modeled trend) at each of them.
E.g. my grid is supposed to have 62250 points. And if I simulate without a trend I indeed get a matrix with 249 rows and 250 columns, but if I hand over a vector with 62250 numeric entries to RMtrend() RFsimulate() will still give me an Error (or result in a fatal error of R):

Error in rfInit(model = list("Simulate", setseed = eval(parse(text = "quote(set.seed(seed=seed))")),  : 
  'RFsimulate' :  Number of data (62250) not a multiple of the number of locations (62567 x 0)

So how is it possible to give RMtrend a linear or polynomial trend?

mattu
  • 318
  • 2
  • 16

0 Answers0