[R] issues with krige function

Adrienne Wootten amwootte at ncsu.edu
Wed Oct 31 16:48:19 CET 2012


Thierry, To answer your first question

summary(casedata)
   station               year          month        day          obs
           mpe
 Length:236         Min.   :2011   Min.   :8   Min.   :28   Min.
:0.0000   Min.   :0.00000
 Class :character   1st Qu.:2011   1st Qu.:8   1st Qu.:28   1st
Qu.:0.0000   1st Qu.:0.00000
 Mode  :character   Median :2011   Median :8   Median :28   Median
:0.0000   Median :0.00000
                    Mean   :2011   Mean   :8   Mean   :28   Mean
:0.6119   Mean   :0.60163
                    3rd Qu.:2011   3rd Qu.:8   3rd Qu.:28   3rd
Qu.:0.0225   3rd Qu.:0.03953
                    Max.   :2011   Max.   :8   Max.   :28   Max.
:9.3600   Max.   :9.05766
      bias              type                lat             lon
     city
 Min.   :-4.75583   Length:236         Min.   :33.53   Min.   :-84.84
 Length:236
 1st Qu.: 0.00000   Class :character   1st Qu.:34.37   1st Qu.:-82.71
 Class :character
 Median : 0.00000   Mode  :character   Median :35.06   Median :-81.18
 Mode  :character
 Mean   :-0.01028      Mean   :35.18   Mean   :-81.00
 3rd Qu.: 0.00000        3rd Qu.:35.99   3rd Qu.:-79.37
 Max.   : 2.82117          Max.   :36.98   Max.   :-76.33
    state            preciptime
 Length:236         Length:236
 Class :character   Class :character
 Mode  :character   Mode  :character

>  summary(gridmeta)
      lon              lat            xcell             ycell
     row              col
 Min.   :-86.29   Min.   :30.51   Min.   :1895112   Min.   :-6545105
Min.   :  1.00   Min.   :  1.0
 1st Qu.:-82.38   1st Qu.:33.73   1st Qu.:2184464   1st Qu.:-6330770
1st Qu.: 61.75   1st Qu.: 46.0
 Median :-79.88   Median :35.22   Median :2473816   Median :-6114053
Median :122.50   Median : 91.5
 Mean   :-79.91   Mean   :35.26   Mean   :2473816   Mean   :-6114053
Mean   :122.50   Mean   : 91.5
 3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.:2763169   3rd Qu.:-5897337
3rd Qu.:183.25   3rd Qu.:137.0
 Max.   :-73.16   Max.   :40.16   Max.   :3052521   Max.   :-5683002
Max.   :244.00   Max.   :182.0


To answer your second question, I'm not quite sure why, but apparently
constraining nmax like that was exactly what it needed, because now it
is producing values.
v.fit = vgm(psill=1.2914,model="Mat",range=14.1611,nugget=0.23,kappa=83.1047)
krige.pred.out =
krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta,model=v.fit)
summary(krige.pred.out)

      lon              lat                 var1.pred         var1.var
 Min.   :-86.29   Min.   :30.51   Min.   :-1.083   Min.   :0.253
 1st Qu.:-82.38   1st Qu.:33.73   1st Qu.:-0.044   1st Qu.:0.253
 Median :-79.88   Median :35.22   Median : 0.000   Median :0.253
 Mean   :-79.91   Mean   :35.26   Mean   :-0.051   Mean   :0.253
 3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.: 0.000   3rd Qu.:0.253
 Max.   :-73.16   Max.   :40.16   Max.   : 1.252   Max.   :0.254
                                               NA's   :14925    NA's   :31483

Thanks for the help.

Adrienne


On Wed, Oct 31, 2012 at 10:28 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
> Dear Adrienne,
>
> What is the output of summary(casestudy) and summary(gridmeta)?
>
> What happens if you set nmax to 10?
> krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta ,model=v.fit, nmax = 10)
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
>
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Adrienne Wootten
> Verzonden: dinsdag 30 oktober 2012 18:36
> Aan: r-help at r-project.org
> Onderwerp: [R] issues with krige function
>
> Greetings all,
>
> Ran into a strange problem with the krige function from geoR.  The problem that I am having is that while the krige function seems to work well, the resulting predicted values are all NAs.  Given the size of the datasets I am working with can't attach it, but I can provide snippets of the datasets.
>
>> casedata
>    station year month day  obs         mpe        bias type      lat       lon
> 140  319147 2011     8  28 0.00 0.000000000  0.00000000 COOP 35.48667 -82.96833
> 141  319354 2011     8  28 0.02 0.001305799 -0.01869420 COOP 34.25722 -78.68722
> 142  319357 2011     8  28 0.00 0.045194085  0.04519409 COOP 34.40944 -78.79139
> 143  319440 2011     8  28 6.92 5.530313974 -1.38968603 COOP 35.85278 -77.03056
> 144  319461 2011     8  28 0.98 0.949224103 -0.03077590 COOP 34.14250 -77.87861
> 145  319467 2011     8  28 0.30 1.492852601  1.19285260 COOP 34.32083 -77.92056
> 146  319476 2011     8  28 2.95 3.284362345  0.33436235 COOP 35.69389 -77.94556
> 147  319555 2011     8  28 0.00 0.000000000  0.00000000 COOP 36.13083 -81.22750
> 148  319667 2011     8  28 0.00 0.014472943  0.01447294 COOP 35.85583 -80.36083
> 149  319675 2011     8  28 0.00 0.000000000  0.00000000 COOP 36.13056 -80.54806
>
>> v.fit =
>> vgm(phi=1.2914,model="Mat",range=14.1611,nugget=0.23,kappa=83.1047)
>> krige.pred.out =
>> krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta
>> ,model=v.fit)
> [using ordinary kriging]
>
>> krige.pred.out
>    lon      lat var1.pred var1.var
> 1  -86.28771 33.91335       NaN      NaN
> 2  -86.27388 33.94722       NaN      NaN
> 3  -86.26003 33.98111       NaN      NaN
> 4  -86.24615 34.01500       NaN      NaN
> 5  -86.23225 34.04890       NaN      NaN
> 6  -86.21835 34.08280       NaN      NaN
> 7  -86.20441 34.11672       NaN      NaN
> 8  -86.19045 34.15064       NaN      NaN
> 9  -86.17648 34.18457       NaN      NaN
> 10 -86.16249 34.21851       NaN      NaN
>
>>  summary(krige.pred.out)
>       lon              lat                 var1.pred        var1.var
>  Min.   :-86.29   Min.   :30.51   Min.   : NA     Min.   : NA
>  1st Qu.:-82.38   1st Qu.:33.73   1st Qu.: NA     1st Qu.: NA
>  Median :-79.88   Median :35.22   Median : NA     Median : NA
>  Mean   :-79.91   Mean   :35.26   Mean   :NaN     Mean   :NaN
>  3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.: NA     3rd Qu.: NA
>  Max.   :-73.16   Max.   :40.16   Max.   : NA     Max.   : NA
>                                                NA's   :44408   NA's   :44408
>
>
> Any ideas are greatly appreciated, I'm not getting any warnings or errors from krige, so this is perplexing to me.
>
> --
> Adrienne Wootten
> Graduate Research Assistant
> State Climate Office of North Carolina
> Department of Marine, Earth and Atmospheric Sciences North Carolina State University
>
> ______________________________________________
> 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.
> * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
> The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.



-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University




More information about the R-help mailing list