[R-sig-Geo] derivation for surf.ls

Claudia Dupke claudia.dupke at googlemail.com
Fri Feb 22 13:58:37 CET 2013


Hi everyone,

for a spatial prediction I want to use a simple linear regression where 
spatial coordinates are used for predictors (trend surface analysis) 
which can easily be done by

DAT <- 
as.data.frame(cbind(x=Grid at coords[,1],y=Grid at coords[,2],z=Grid at data$z))
#I attached DAT

dg <- 4
M1 <- surf.ls(np=dg,DAT)

I would like to get the derivation of the function, so I tried

PD <- predict.derivative(M1,DAT$x,DAT$y)

I would have expected to obtain a matrix of partial derivatives: The 
columns being the partial derivatives and the rows the locations as it 
is explained in the manual. Instead, I get a vector. What is that?

Furthermore, is there a convenient way of getting the explicit equation 
of the modelfunction, instead of taking the coefficients manually out of 
the model output?
I have also tried to use lm for modelling the surface
M2 <- lm(z ~ poly(x,y, degree= dg,raw=FALSE), data=DAT)
but also here I can not find an easy way to derive the derivation of the 
model function.

Any suggestion would be helpful.
Thanks in advance,
Claudia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130222/51e53452/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DAT.RData
Type: application/octet-stream
Size: 2100 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130222/51e53452/attachment.obj>


More information about the R-sig-Geo mailing list