Loading ...
Sorry, an error occurred while loading the content.

AI-GEOSTATS: more gstat in R doubts: UK with covariate did not work

Expand Messages
  • Marta Rufino
    ... #So for example, if I additionally do (just playing not seriously....): vgm2
    Message 1 of 2 , Dec 11, 2003
    • 0 Attachment
      >Dear colegues,
      >
      >When trying Edzer suggestions, on doing UK with gstat, I found some
      >problems...
      >As this were general, I decided to post this message for the list because
      >other people may encoutered similar situations.
      >I could not manage to make UK with a covariate work...
      >
      >For example:
      >
      >
      >data(meuse)
      >vgm1 <- variogram(log(zinc)~elev, ~x+y, meuse)
      >m=fit.variogram(vgm1, vgm(1,"Sph",300,1))
      >plot(vgm1, model=m)#(this worked fine)
      >
      ># However when doing krige, it does not worked. I tried with dif. data
      >sets,.... and always similar.
      >
      >x <- krige(log(zinc)~c(elev), ~x+y, model = m, data = meuse, newd =
      >meuse.grid)
      >#Error in eval(expr, envir, enclos) : Object "elev" not found
      >
      >x <- krige(log(zinc)~meuse$elev, ~x+y, model = m, data = meuse, newd =
      >meuse.grid)
      >#Error in predict.gstat(g, newdata = newdata, block = block, nsim =
      >nsim, : dimensions do not match: locations 6206, nrows in X 155
      >
      >Maybe the covariate for the kriging should be the predictions for all the
      >borded area (similar to geoR)????
      >Like this:

      #So for example, if I additionally do (just playing not seriously....):

      vgm2 <- variogram(elev~1, ~x+y, meuse)
      m2=fit.variogram(vgm2, vgm(1,"Sph",300,1))

      plot(vgm2, model=m2)#(this worked fine)
      k.elev <- krige(elev~1, ~x+y, model = m2, data = meuse, newd = meuse.grid)
      image(k.elev)
      #### So we have a prediction of the covariate for each location within the grid
      ## And after:

      x <- krige(log(zinc)~k.elev$var1.pred, ~x+y, model = m, data = meuse, newd
      = meuse.grid)

      >I just tried it and it does not work as well....
      >What am I doing wrong?
      >
      >Thank you in advance for any help,
      >All the best
      >Marta


      [Non-text portions of this message have been removed]
    • Edzer J. Pebesma
      ... Martha, I now realize that you need more knowledge about how formulas work in S (R, S-PLUS). The example you give just does not make sense. Please read an
      Message 2 of 2 , Dec 11, 2003
      • 0 Attachment
        Marta Rufino wrote:

        >> Dear colegues,
        >>
        >> When trying Edzer suggestions, on doing UK with gstat, I found some
        >> problems...
        >
        >
        > x <- krige(log(zinc)~k.elev$var1.pred, ~x+y, model = m, data = meuse,
        > newd = meuse.grid)
        >
        >> I just tried it and it does not work as well....
        >> What am I doing wrong?
        >

        Martha, I now realize that you need more knowledge about how
        formulas work in S (R, S-PLUS). The example you give just
        does not make sense. Please read an introductory text about S
        models, or the help pages of lm(), e.g. by

        > ?lm

        Best regards,
        --
        Edzer


        --
        * To post a message to the list, send it to ai-geostats@...
        * As a general service to the users, please remember to post a summary of any useful responses to your questions.
        * To unsubscribe, send an email to majordomo@... with no subject and "unsubscribe ai-geostats" followed by "end" on the next line in the message body. DO NOT SEND Subscribe/Unsubscribe requests to the list
        * Support to the list is provided at http://www.ai-geostats.org
      Your message has been successfully submitted and would be delivered to recipients shortly.