[R-sig-Geo] [FORGED] different models
Rolf Turner
r.turner at auckland.ac.nz
Thu Apr 7 05:11:20 CEST 2016
On 06/04/16 22:00, Virginia Morera Pujol wrote:
> Hi all,
>
> This might be a very dumb question that shows I have very little idea of
> what I am talking about, but I'll risk it:
>
> What is the difference between fitting a model using these 3 different
> syntaxes?
>
> 1/ fit1 <- ppm(ppp, ~covariate),
> 2/ fit2 <- ppm(ppp, ~x+y+Z, covariates=list(Z=covariate))
> 3/ fit3 <- ppm(ppp, ~x+y+covariate)
>
> where ppp is my point pattern and "covariate" is a pixel image? I realise
> the outputs of 2 and 3 are the same and different to that of 1, so I guess
> the question really is
>
> a/ Is there any difference, practical or in the actual computations of the
> model, between using 2 and 3?
> b/ What is the difference between (2&3) and 1?
(1) There is essentially no difference between fits 2 & 3. The fit 2
syntax is provided so that the user can have the relevant covariates
bundled up in a list without any need to extract these covariates from
that list. With the fit 2 syntax you don't need to have all covariates
present in your workspace.
E.g.: fit <- ppm(bei ~ elev + grad, data=bei.extra)
(2) The fit 2 syntax is essentially the same as that used by lm() and
glm() and was designed in imitation thereof.
(3) The preferred structure of a call to ppm() is
fit2 <- ppm(ppp ~ x + y + Z, data=list(Z=covariate))
Note: "data" rather than "covariates"; no comma between the name of the
response variable ("ppp") and the formula.
This makes the syntax identical to that of lm() and glm().
The syntax that you used is a remnant of earlier versions of spatstat
and remains acceptable for reasons of backward compatibility.
(4) The difference between model 1 and models 2 and 3 is that models 2
and 3 involve the Cartesian coordinates "x" and "y". Model 1 is such
that the model intensity takes the form
exp(beta_0 + beta_1 * covariate)
In models 2 and 3 the model intensity takes the (more complex) form
exp(beta_0 + beta_1 * x + beta_2 *y beta_3 * covariate)
Note that "x" and "y" are *reserved* names. You cannot use these names
for any covariates *other than* the Cartesian coordinates.
(5) The name "covariate" is probably *not* a good name for a covariate.
As fortune(77) puts it "Would you call your dog 'dog'?"
(6) Likewise (and even more so) "ppp" is *not* a good name for a point
pattern, since it clashes the name of the creator function ppp().
cheers,
Rolf Turner
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
More information about the R-sig-Geo
mailing list