[R-sig-Geo] apply autofitVariogram() to already calculated variograms
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Thu Sep 27 19:25:35 CEST 2012
Why don't you modify autofitVariogram such that you feed it with a
sample variogram rather than point data? Seems like the main thing
involved is removing code...
On 09/27/2012 05:48 PM, Laura Wette wrote:
> Dear mailing list,
>
> I have to fit several (more than 150) variograms. I found the function
> autofitVariogram(), which fits the best model automatically to variograms.
> But I have problems with the usage of the function because of this reason:
> I created the variograms before as I just need a selection of all the point
> pairs (I just need those pairs which include the center point of a polygon,
> e. g. row number 1 in input data frame). Unfornunately, autofitVariogram()
> wants to estimate the variogram on its own. Is there a possibility that
> autofitVariograms can handle objects of class "gstatVariogram" as well? You
> can see my code below.
>
> library(gstat)
> loadMeuse()
>
> ## generate a variogram where I can see each combination of points in the
> ## columns "left" and "right". The numbers are the row indexes of the input
> ## data frame
>> v = variogram(log(zinc)~1, meuse, cloud=TRUE)
>> v[1:10,]
> dist gamma dir.hor dir.ver id left right
> 1 70.83784 0.006065804 0 0 var1 2 1
> 2 118.84864 0.109534743 0 0 var1 3 1
> 3 141.56624 0.167153095 0 0 var1 3 2
> 4 259.23927 0.952808244 0 0 var1 4 1
> 5 282.85155 1.110920725 0 0 var1 4 2
> 6 143.17123 0.416229664 0 0 var1 4 3
> 7 366.31407 0.890852716 0 0 var1 5 1
> 8 362.64032 1.043938763 0 0 var1 5 2
> 9 251.02390 0.375633672 0 0 var1 5 3
> 10 154.26276 0.001041290 0 0 var1 5 4
>
> ## extract point pairs where row 1 of input-data frame is contained.
> ## %/% stands for right, %% for left
> v1 = v[((v$np %/% attr(v, ".BigInt"))+1)==1 | v$np %% attr(v,
> ".BigInt"))+1==1,][1:10,]
> dist gamma dir.hor dir.ver id left right
> 1 70.83784 0.006065804 0 0 var1 2 1
> 2 118.84864 0.109534743 0 0 var1 3 1
> 4 259.23927 0.952808244 0 0 var1 4 1
> 7 366.31407 0.890852716 0 0 var1 5 1
> 11 473.62960 0.833549786 0 0 var1 6 1
> 16 258.32151 0.586528972 0 0 var1 7 1
> 22 252.04960 0.426115526 0 0 var1 8 1
> 29 380.18943 0.583407369 0 0 var1 9 1
> 37 471.00849 1.479252663 0 0 var1 10 1
> 46 510.07548 1.424283374 0 0 var1 11 1
>
>> class(v1)
> [1] "variogramCloud" "data.frame"
>
> ## change the object-class of v1
> class(v1) = c("gstatVariogram", "data.frame")
> v1$np = rep(1, nrow(v1))
>
> (at this point special thanks again to Edzer)
>
> Now, it is feasible to apply fit.variogram() to v1. Isn't there any
> possibility to apply autofitVariogram()? I searched the Internet, but
> didn't found other possibilities to fit automatically. However, maybe there
> is another function I can use? I think making a for loop around
> fit.variogram isn't the right solution as all the variograms are very
> different and thus I cannot make any estimates for sill, etc. which fit
> each variogram.
>
> Thanks for any answers in advance!
> Regards
> Laura
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
More information about the R-sig-Geo
mailing list