Search Comments and Ratings

go

   
Date File Comment by Comment Rating
23 Oct 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart steve

function [a,c,n,S] = variogramfit(h,gammaexp,a0,c0,numobs,varargin)

h=[2.238; 2; 3; 5.657; 2.238; 1.414;3.606; 3.606; 4.472; 4.123];
gammaexp=[12.5; 12.5; 0; 112.5; 0; 12.5; 50; 12.5; 50; 112.5];
a0=[];
c0=[];
numobs=10;

% check input arguments

if ~exist('a0','var') || isempty(a0)
a0 = max(h)*2/3;
end
if ~exist('c0','var') || isempty(c0)
c0 = max(gammaexp);
end
if ~exist('numobs','var') || isempty(a0)
numobs = [];
end
% check input parameters
params.model = 'spherical';
params.nugget = [];
params.plotit = true;
params.stablealpha = 1.5;
params.solver ='fminsearch';
params.weightfun = 'cressie85';
params.nu = 1;

% check if fminsearchbnd is in the search path
switch lower(params.solver)
case 'fminsearchbnd'
if ~exist('fminsearchbnd.m','file')==2
params.solver = 'fminsearch';
warning('Variogramfit:fminsearchbnd',...
'fminsearchbnd was not found. fminsearch is used instead')
end
end

% check if h and gammaexp are vectors and have the same size
if ~isvector(h) || ~isvector(gammaexp)
error('Variogramfit:inputargs',...
'h and gammaexp must be vectors');
end
% check size of supplied vectors
if numel(h) ~= numel(gammaexp)
error('Variogramfit:inputargs',...
'h and gammaexp must have same size');
end
% remove nans;
nans = isnan(h) | isnan(gammaexp);
if any(nans);
h(nans) = [];
gammaexp(nans) = [];
if ~isempty(numobs)
numobs(nans) = [];
end
end
% check weight inputs
if isempty(numobs);
params.weightfun = 'none';
end
b(1)=a0;
b(2)=c0;
b0 = [a0 c0 params.nugget];

switch lower(params.model)
case 'spherical'
type = 'bounded';
func = @(b,h)b(2)*((3*h./(2*b(1)))-1/2*(h./b(1)).^3);

case 'exponential'
type = 'unbounded';
func = @(b,h)b(2)*(1-exp(-h./b(1)));
otherwise
error('unknown model')
end

% nugget variance
if isempty(params.nugget)
nugget = false;
funnugget = @(b) 0;
else
nugget = true;
funnugget = @(b) b(3);
end

% create weights (see Webster and Oliver)
switch lower(params.weightfun)
case 'cressie85'
weights = @(b,h) (numobs./variofun(b,h).^2)./sum(numobs./variofun(b,h).^2);
case 'mcbratney86'
weights = @(b,h) (numobs.*gammaexp./variofun(b,h).^3)/sum(numobs.*gammaexp./variofun(b,h).^3);
otherwise
weights = @(b,h) 1;
end

% create objective function: weighted least square
objectfun = @(b)sum(((variofun(b,h)-gammaexp).^2).*weights(b,h));
% call solver
switch lower(params.solver)
case 'fminsearch'
% call fminsearch
[b,fval,exitflag,output] = fminsearch(objectfun,b0);
case 'fminsearchbnd'
% call fminsearchbnd
[b,fval,exitflag,output] = fminsearchbnd(objectfun,b0,lb,ub);
otherwise
error('Variogramfit:Solver','unknown or unsupported solver')
end

% create vector with initial values
a = b(1); %range
c = b(2); %sill
b0 = [a0 c0 params.nugget];

if nugget;
n = b(3);%nugget
else
n = [];
end
% Create structure array with results
if nargout == 4;
S.model = lower(params.model); % model
S.func = func;
S.type = type;
switch S.model
case 'matern';
S.nu = params.nu;
case 'stable';
S.stablealpha = params.stablealpha;
end


S.range = a;
S.sill = c;
S.nugget = n;
S.h = h; % distance
S.gamma = gammaexp; % experimental values
S.gammahat = variofun(b,h); % estimated values
S.residuals = gammaexp-S.gammahat; % residuals
COVyhaty = cov(S.gammahat,gammaexp);
S.Rs = (COVyhaty(2).^2) ./...
(var(S.gammahat).*var(gammaexp)); % Rsquare
S.weights = weights(b,h); %weights
S.weightfun = params.weightfun;
S.exitflag = exitflag; % exitflag (see doc fminsearch)
S.algorithm = output.algorithm;
S.funcCount = output.funcCount;
S.iterations= output.iterations;
S.message = output.message;
end
% if you want to plot the results...
if params.plotit
switch lower(type)
case 'bounded'
plot(h,gammaexp,'rs','MarkerSize',10);
hold on
fplot(@(h) funnugget(b) + func(b,h),[0 b(1)])
fplot(@(h) funnugget(b) + b(2),[b(1) max(h)])

case 'unbounded'
plot(h,gammaexp,'rs','MarkerSize',10);
hold on
fplot(@(h) funnugget(b) + func(b,h),[0 max(h)])
end
axis([0 max(h) 0 max(gammaexp)])
xlabel('lag distance h')
ylabel('\gamma(h)')
hold off
end

% fitting functions for fminsearch/bnd
function gammahat = variofun(b,h)

switch type
% bounded model
case 'bounded'
I = h<=b(1);
gammahat = zeros(size(I));
gammahat(I) = funnugget(b) + func(b,h(I));
gammahat(~I) = funnugget(b) + b(2);
% unbounded model
case 'unbounded'
gammahat = funnugget(b) + func(b,h);
if flagzerodistances
gammahat(izero) = funnugget(b);
end
end
end

end

23 Oct 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart steve

look at that code and please advice me accordingly. i am trying to come up with a variogram for modeling but i just cannot get through. thanks

23 Oct 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@steve: thanks for your comment. variofun is a subfunction that you'll find below the main function.

23 Oct 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart steve

nice work there. what am wondering is what does variofun mean? since am trying to run that code am being told that it is an undefined variable. please help

09 Apr 2014 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Carlos

Wolfgang,

Thanks for this awesome submission. It was very helpful. I however have a questions..

On line 165 you perform the following operation

edges(end) = inf;

Can you explain the logic behind it?

The reason that I ask it that when the data is uniformly distributed in space the number of data pairs separated by a lag (h) decreases as h increases.

However, as written line 165 then makes later lines (l78 and 179)

S.val = accumarray(ixedge,...
lam,[numel(edges) 1],fvar,nan);

S.num = accumarray(ixedge,ones(size(lam))...
,[numel(edges) 1],@sum,nan);

Calculate the gamma value and the number of pairs using the the rest of the data set. You then do a final modification of the arrays but that does eliminate the extra data poins used int he Variogram calculation..

Let me give you an example.

My edges vector before line 165

250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 3000

My edges vector after line 165

250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 Inf

Then on lines
178,179 and 186, 187

you produce the S.distance,S.num and S.val struct arrays

This is what the S.distance says:

625
875
1125
1375
1625
1875
2125
2375
2625
2875

Then this is what the S.num says:

41
40
39
38
37
36
35
34
33
32
31
59

You see That 59 should not be there there are no 59 number of data pairs with an average lag distance of 2875. In fact there are only 30.

If I comment line 165 then I get the expected result of monotonically decreasing number of pairs as lag distance increases.

Let me know what you think...

Carlos Soto

04 Mar 2014 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart kaiba Wong

Fantastic code - just what I needed. However, I am trying to modify it a bit for cross-variogram. Can I do it this way: save the
lam = (y(iid(:,1))-y(iid(:,2)));
for two separate variable (say A and B) Combine=bsxfun(@times, lamA,lamB);
Combine_cross = accumarray([ixedge ixtheta],Combine,...
[21 7],fvar,nan);
Combine_cross(:,end)=Combine_cross(:,1);

Is this approach correct?
Thanks

26 Feb 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Roque Santos: Hi, see here: http://blogs.mathworks.com/community/2010/12/13/citing-file-exchange-submissions/

23 Feb 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Roque Santos

Hello friend,
I used your code in a job (Masters), wanted to know how do I quote your code.
I await
Hug!

25 Jan 2014 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Zoltán

Hi Wolfgang!

Thank you for this, it is a very good one!

Could you please explain me, where is your algorithm calculate the separation (or lag) vector(h). Theoretically, if I am calculating a variogram, I use this formula:

gamma^2(h)=(1/2N(h))*sum(f(u+h)-f(u))^2

Did you used the same? If yes, how do you calculated h? (in which row?)

Thank you!

Zoltán

06 Jan 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Roque Santos: thanks for your comment. Please check the documentation for varargin here: http://www.mathworks.de/de/help/matlab/ref/varargin.html

06 Jan 2014 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Roque Santos

Hello, ... great code! Congratulations on your initiative!
Could not identify the input variable "varargin".
Could you help me?

06 Dec 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@JG: Yes, [x y] can also be a nx1 vector with n number of points in time. Use datenum to calculate a numeric vector from your dates. Variogram doesn't do the conversion for you.

06 Dec 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart J G

Thanks Wolfgang. Also, can this be used for temporal separation too? i.e., can [x y] be time?

25 Nov 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@JG: This syntax is correct. Take care, however, if latitude and longitude refer to geographic coordinates... The function doesn't calculate distances on a sphere.

25 Nov 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart J G

Thanks for this!
I just want to make sure I'm using it correctly;

If I have latitude and longitude coordinates ([x y]), and my data (z),

I use: variogram([x y],z)

24 Sep 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Edgar.

Hi Edgar, yes, this seems to be an error in the function. Thanks for reporting it! I hardly needed those plot options so I probably forgot to care for them when adding anisotropy. Regarding your earlier question, I suppose that this should be ok.

I'll see if I can make a update in the next couple of days. Unfortunately, my time to support these functions at the moment is quite scarce...

24 Sep 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Edgar

Hi Wolfang,
When types "cloud1" and "cloud2" are used in combination with anisotropy, the function does not return an array (a column for each theta tested). I'm guessing this is an error in the function?

Best,
Edgar

10 Sep 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Edgar

Hi Wolfang,

I'm working with meteorological data, I can see a mountain range drives the spatial variation of the meteorological fields. The mountain range has an orientation (larger axis) at 110° (calculated clockwise from top, i.e. positive latitud axis). The corresponding semi-variogram from your script would be the one at 20°? Thanks for your help. Really nice algorithm, congrats!

29 Aug 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Jeff

Very helpful, thank you. I made a small change so that the nugget can be specified directly and not optimized:
line 299: funnugget = @(b) params.nugget;
line 336: [b,fval,exitflag,output] = fminsearchbnd(objectfun,b0(1:2),lb(1:2),ub(1:2),options);
line 346: n = params.nugget;

It's not pretty, but it works.

12 Aug 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Ricardo

Hi Wolfgang,
Yes, that's a decision that concerns me these days, because either I use one variogram per time sample or as i have a lot of timesamples, I can do a training phase for kriging and I get a variogram characteristic from the system, which I will use in the test phase. I am currently working on my own 3d kriging and i wanted to compare results.
Thank you very much!

09 Aug 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Ludwig: Yes. The output is the function parameter, which means that b(1) (or a or S.range) is 1/3 of the range. Sorry for the confusion. Perhaps I should at least provide two different values (S.range and b(1)) in the structure array output.

09 Aug 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

Hi Ricardo, I am afraid my kriging won't work in three dimensions. However, it shouldn't be a very big deal do modify the function to do so. However, I am skeptical how you want to handle time and space dimensions in calculating one variogram.

09 Aug 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Ricardo

Hi again,
I just realize the NaN make sense in my data.
But still i have some questions.
Once I already know that variogram can work with 3d input, I tryed the kriging script but it seems like the input is 2dimensional, is there a way to use 3D data on the kriging script?
I am working with temperature samples along a period of time, and i wonder if i can in the variogram function give as values the entire time samples matrix, instead only one time sample only.
I hope i am being clear enough.
Thank you so much

09 Aug 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Ricardo

09 Aug 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Ricardo

Thank you so much Wolfgang!
I tried and at the beginning i had an error but i changed what @Shen said
d = sqrt(sum((X(i,:)-X(j,:)).^2,2));
and it worked, but the d.val has a lot of NaN, is that OK? because I have very bad fits on the variogramfit script.
Thanks again

09 Aug 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Ludwig

@Wolfgang: My issue was around the output. For unbounded models, won't S.range (or a) be 1/3 of the range since it is just assigned b(1)?

08 Aug 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Ludwig: I know that the way range is used for unbounded models is confusing. When supplying the initial values you should enter the range where the model reaches about 95% of the sill variance. I decided to do so, since it can be easier visually determined from the experimental variogram and can better compared to bounded models. The parameter b(1) in the exponential variogram model
gamma = b(2)*(1-exp(-h./b(1)));
should be approx. 1/3 of this range.

08 Aug 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Ludwig

I am working with fitting exponential models to my data and was a bit confused about the outputted range. Should the range be 3x the fitted parameter that is currently being called the range? When I ask the function to include a plot I can see that the given range is not 95% of the sill.

It is possible I am having a misunderstanding.

01 Aug 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Aditi

25 Jul 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Riccardo: variogram supports higher dimensional data. In your case, just call the function like
variogram([x(:) y(:) z(:)], values, ...)

25 Jul 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Ricardo

Hello Wolfgang,
I am trying to apply Kriging to a 3d mesh but first of all i don't know if i can use your variogram from a 3d data, it seems that only accepts X ans Y, not Z coordinates. Is there any way to use it with 3d input?
Thank you very much
Ricardo

16 May 2013 neighbor indexing returns neighbors of cells in n*m matrices Author: Wolfgang Schwanghart Fernando Gonzalez

Very useful!

24 Apr 2013 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart meo

24 Apr 2013 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart meo

04 Apr 2013 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart Willy

@Wolfgang: I really appreciate your interactivity and your pertinence in all your comments. I just coded the Deutsch method to solve the problem of the negative weights. Thanks to your doi link. Thus, the gaussian variogram is now well working :)

Here are the lines code to insert within the "for" loop, between the paragraphs "solve system" and "estimate zi".

However, I'm not an excellent developper. I'll let you find some better/faster way to code this.

% solve system
lambda = A*b;

% correct negative weights (Deutsch 1996)
if sum(lambda(:)<0) % if negative weigths are found
% compute the "average absolute magnitude of the negative weights"
lambdaLim=lambda(1:end-1,:);
PosInd=lambdaLim>=0;
lambdaLim(PosInd)=NaN;
lambdaLim=nanmean(abs(lambdaLim),1);
% compute the mean covariance between "negative" locations and the IX ones
bNoOnes=b(1:end-1,:);
bLim=bNoOnes;
bLim(PosInd)=NaN;
bLim=nanmean(bLim,1);
% correct the weights
lambdaC=lambda(1:end-1,:); % step 1 of Deutsch 1996
lambdaC(lambdaC<0)=0; % step 2 of Deutsch 1996
lambdaC(PosInd & bNoOnes-repmat(bLim,numobs,1)<0 & lambda(1:end-1,:)-repmat(lambdaLim,numobs,1)<0)=0; % step 3 of Deutsch 1996
% restandardization of the weights
lambda(1:end-1,:)=lambdaC./repmat(sum(lambdaC,1),numobs,1);
end

% estimate zi
zi(IX) = lambda'*z;

03 Apr 2013 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Sébastien: Thanks for pointing at the error when using a nugget variogram.

I am currently abroad, so I probably won't find much time to update the function. So, in the meantime please adopt the changes proposed by Sébastien.

The problem with the gaussian variogram is most likely due to negative weights (see http://dx.doi.org/10.1016/0098-3004(96)00005-2 ). I will try to implement the procedure suggested by Deutsch (1996) in a future update.

03 Apr 2013 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart Sébastien

Very nice submission. I was amazed by its speed.
However, two things to say:

1) there is a mistake in the code when expanding b with ones. It should be the following:
% expand b with ones
b = vstruct.func([vstruct.range vstruct.sill],b);
if ~isempty(vstruct.nugget)
b = b+vstruct.nugget;
end
b=[b;ones(1,chunksize)];
Indeed, the ones should be added AFTER adding the nugget. Otherwise, the nugget is also applied to the ones: an offset is then unfortunately observed on the results...

2) I have the same problem than Kirsten: it's working well with spherical variograms. However, when I apply a gaussian one, huge values are found. I'm actually investigating the problem. If I find something, I'll let you know. But I would appreciate if you find the solution first ;)

15 Feb 2013 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart Wolfgang Schwanghart

@Imran Zafar: Fig. 4 shows the kriging variance which quantifies the uncertainty of the kriging estimates. You will note, that the kriging variance increases with increasing distance from observations.

11 Feb 2013 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart Imran Zafar

@Wolfgang Schwanghart: can you please illustrate the figure showing 4 plots? No description given. Please get back

02 Jan 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

Hi Shen,

you are right! Thanks for pointing out this bug. Seems I have not thoroughly checked the multidimensional support since I've never needed it. I'll correct for it as soon as possible.

Thanks again,
Wolfgang

02 Jan 2013 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Shen Liu

Hi Wolfgang,

I am not sure if the following had been spotted:

In Line 253, when calculating the distances for more than two dimensions, the code was
d = sqrt(sum((X(i,:)-X(j,:)).^2));

I think it should be
d = sqrt(sum((X(i,:)-X(j,:)).^2,2));
as we need the sums of the rows but not the columns. After this correction, everything works perfectly in calculating 3-dimensional variograms.

Many thanks for your function. It is absolutely fabulous!

Best regards,
Shen

27 Dec 2012 variogramfit fits different theoretical variograms to an experimental variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@ C Gutierrez: I think I haven't seen this error so far. Can you send me more information on how you have called variogramfit via the "contact author" interface?

27 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@vipul utsav: the nugget variance is the variogram value at zero lag distance. You can estimate it visually from the experimental variogram or (better) use variogramfit (http://www.mathworks.de/matlabcentral/fileexchange/25948) to estimate it from the data.

27 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart vipul utsav

nugget variance from variogram ,how it is possible?

13 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@dd: Right now, this is not possible, but with a minor modification of the function, it is not a problem. Just enter following line in the section where the output for the type 'cloud1' is calculated (Line 202)

S.ij = iid(:,[1 2]);

This gives you the indices for each point pair. You can now take these to calculate e.g. the correlation coefficient for a binned lag distance.

x = rand(1000,1)*4-2;
y = rand(1000,1)*4-2;
z = 3*sin(x*15)+ randn(size(x));
d = variogram([x y],z,'type','cloud1');

% should give you this
d =

distance: [382476x1 double]
val: [382476x1 double]
ij: [382476x2 double]

distbins = unique(d.distance);

% calculate the correlation coefficient
% for the second distance bin
I = d.distance == distbins(2);

corrcoef(z(d.ij(I,1)),z(d.ij(I,2)))

ans =

1.0000 -0.2306
-0.2306 1.0000

Hope it works out for you.

Cheers, W.

13 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart dd

@ Wolfgang:
I would need it mostly for didactic purpose: how gamma, corr. and covar. are evolving along with lag distance.
Another question: how can I produce a crossplot of a variable between two lag distances?
Many thanks

12 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart Wolfgang Schwanghart

@dd: the covariance (C(h)) as a function of lag distance h is directly related to the semi-variogram (gamma(h)) and can be calculated by

gamma(h) = C(0)-C(h)

You can take the sill variance as C(0) but this only works for bounded variograms.

Why do you need the correlation or covariance?

12 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart dd

Hi Wolfgang,
I was wondering if there would be a simple way to include correlation and covariance in the analysis?
Thanks

12 Dec 2012 Experimental (Semi-) Variogram calculate the isotropic and anisotropic experimental (semi-) variogram Author: Wolfgang Schwanghart dd

16 Oct 2012 Ordinary Kriging 2D-interpolation using geostatistics Author: Wolfgang Schwanghart Kirsten

I sent this dataset to Wolfgang and Yesid, but in case anyone else wants to take a look here's my issue... I've used this dataset with an exponential and spherical model and get good results, but when I use the gaussian model it goes crazy at the domain edges. It will even predict min and max values smaller/larger than those in the original dataset, which should not be possible (and doesn't happen with the other variogram models). The problem seems to be worst at the edge where x=23.45 (I'm using leave-one-out validation and getting strange answers). Thanks for your help!
Kirsten
Here's my data:
x,y,z=[0.000000 0.000000 0.143917
5.860000 0.000000 0.159720
11.730000 0.000000 0.147167
17.590000 0.000000 0.181833
23.450000 0.000000 0.094583
0.000000 7.400000 0.170333
5.860000 7.400000 0.161250
11.730000 7.400000 0.160000
17.590000 7.400000 0.130750
23.450000 7.400000 0.119333
5.860000 8.750000 0.132833
11.730000 8.750000 0.109583
17.590000 8.750000 0.113000
23.450000 8.750000 0.090167
0.000000 14.800000 0.131231
5.860000 14.800000 0.137417
11.730000 14.800000 0.175333
17.590000 14.800000 0.191167
23.450000 14.800000 0.125333
5.860000 17.490000 0.037083
11.730000 17.490000 0.138750
17.590000 17.490000 0.093500
23.450000 17.490000 0.076917
0.000000 22.200000 0.159923
5.860000 22.200000 0.112000
11.730000 22.200000 0.397667
17.590000 22.200000 0.189750
5.860000 26.240000 0.146250
11.730000 26.240000 0.113083
17.590000 26.240000 0.116083
23.450000 26.240000 0.108750
0.000000 29.610000 0.126833
5.860000 29.610000 0.122667
11.730000 29.610000 0.200167
17.590000 29.610000 0.128333
23.450000 29.610000 0.118500
5.860000 34.990000 0.077750
11.730000 34.990000 0.084167
17.590000 34.990000 0.240167
23.450000 34.990000 0.100167
0.000000 37.010000 0.122583
5.860000 37.010000 0.139417
11.730000 37.010000 0.145083
17.590000 37.010000 0.142250
23.450000 37.010000 0.085833
5.860000 43.740000 0.046538
11.730000 43.740000 0.120583
17.590000 43.740000 0.105833
23.450000 43.740000 0.079500
0.000000 44.410000 0.133500
5.860000 44.410000 0.148250
11.730000 44.410000 0.136182
17.590000 44.410000 0.151083
23.450000 44.410000 0.116917
0.000000 51.810000 0.080750
5.860000 51.810000 0.127500
11.730000 51.810000 0.124000
17.590000 51.810000 0.108917
23.450000 51.810000 0.144250
0.000000 52.480000 0.079583
5.860000 52.480000 0.038750
11.730000 52.480000 0.142545
17.590000 52.480000 0.081917
23.450000 52.480000 0.066417
0.000000 59.210000 0.120917
5.860000 59.210000 0.106333
11.730000 59.210000 0.118750
17.590000 59.210000 0.108500
23.450000 59.210000 0.091667
0.000000 61.230000 0.191750
5.860000 61.230000 0.086667
11.730000 61.230000 0.102417
17.590000 61.230000 0.083455
23.450000 61.230000 0.058250
0.000000 66.610000 0.080083
5.860000 66.610000 0.161750
11.730000 66.610000 0.092833
17.590000 66.610000 0.047500
23.450000 66.610000 0.138083
0.000000 69.980000 0.104667
5.860000 69.980000 0.059000
11.730000 69.980000 0.048833
17.590000 69.980000 0.038167
23.450000 69.980000 0.052917
0.000000 74.020000 0.056500
5.860000 74.020000 0.104833
11.730000 74.020000 0.084250
17.590000 74.020000 0.080083
23.450000 74.020000 0.065583
0.000000 78.730000 0.051333
5.860000 78.730000 0.076333
11.730000 78.730000 0.069083
17.590000 78.730000 0.067250
23.450000 78.730000 0.047167
0.000000 81.420000 0.099417
5.860000 81.420000 0.082000
11.730000 81.420000 0.064917
17.590000 81.420000 0.054000
23.450000 81.420000 0.026333
0.000000 87.470000 0.036333
5.860000 87.470000 0.032083
11.730000 87.470000 0.040250
17.590000 87.470000 0.025000
23.450000 87.470000 0.014000
0.000000 88.820000 0.070750
5.860000 88.820000 0.054000
11.730000 88.820000 0.058083
17.590000 88.820000 0.049917
0.000000 96.220000 0.035667
5.860000 96.220000 0.028750
11.730000 96.220000 0.031125
17.590000 96.220000 0.030217
23.450000 96.220000 0.005333];

Contact us