Modeling space/time variability

advertisement
Modeling space/time variability
2. The covariance of Space/Time Random Fields (S/TRF)
2.1 Definitions
The Space/Time Random Field (S/TRF) X(p) =X(s,t) is a random variable that is a function of
location s=(s1,s2) and time t.
The space/time covariance between space/time points p and p’ is
cX(p,p’) = E[(X(p)- mX(p))(X(p’)- mX(p’))]
2.2 Homogeneous / Stationary S/TRF
A homogeneous/stationary S/TRF has the following properties:
It’s mean trend is constant, mX(p)= mX
It’s covariance is only a function of the spatial lag r and temporal lag ;
cX(p,p’) = cX((s,t), (s’,t’)) = cX( r=||s-s’|| , =| t- t’|)
Are the following s/t covariance homogeneous/stationary?
Homogeneous/stationary
cX(p,p’) = c0 exp-||s+s’|| exp-|tt’|
cX(p,p’) = c0 exp-||s-s’|| exp-|t-t’|= c0 exp-r exp-
cX(p,p’) = c0 exp[-||s-s’|| |t-t’|] = c0 exp-(r
Separable
17
2. The covariance of Space/Time Random Fields (S/TRF)
2.1 Definitions
The Space/Time Random Field (S/TRF) X(p) =X(s,t) is a random variable that is a function of
location s=(s1,s2) and time t.
The space/time covariance between space/time points p and p’ is
cX(p,p’) = E[(X(p)- mX(p))(X(p’)- mX(p’))]
2.2 Homogeneous / Stationary S/TRF
A homogeneous/stationary S/TRF has the following properties:
It’s mean trend is constant, mX(p)= mX
It’s covariance is only a function of the spatial lag r and temporal lag ;
cX(p,p’) = cX((s,t), (s’,t’)) = cX( r=||s-s’|| , =| t- t’|)
Are the following s/t covariance homogeneous/stationary?
Homogeneous/stationary
cX(p,p’) = c0 exp-||s+s’|| exp-|tt’|
NO
cX(p,p’) = c0 exp-||s-s’|| exp-|t-t’|= c0 exp-r exp-
YES
cX(p,p’) = c0 exp[-||s-s’|| |t-t’|] = c0 exp-(r
YES
Separable
n/a
YES

18
2.3 Space/time separable covariance for homogeneous / stationary S/TRF
A homogeneous/stationary S/TRF is space/time separable if its covariance can be written as
cX(r,) = cX,r(r) cX,t()
cX,r(r) is called the spatial covariance component
cX,t()is called the temporal covariance component
Exercise:
Consider the following covariance models:
cX(r,) = c0 exp-(3r2/ar2) exp-(3 /at)
cX(r,) = c01 exp-(3r/ar1) exp-(3 /at1) + c02 exp-(3r/ar2) exp-(3 /at2)
Are these models homogeneous/stationary?
Are they space/time separable?
If the covariance is separable, what is the covariance model of the spatial and temporal components?
If covariance is not separable, is it a nested structure of s/t separable covariance models?
19
2.4 Displaying a separable s/t covariance for homogeneous / stationary S/TRF
cX(r,) is a 2D function that can be
displayed as a surface
cX(r,) is a slice of that surface for  .
It shows the spatial component
cX(r,) is a slice of that surface for r .
It shows the temporal component
20
2.5 Estimating a s/t covariance
A useful equation to calculate the covariance of a homogeneous/stationary S/TRF is
cX(r,)= E[X(s,t)X(s’,t’)] ||s-s’||=r , |t-t’|=- mX2
When having site-specific data, and assuming the SRF is homogeneous/stationary, we may
estimate the covariance value for a given spatial lag r and temporal lag using the following
estimator
1
N ( r , )
2
cˆ X ( r , ) 
X
X

m

head
,
i
tail
,
i
X
N (r , ) i 1
where N(r,) is the number of pairs of points with values (Xhead, Xtail) separated by a
distance of r and a time of . In practice we use a tolerance dr and d, i.e. such that
r-dr ≤ ||shead-stail|| ≤ r+dr and -d ≤ ||thead-stail|| ≤ +d
21
2.6 Space/Time covariance estimation in BMElib
Space/time data formats in BMElib
Space/time vector format
When data are collected irregularly in space and time, each data point has a separate space/time
location. An example of this format is when data is collected at different times along a path (e.g.
samples collected on a moving plane or ship).
In this case the data is stored in BMElib in the space/time vector format. Each data point is
specified with its specific spatial location and temporal coordinate.
Space/time grid format
When the data is collected at synchronized times for a set of fixed monitoring station, we can
take advantage of the regularity in the space/time data. An example of this format is for PM10 data
collected every 6 days at set of EPA monitoring station with fixed spatial location.
In this case the data is stored in BMElib in the space/time grid format. In this format the fixed
spatial location of the Monitoring Station (MS) are stored separately from the times at which
samples are collected (the Monitoring Events or ME).
22
Conversion of space/time data formats in BMElib
Conversion between space/time grid and space/time vector formats
stgridsyntax
- Syntaxical help for s/t grid format
valstg2stv
- Converts values from s/t grid coord to s/t vector coord
valstv2stg
- Converts values from s/t vector coord to s/t grid coord
probastv2stg
- Converts probabilistic data from s/t vector coord to s/t grid coord
probastg2stv
- Converts probabilistic data from s/t grid coord to s/t vector coord
A game: where should all these functions be located? (help iolib)
23
help stgridsyntax
stgridsyntax
2001)
For example converting the above s/t grid data to s/t vector format
is done by using the following command :
- Syntaxical help for s/t grid format (Jan 1,
[ch,z]=valstg2stv(Z,cMS,tME);
And the result is as follow in s/t vector format
CONTENT OF HELP FILE:
When the data are collected at a fixed set of nMS Monitoring Sites
with coordinates cMS for nME time events, then one can use the s/t
grid format to store the space/time data. In this case the locations of
the Monitoring Sites are stored in the nMS by 2 vector cMS=[s1MS
s2MS], the time of the nME Monitoring Events are stored in a 1 by
nME vector, and the space/time data is stored in a nMS by nME
matrix Z, as shown in the following example:
cMS=[10 10;
20 20;
30 30];
tME=[100
200
300
400];
Z=
4
5
6
7
8
9
10;
11;
12];
[1
2
3
One can convert the data from s/t grid format to s/t vector format
where each data value is associated with a s/t location. Hence the
values are in a nMS*nME by 1 vector z to which is associated the
locations ch=[s1,s2,t], where s1, s2, and t are nMS*nME by 1
vectors for the s1 spatial coordinates, s2 spatial coordinates, and
time, respectively.
s1
s2
time
z
ch=[10
20
30
10
20
30
10
20
30
10
20
30
10
20
30
10
20
30
10
20
30
10
20
30
100;
100;
100;
200;
200;
200;
300;
300;
300;
400;
400;
400];
z=[1;
2;
3;
4;
5;
6;
7;
8;
9;
10;
11;
12];
Additionally the data can be converted from s/t vector to s/t grid
format as follow
[Z]=valstv2stg(ch,z,cMS,tME);
Note that the commands probastv2stg and probastg2stv do a similar
conversion on probabilistic data.
24
BMElib Covariance estimation using space/time vector data
In BMElib the function used to estimate the s/t covariance of a homogeneous/stationary S/TRF using
data in s/t vector format is crosscovarioST.m
SYNTAX :
[ds,dt,c,o]=crosscovarioST(c1,c2,z1,z2,cls,clt,options);
c1=[- - -;
- - -;
- - -]
c2
z1=[-;
-;
-]
z2
cls
Space/time coordinates of n1 data points. Column 1 and 2 are spatial
x-y coordinates, and colum 3 is time.
for covariance estimation, c2 and c1 are the same
vector of values of data at the c1 space/time coordinates
for covariance estimation, z2 and z1 are the same
ncs+1 by 1 vector giving the limits of the spatial distance classes that are used
for estimating the covariance or cross covariance. The distance classes are open
on the left and closed on the right.
clt
nct+1 by 1 vector giving the limits of the temporal "distance" classes that are
used for estimating the covariance or cross covariance. As for cls, the classes
are open on the left and closed on the right.
BMElib covariance estimation using space/time grid data
18
In BMElib the function used to estimate the s/t covariance of a homogeneous/stationary S/TRF using
data in s/t grid format is stcov.m
SYNTAX :
[C np]=stcov(Zi,cMSi,tMEi,Zj,cMSj,tMEj,rLag,rLagTol,tLag,tLagTol);
INPUT:
cMSi=[- -;
- -;
- -]
tMEi=[- - … ]
Zi
spatial coordinates of nMS monitoring stations
time of nME monitoring events
nMS by nME observed values (may contains NaN for missing values)
For covariance estimation cMSi tMEi and Zi are the same as cMSj tMEj and Zj
rLag=[r1 r2 … ]
rLagTol=[dr1 dr2 … ]
define the spatial lag classes
r1+/-dr1, r2+/-dr2, …
tLag=[t1 t2 … ]
tLagTol=[dt1 dt2 … ]
define the temporal lag classes
t1+/-dt1, t2+/-dt2, …
19
3. The cross-covariance between two Random Fields
3.1 Definitions
Let X(p) and Y(p) are two random fields. The cross-covariance between X at point p and Y
at point p’ is
cXY(p,p’) = E[(X(p)- mX(p))(Y(p’)- mY(p’))] = E[X(p)Y(p’) ]- mX(p).mY(p’)
If X(p) and Y(p) are homogeneous/stationary S/TRF then the covariance is given by
cXY(p,p’) = cXY((s,t), (s’,t’)) = cXY( r=||s-s’|| , =| t- t’|)
3.2 Estimation a cross-covariance
Using site-specific data, for two homogeneous/stationary S/TRFs the cross-covariance is given by
1
N ( r , )
cˆXY (r , ) 
X head ,iYtail,i  mX mY

i 1
N (r , )
where N(r,) is the number of pairs of points with values (Xhead, Ytail) separated by a
distance of r and a time of . In practice we use a tolerance dr and d, i.e. such that
r-dr ≤ ||shead-stail|| ≤ r+dr and -d ≤ ||thead-stail|| ≤ +d
20
3.3 BMElib cross-covariance estimation
The function to estimate the cross-covariance between two homogeneous SRFs is
crosscovario.m
The function used to estimate the s/t cross covariance between two homogeneous/stationary S/TRFs
using data in s/t vector format is crosscovarioST.m
SYNTAX :
[ds,dt,c,o]=crosscovarioST(c1,c2,z1,z2,cls,clt,options);
The inputs are the same as for covariance estimation, except now c1,z1 are for field X and c2,z2
are for field Y.
The function used to estimate the s/t cross covariance between two homogeneous/stationary S/TRFs
using data in s/t grid format is stcov.m
SYNTAX :
[C np]=stcov(Zi,cMSi,tMEi,Zj,cMSj,tMEj,rLag,rLagTol,tLag,tLagTol);
The inputs are the same as for covariance estimation, except now cMSi tMEi and Zi are for
field X and cMSj tMEj and Zj are for field Y.
21
3.4 Review of the BMElib functions for covariance estimation
pairsplot
pairsindex
covario
crosscovario
crosscovarioST
stcov
- display pairs of points separated by a given distance interval
- finds pairs of points separated by a given distance interval
- covariance and cross covariance estimation a set of variables which are
known at the same set of spatial coordinates
- single cross covariance function estimation
- space/time cross covariance estimation for s/t vector data
- space/time cross covariance estimation for s/t grid data
22
Appendix: The covEstimationSTv.m and
covEstimationSTv.g Tutorials
Exploratory analysis and covariance estimation for Space/Time
Random Fields (SRF) X(s,t)
Space/Time Random Field (S/TRF) X(s,t) take values that changes both as a function of
the spatial location s=[x,y] as well as time t.
The hard data (exact measurements) of the S/TRF may typically be available in two type
of format. In the first format which we will call STg (for Space Time grid), there are a set
of nMS monitoring stations at location cMS=[[x1,y1];…], and the measurements occurred at
a set of nME monitoring event (at time tME=[t1,… ] that are the same for all monitoring
stations (hence resulting in nMS*nME measurements). In the second format which we call
STv (for Space Time vector), each location is sampled at a different time, hence in this
case the data is listed as a set of nh measurements corresponding to space/time nh points
ph=[[ x1,y1,t1],…].
The colorplot.m command may be used to provide a color maps showing the hard
data at different time intervals. Hence a sequence of such maps will provide a "movie"
showing the spatiotemporal variation of the data.
When using space/time data in the STv (Space/Time vector) format, the
crosscovarioST.m command may be used to estimate experimental values of the
covariance as a function of spatial lag and temporal lag. The covEstimationSTv.m
command is a tutorial showing how to use this command, and an example is presented in
the following pages. The program covEstimationSTv.m itself is printed at the end
of this appendix.
When using space/time data in the STg (Space/Time grid) format, the stcov.m
command may be used to estimate experimental values of the covariance as a function of
spatial lag and temporal lag. The covEstimationSTg.m command is a tutorial
showing how to use this command, and an example is presented in the following pages
after the example for the STg format. The program covEstimationSTg.m itself is
printed at the end of this appendix.
i
Space/Time Random Field (S/TRF) X(s,t) in STv format with a separable exponential
covariance.
The model selected is
C(r,)=0.6 C0 exp(-3 r/ar) exp(-3 t/at1) + 0.4 C0 exp(-3 r/ar2) exp(-3 t/at2)
where the sill (variance) C0=0.7ppm2, ar1=3 Km, at1 =2 days, ar2=15 Km, at2 =20 days
ii
Space/Time Random Field (S/TRF) X(s,t) in STg format with a separable exponential
covariance.
The model selected is
C(r,)=C0 exp(-3 r/ar) exp(-3 t/at)
where the sill (variance) C0=1.33 ppm2, the spatial range ar =13 Km, and the temporal
range at =11 days.
iii
The covEstimationSTv.m Program
% covEstimationSTv
- covariance estimation tutorial using data in S/T vector format
%%% ESTIMATION OF COVARIANCE USING SPACE/TIME VECTOR DATA
%%% ----------------------------------------------------%%% Read the hard data from file
[val,valname,filetitle]=readGeoEAS('covstv.txt');
ch=val(:,1:3);
zh=val(:,4);
th=ch(:,3);
%%% Open a new graphic window and display the hard
%%% data that were measured between day 0 and day 5,
%%% using circles having a size which is proportional
%%% to value of the hard data.
figure;hold on;
colormap=hot;colormap=colormap(end:-1:1,:);
cax=[min(zh(:)) max(zh(:))];
colorplot(ch(0<=th&th<5,1:2),zh(0<=th&th<5),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for time 0 to 5 days');
%%% Open a new graphic window and display the hard
%%% data that were measured between day 5 and day 10,
%%% using circles having a size which is proportional
%%% to value of the hard data.
figure;hold on;
colorplot(ch(5<=th&th<10,1:2),zh(5<=th&th<10),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for time 5 to 10 days');
%%% Open a new graphic window and display the hard
%%% data that were measured between day 10 and day 15,
%%% using circles having a size which is proportional
%%% to value of the hard data.
iv
figure;hold on;
colorplot(ch(10<=th&th<15,1:2),zh(10<=th&th<15),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for time 10 to 15 days');
%%% Open a new graphic window and display the hard
%%% data that were measured between day 15 and day 20,
%%% using circles having a size which is proportional
%%% to value of the hard data.
figure;hold on;
colorplot(ch(15<=th&th<20,1:2),zh(15<=th&th<20),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for time 15 to 20 days');
%%% Estimate the covariance by using pairs in all
%%% directions.
cls=[0 5 10 20];
clt=[0 6 12 20];
D=coord2dist(ch(:,1:2),ch(:,1:2));
d=D(D>0);
cls=[0 quantest(d,[0.02:0.02:0.04 0.05:0.025:0.10 0.15 0.2:0.1:0.7])];
T=coord2dist(ch(:,3),ch(:,3));
t=T(T>0);
clt=[0 quantest(d,[0.02:0.02:0.04 0.05:0.025:0.10 0.15 0.2:0.1:0.7])];
[ds,dt,c,o]=crosscovarioST(ch,ch,zh,zh,cls,clt);
variance=var(zh);
%%% Plot the estimated covariance on a new graphic
%%% window
figure;
subplot(2,1,1);hold on;
set(gca,'FontSize',12);
hs(1)=plot([0 ds(:,1)'],[variance c(:,1)'],'or:','MarkerSize',10,'MarkerFace','r');
plot([0 15],[0 0],'k-');
ylabel('Covariance C(r,t=0)');
xlabel('spatial lag r (Km)');
title('Covariance');
v
subplot(2,1,2);hold on;
set(gca,'FontSize',12);
ht(1)=plot([0 dt(1,:)],[variance c(1,:)],'or:','MarkerSize',10,'MarkerFace','r');
plot([0 15],[0 0],'k-');
ylabel('Covariance C(r=0,t)');
xlabel('temporal lag t (Day)');
%%% A reasonable model is the following
r=0:.2:15;
covmodel={'exponentialC','exponentialC'};
covparam={[0.6*variance 3],[0.4*variance 15]};
subplot(2,1,1);
Cr_model=modelplot(r,covmodel,covparam);
hs(2)=plot(r,Cr_model,'r','LineWidth',2);
legend(hs,'Experimental Covariance','Covariance Model');
ylabel('Covariance C(r,t=0)');
xlabel('spatial lag r (Km)');
t=0:.2:15;
covmodel={'exponentialC','exponentialC'};
covparam={[0.6*variance 2],[0.4*variance 20]};
subplot(2,1,2);
Ct_model=modelplot(t,covmodel,covparam);
ht(2)=plot(t,Ct_model,'r','LineWidth',2);
legend(ht,'Experimental Covariance','Covariance Model');
ylabel('Covariance C(r=0,t)');
xlabel('temporal lag t (Day)');
vi
The covEstimationSTg.m Program
%%% ESTIMATION OF COVARIANCE USING SPACE/TIME GRID DATA
%%% --------------------------------------------------%%% Read the hard data from file
[val,valname,filetitle]=readGeoEAS('covstg.txt');
cMS=val(:,1:2);
Zh=val(:,3:end);
nME=size(Zh,2);
tME=1:nME;
%%% Open a new graphic window and display the hard
%%% data that were measured on day 1,
%%% using circles having a size which is proportional
%%% to value of the hard data.
figure;hold on;
colormap=hot;colormap=colormap(end:-1:1,:);
cax=[min(Zh(:)) max(Zh(:))];
colorplot(cMS,Zh(:,1),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for day 1');
%%% Open a new graphic window and display the hard
%%% data that were measured on day 2,
%%% using circles having a size which is proportional
%%% to value of the hard data.
figure;hold on;
colorplot(cMS,Zh(:,2),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for day 2');
%%% Open a new graphic window and display the hard
%%% data that were measured on day 3,
%%% using circles having a size which is proportional
%%% to value of the hard data.
vii
figure;hold on;
colorplot(cMS,Zh(:,3),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for day 3');
%%% Open a new graphic window and display the hard
%%% data that were measured on day 4,
%%% using circles having a size which is proportional
%%% to value of the hard data.
figure;hold on;
colorplot(cMS,Zh(:,4),colormap,{'Marker','MarkerSize'},{'o',14});
caxis(cax);
set(gca,'FontSize',14);
colorbar('FontSize',14);
xlabel('x (Km)');ylabel('y (Km)');
title('AgentX (ppm) for day 4');
%%% Estimate the covariance by using pairs in all
%%% directions.
D=coord2dist(cMS,cMS);
d=D(D>0);
cl=[0 quantest(d,[0.01:0.01:0.04 0.05:0.025:0.10 0.15 0.2:0.1:0.7])];
rLag=[0 0.5*(cl(1:end-1)+cl(2:end))];
rLagTol=[0 diff(cl)/2.01];
[Cr npr]=stcov(Zh,cMS,tME,Zh,cMS,tME,rLag,rLagTol,0,0);
tLag= [0:10];
tLagTol=[0 0.01*ones(1,length(tLag)-1)];
[Ct npt]=stcov(Zh,cMS,tME,Zh,cMS,tME,0,0,tLag,tLagTol);
%%% Plot the estimated covariance values on a new graphic
%%% window
figure;
subplot(2,1,1);hold on;
set(gca,'FontSize',12);
hs(1)=plot(rLag,Cr,'or:','MarkerSize',10,'MarkerFace','r');
plot([0 15],[0 0],'k-');
ylabel('Covariance C(r,t=0)');
xlabel('spatial lag r (Km)');
title('Covariance');
viii
subplot(2,1,2);hold on;
set(gca,'FontSize',12);
ht(1)=plot(tLag,Ct,'or:','MarkerSize',10,'MarkerFace','r');
plot([0 15],[0 0],'k-');
ylabel('Covariance C(r=0,t)');
xlabel('temporal lag t (Day)');
%%% A reasonable model is the following
r=0:.2:15;
covmodel='exponentialC';
covparam=[Cr(1) 13];
subplot(2,1,1);
Cr_model=modelplot(r,covmodel,covparam);
hs(2)=plot(r,Cr_model,'r','LineWidth',2);
legend(hs,'Experimental Covariance','Covariance Model');
ylabel('Covariance C(r,t=0)');
xlabel('spatial lag r (Km)');
t=0:.2:15;
covmodel='exponentialC';
covparam=[Cr(1) 11];
subplot(2,1,2);
Ct_model=modelplot(t,covmodel,covparam);
ht(2)=plot(t,Ct_model,'r','LineWidth',2);
legend(ht,'Experimental Covariance','Covariance Model');
ylabel('Covariance C(r=0,t)');
xlabel('temporal lag t (Day)');
ix
Download