From: Rolf Turner <rolf.turner_at_xtra.co.nz>

Date: Sun, 17 Apr 2011 11:18:26 +1200

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 16 Apr 2011 - 23:25:52 GMT

Date: Sun, 17 Apr 2011 11:18:26 +1200

On 17/04/11 02:17, Gregory Ryslik wrote:

> Hi Mr. Turner,

*>
**> You are correct that I am confused a bit by the RCode. Basically, I have 3772 observations of data and only about 500
*

500? You said 944 previously. Doesn't really matter, but.

> of them correspond to where "people" exist. For the other observations, I just have the covariate values so I thought that this was appropriate. Thus, where "people exist" is my spatial point pattern and everywhere else I just have covariate values.

*>
**> Thank you for your help and suggestions on how to fit the data. I was able to get it to work using the data frame method but I seem to be having difficulty getting the image thing to work.
**>
**> Basically, at the moment, I have two matrices for Z1 and Z2 which is in the form of (z, x, y) where z is the value, x is the x-coordinate and y-is the y coordinate. Thus the matrix dimension is 3772x3. I've tried converting this to an image but they do a index swap so I'm not quite sure what the correct way to do it would be? Hopefully, I would get the fit using the image way and see that the fits are consistent.
**>
**> Thank you again for your help!
*

To make use of a covariate you ***really*** need to have the values of
the covariate

available at ***all*** points of the observation window. In your
situation I think that

the best that you can do is to interpolate between the actual observations.

You could use, I think, the interp() function from the "akima" package.
Here's a toy

demo:

> require(akima)

*> W <- owin(c(73,135),c(18,54))
**> M <- as.mask(W,dimyx=c(250,500)) # Window is roughly twice as wide as
**> it is high.
**> set.seed(42)
**> X <- runifpoint(3772,win=W)
**> Z <- exp(2*(sin(2*X$x/pi) + sin(2*X$y/pi))) # A made-up covariate.
**> XYZ <- interp(X$x,X$y,Z,xo=M$xcol,yo=M$yrow,linear=FALSE,extrap=TRUE)
**> IZ <- im(t(XYZ$z),xcol=XYZ$x,yrow=XYZ$y) # Note the transpose of the z
**> matrix!
**> E <- as.im(function(x,y){exp(2*(sin(2*x/pi) + sin(2*y/pi)))},W=W)
**> plot(listof(exact=E,interp=IZ),nrows=2,main="")
*

The interpolated image is a bit rough compared with the truth (which we
know in this

artificial case) but no worse than what one might reasonably expect.

**HTH
**
cheers,

Rolf Turner

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 16 Apr 2011 - 23:25:52 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sun 17 Apr 2011 - 00:00:31 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*