[R] GeoR model.control - defining covariates at prediction locations

imicola N.A.Batchelor at sms.ed.ac.uk
Thu Aug 28 16:11:38 CEST 2008


Thanks,

I've managed to make some progress, but seem to be getting some strange
results from my kriging, which I think much have something to do with a
problem with my prediction points.

I have my geodata object (called nicola), my prediction points (predpoints,
imported from a csv containing only the x and y coordinated of the
prediction locations) and my covariate data at each of the prediction points
(covars, imported from a csv containing the x and y coordinates of the
prediction locations, plus the values of the two covariates I want to use at
each of the prediction locations).

>predpoints<-read.csv(file="C:\\Documents and Settings\\s9901315\\My 
+ Documents\\Uni\\Data\\Work\\Case control study\\Full study area\\R\\Files
for analysis\\Prediction 
+ points\\predpoints.csv", header=FALSE, sep=",")

>covars<-read.csv(file="C:\\Documents and Settings\\s9901315\\My 
+ Documents\\Uni\\Data\\Work\\Case control study\\Full study area\\R\\Files
for analysis\\Covariate 
+ data\\covars.csv", header=TRUE, sep=",")

The final model is defined using "OTUBOIDIST" and "LSTPHAN" as external
covariates:

>mlx2<-likfit(nicola, cov.model="mat", kap=0.5, ini=c(0.6, 20), nug=0.3,
trend=~OTUBOIDIST + 
+ LSTPHAN)

and then I carry out the kriging using the model "mlx2", prediction points
"predpoints", and covariate data "covars" :

>kcontrol<-krige.control(obj.m=mlx2, type.krige="ok", trend.d=~OTUBOIDIST +
LSTPHAN, 
+ trend.l=~covars$otuboidist + covars$lstphan) 

>krige<-krige.conv(nicola, loc=predpoints, krige=kcontrol)

Then I view it using the image function:

>image(krige, col=gray(seq(1, 0.2, l=100)))

The resulting image is clearly wrong with a regular stepped line appearing
diagonally across the image, and the predicted values do not coincide with
the actual observed data at all.  I've included the predicted data image, as
well as the predicted image overlaid with the data points.

http://www.nabble.com/file/p19201449/no%2Bpoints.jpg 
http://www.nabble.com/file/p19201449/withpoints.jpg 

Can anyone give me any pointers of why this may be going wrong?  I've tried
the same thing many times having changed everything I can think of that
might be causing the problem.

Thanks,
Nicola



N.A.Batchelor at sms.ed.ac.uk



Paulo Justiniano Ribeiro Jr-2 wrote:
> 
> Trends in ge are handled by the "trend"argument.
> In particular, for the so called "external trend" we use varioables which
> can be at the geodata object or another object.
> 
> For instance a model fitting call could be somethoing like:
> ML <- likfit..., trend= ~covar1+ covar2, ...)
> 
> where covar1 and covar2 have the same dimension as the data and can be
> vector or columuns withing the covariate elelent of a geodata obvject.
> 
> For kriging you need the values of such covariates at prediction locations
> lts say the vectors predcovar1 and predcovar2
> 
> Then you use model.control(..., trend.l= ~ predcovar1+predcovar2)
> 
> Three are osme more examples at geoR page, Tutorials section, and please
> send the commands such that we can be more specific
> 
> best
> P.J.
> 
> 
> 
> Date: Mon, 18 Aug 2008 02:59:50 -0700 (PDT)
> From: imicola <N.A.Batchelor at sms.ed.ac.uk>
> Subject: [R] GeoR model.control - defining covariates at prediction
>         locations
> To: r-help at r-project.org
> Message-ID: <19028273.post at talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
> 
> 
> Hi,
> 
> Im using geoR and I'm trying to do some predictions, based on an external
> trend.
> 
> I'm having some problems specifying my model.control, specifically how do
> I
> define my model, and also the source of the covariate data at the
> prediction
> locations?
> 
> I am assuming that the covariate data at the prediction locations should
> be
> imported to a geodata object along with the prediction location
> coordinates
> - this is what I have done, but I can't get the prediction to work.
> 
> So my question is:  How should the prediction location and covariate data
> at
> prediction locations be stored?  And also how do I specify model.control
> so
> that it recognises where my covariate data is?
> 
> Below is the error message that I am getting:
> 
> krige.bayes: model with mean defined by covariates provided by the user
> Warning messages:
> 1: locations provided as a list with more than 2 components. Only the 2
> first will be used as coordinates in: .check.locations(locations)
> 2: data length [507] is not a sub-multiple or multiple of the number of
> rows
> [254] in matrix
> Error in trend.spatial(trend = model$trend.l, geodata = list(coords =
> locations)) :
> 
> trend elements not found
> 
> Thanks,
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/GeoR-model.control---defining-covariates-at-prediction-locations-tp19028273p19201449.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list