I have spatial data on a sphere (the Earth) for which I would like to run an gls model assuming that the errors are autcorrelated, i.e. including a corSpatial correlation in the model specification. In this case the distance metric should be calculated on the sphere, therefore metric = "euclidean" in (for example) corSpher would be incorrect. I would be grateful for help on how to write a new distance metric for the corSpatial function. I believe there are several ways that distances on a sphere can be calculated in R, for example the "distMeeus" function in the geosphere library. However, I have no idea how to write this into a corSpatial function. The aim is to end up with a metric = "sphere" option that calculates great circle distances between points using latitude and longitude. Many thanks, Dan
nlme: spatial autocorrelation on a sphere
5 messages · Dan Bebber, Spencer Graves, David Winsemius
On Sep 30, 2012, at 6:48 PM, Dan Bebber wrote:
I have spatial data on a sphere (the Earth) for which I would like to run an gls model assuming that the errors are autcorrelated, i.e. including a corSpatial correlation in the model specification. In this case the distance metric should be calculated on the sphere, therefore metric = "euclidean" in (for example) corSpher would be incorrect. I would be grateful for help on how to write a new distance metric for the corSpatial function. I believe there are several ways that distances on a sphere can be calculated in R, for example the "distMeeus" function in the geosphere library. However, I have no idea how to write this into a corSpatial function. The aim is to end up with a metric = "sphere" option that calculates great circle distances between points using latitude and longitude.
LMCTVTFY: http://cran.r-project.org/web/views/Spatial.html
David Winsemius, MD Alameda, CA, USA
Thanks, but the problem is quite specific and not addressed on the Spatial Data taskview page. Quite specifically, I would like to know how to edit corSpatial functions to calculate great circle distances. The Bayesian equivalent, georamps in the ramps package, is able to do this, therefore I imagine it must be possible for nlme. Dan
From: David Winsemius [dwinsemius at comcast.net]
Sent: 01 October 2012 08:38
To: Dan Bebber
Cc: r-help at r-project.org
Subject: Re: [R] nlme: spatial autocorrelation on a sphere
Sent: 01 October 2012 08:38
To: Dan Bebber
Cc: r-help at r-project.org
Subject: Re: [R] nlme: spatial autocorrelation on a sphere
On Sep 30, 2012, at 6:48 PM, Dan Bebber wrote: > I have spatial data on a sphere (the Earth) for which I would like to run an gls model assuming that the errors are autcorrelated, i.e. including a corSpatial correlation in the model specification. > > In this case the distance metric should be calculated on the sphere, therefore metric = "euclidean" in (for example) corSpher would be incorrect. > > I would be grateful for help on how to write a new distance metric for the corSpatial function. > I believe there are several ways that distances on a sphere can be calculated in R, for example the "distMeeus" function in the geosphere library. However, I have no idea how to write this into a corSpatial function. > > The aim is to end up with a metric = "sphere" option that calculates great circle distances between points using latitude and longitude. LMCTVTFY: http://cran.r-project.org/web/views/Spatial.html -- David Winsemius, MD Alameda, CA, USA
1. Have you consulted Pinheiro and Bates (2000) Mixed-Effects
Modeling in S and S-Plus (Springer)? It does not has much information
on the cor* constructor functions, but it does have some. "corExp" is
discussed on p. 238, and information on other cor* functions should be
in pages near 238.
2. Have you tried subscribing and posting to
"r-sig-mixed-models at r-project.org"? That email list is devoted
primarily to "lmer", the replacement for nlme. However, with luck, you
will get an answer there, including, (a) whether what you want is
available for "lmer", and (b) how to use it either with lmer or nlme.
Best Wishes,
Spencer
On 10/1/2012 12:59 AM, Dan Bebber wrote:
Thanks, but the problem is quite specific and not addressed on the Spatial Data taskview page. Quite specifically, I would like to know how to edit corSpatial functions to calculate great circle distances. The Bayesian equivalent, georamps in the ramps package, is able to do this, therefore I imagine it must be possible for nlme. Dan
________________________________________ From: David Winsemius [dwinsemius at comcast.net] Sent: 01 October 2012 08:38 To: Dan Bebber Cc: r-help at r-project.org Subject: Re: [R] nlme: spatial autocorrelation on a sphere On Sep 30, 2012, at 6:48 PM, Dan Bebber wrote: I have spatial data on a sphere (the Earth) for which I would like to run an gls model assuming that the errors are autcorrelated, i.e. including a corSpatial correlation in the model specification. In this case the distance metric should be calculated on the sphere, therefore metric = "euclidean" in (for example) corSpher would be incorrect. I would be grateful for help on how to write a new distance metric for the corSpatial function. I believe there are several ways that distances on a sphere can be calculated in R, for example the "distMeeus" function in the geosphere library. However, I have no idea how to write this into a corSpatial function. The aim is to end up with a metric = "sphere" option that calculates great circle distances between points using latitude and longitude. LMCTVTFY: http://cran.r-project.org/web/views/Spatial.html -- David Winsemius, MD Alameda, CA, USA ______________________________________________ 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.
-- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San Jos?, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com
Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San Jos?, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com
On Oct 1, 2012, at 12:59 AM, Dan Bebber wrote:
Thanks, but the problem is quite specific and not addressed on the Spatial Data taskview page. Quite specifically, I would like to know how to edit corSpatial functions to calculate great circle distances. The Bayesian equivalent, georamps in the ramps package, is able to do this, therefore I imagine it must be possible for nlme.
Can't you use the corStruct functions in pkg::ramps? They allow specification of the 'haversine' metric. The corR* functions inherit from class corStruct.
David. > Dan > ________________________________________ > From: David Winsemius [dwinsemius at comcast.net] > Sent: 01 October 2012 08:38 > To: Dan Bebber > Cc: r-help at r-project.org > Subject: Re: [R] nlme: spatial autocorrelation on a sphere > > On Sep 30, 2012, at 6:48 PM, Dan Bebber wrote: > >> I have spatial data on a sphere (the Earth) for which I would like to run an gls model assuming that the errors are autcorrelated, i.e. including a corSpatial correlation in the model specification. >> >> In this case the distance metric should be calculated on the sphere, therefore metric = "euclidean" in (for example) corSpher would be incorrect. >> >> I would be grateful for help on how to write a new distance metric for the corSpatial function. >> I believe there are several ways that distances on a sphere can be calculated in R, for example the "distMeeus" function in the geosphere library. However, I have no idea how to write this into a corSpatial function. >> >> The aim is to end up with a metric = "sphere" option that calculates great circle distances between points using latitude and longitude. > > LMCTVTFY: http://cran.r-project.org/web/views/Spatial.html > > -- > > David Winsemius, MD > Alameda, CA, USA > > David Winsemius, MD Alameda, CA, USA