[R-sig-Geo] spacetime EOF implementation - interpretation question

Andrew Vitale vitale232 at gmail.com
Wed Oct 29 02:45:11 CET 2014


Edzer,

Thanks a bunch for looking in to this!

Just to double check that everything looked correct, I conducted an EOF
analysis on the same data with the R spacetime package on GitHub
<https://github.com/edzer/spacetime> and with the Python eofs
<http://ajdawson.github.io/eofs/api/eofs.standard.html#eofs.standard.Eof>
package.

Here is a link
<https://plus.google.com/u/0/photos/+AndrewVitale/albums/6075420991607598513/6075420995240106354?pid=6075420995240106354&oid=106112792577057082777>
to an album of figures (if you end up checking out the figures, note that
you can zoom in with the mouse wheel).  I've plotted out the first 4 EOFs
(maps) from R and Python, the entirety of the first four PCs (time series)
from R and Python, and the last 365 days of the PCs time series from both R
and Python.  The spatial and temporal patterns look to be qualitatively
similar, although I haven't had a chance to compare them quantitatively yet.

The only reason I decided to normalize the PCs was to try and make it look
more like some papers/books I've seen.  My uncertainty surrounding the
range of PC values was the biggest reason I came to the list with my
questions.  The "EOF Primer" that I sent in my original message (
http://www.met.reading.ac.uk/~han/Monitor/eofprimer.pdf , pp 11-12, Fig. 2,
3) claims to "standardi[ze the PCs] to have zero mean and unit variance",
and the Python eofs module includes the option of returning scaled PC and
EOF values with two different methods.  It seems that the biggest source of
confusion throughout the process of this analysis has been varying
terminology and slightly different methods all thrown under the EOF blanket.

Thanks again for looking in to this and making such a speedy correction to
the source code.  You've helped tremendously.

-Andrew

On Mon, Oct 27, 2014 at 11:32 AM, Edzer Pebesma <
edzer.pebesma at uni-muenster.de> wrote:

> Thanks for bringing this up, Andrew, for the note, and for the example.
> I looked into the note, into Wilks, and into Cressie & Wikle, which I
> tried to follow when I wrote EOF.
>
> I decided to deprecate spacetime::EOF. It computes principle component
> scores from the m x p space-time matrix or its transpose, which might be
> useful to some, but what it does is too far from the EOF literature to
> be helpful. In particular, it confused "spatial" and "temporal" modes,
> as C & W use these terms.
>
> I added a new function, spacetime::eof, which should do what the
> literature describes as EOF: return the eigenvector coefficients of the
> rotation matrix. Argument returnEOFs = FALSE gives back the prcomp
> object, feeding that to predict() gives the scores.
>
> Reproducing the figures in C & W Ch 5 looks now better, up to expected
> sign changes, but the numerical ranges are still different.
>
> Please reinstall spacetime from github, use eof, and see if things now
> work as expected. demo(CressieWikle) is now updated as well.
>
> In your example below, you normalize by
>
> > PCs = apply(seof$rotation, 2, function(x) (x - mean(x)) / sd(x))
>
> but why? Eigenvectors are already standardized, but to unit length; is
> this another convention of the EOF world?
>
> With best regards,
>
> On 10/24/2014 12:04 AM, Andrew Vitale wrote:
> > Hello,
> >
> > I'm performing an empirical orthogonal function analysis on sea level
> > pressure using the spacetime package, and I'm having trouble determining
> > which elements of the function output I should use to interpret the
> results.
> >
> > It seems that most examples in the literature calculate empirical
> > orthogonal functions (EOFs) and their associated principle component (PC)
> > time series (e.g.
> http://www.met.reading.ac.uk/~han/Monitor/eofprimer.pdf ,
> > pp 11-12, Fig. 2, 3).  As far as I can tell, I should be able to extract
> > all of the relevant information using only the spatial mode in the
> > spacetime:::EOF function.  However, the ambiguous terminology in the
> > literature and the availability of the "temporal" mode in spacetime:::EOF
> > have me uncertain of my interpretation.
> >
> > I have been treating the output of spacetime:::EOF with
> > returnPredictions=TRUE as the EOFs, and I have been treating the
> > spacetime:::EOF $rotation element with returnPredictions=FALSE as the
> PCs.
> >
> > Am I extracting the proper information from the spacetime:::EOF results?
> > Are the results of the spatial and temporal modes of spacetime:::EOF both
> > required to perform an EOF analysis of a sea level pressure field, or are
> > these two separate analyses?
> >
> > Below is a small example of how I am currently extracting the spatial
> EOFs
> > and their associated PCs.
> >
> > Thanks for any comments,
> > Andrew Vitale
> >
> >
> > library(raster)
> > library(spacetime)
> >
> > ## Create a raster object that mimics my data
> > ## which is actually a raster stack of 20,718
> > ## daily sea level pressure anomolies
> > a = array(rnorm(9*9*100), c(9,9,100))
> > b = brick(a)
> > b = setValues(b, a)
> > z = seq(as.Date('1980-01-01'), as.Date('1980-04-09'),
> >         by = 'day')
> > b = setZ(b, z)
> >
> > ## coerce the raster stack to an STFDF object
> > st = as(b, 'STFDF')
> >
> > ## calculate EOFs in spatial mode using spacetime
> > seof = EOF(st, how='spatial', returnPredictions=FALSE, scale.=TRUE)
> > seof_preds = EOF(st, how='spatial', returnPredictions=TRUE, scale.=TRUE)
> >
> > ## Create a raster stack of the predictions, which seem to be
> > ## generally referred to as EOFs in the literature
> > EOFs = stack(seof_preds)
> > ## extract and standardize the rotation element of the
> > ## seof object, which seems to be the eigenvectors, which seem
> > ## to also be referred to as PCs in the literature
> > PCs = apply(seof$rotation, 2, function(x) (x - mean(x)) / sd(x))
> >
> > ## Plot the EOFs as maps (seof_preds)
> > plot(EOFs)
> >
> > ## Plot the first PC (seof$rotation [standardized])
> > x11(height=7, width=10)
> > plot(x=as.Date(row.names(PCs), format='X%Y.%m.%d'),
> >      y=PCs[ , 1], type='l', xlab='Date', ylab='Standardized PC1')
> >
> >
>
> --
> Edzer Pebesma,  Co-Editor-in-Chief Computers & Geosciences
> Institute for Geoinformatics (ifgi), University of Münster
> Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
> 83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>


-- 
*Andrew P. Vitale*
Masters Student
Department of Geography
University of Nevada, Reno
vitale232 at gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list