This is an

**for**__archive__**R-sig-geo**, not a forum. It is not possible to post through Nabble - you may not start a new thread nor follow up an existing thread. If you wish to post, but are not subscribed to the list through the list homepage, subscribe first**(through the list homepage, not via Nabble)**and post from your subscribed email address. Until 2015-06-20, subscribers could post through Nabble, but policy has been changed as too many non-subscribers misunderstood the interface.*Updated:*27 min 34 sec ago

### Re: R squared in lagsarlm

Do not post HTML-mail!

What do you mean by: "what parameters of SAR we should expose"? What do

you mean by SAR? Do you mean the SAR model (simultaneous autoregressive

model, a.k.a. the simultaneous spatial error model) or the SAR model

(spatial autoregressive model a.k.a. the simultaneous spatial lag model)?

If the spatial lag model, only ever report impacts, never report the

betas. Please be more precise.

Roger

On Thu, 21 Mar 2019, Leonardo Matheus Servino wrote:

> Thanks, and one more question: what parameters of SAR we should expose in

> articles?

>

> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

> Livre

> de vírus. www.avast.com

> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.

> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

>

> Em qui, 21 de mar de 2019 às 10:09, Roger Bivand <[hidden email]>

> escreveu:

>

>> The Nagelkerke measure is optionally provided in the summary method:

>> Nagelkerke NJD (1991) A note on a general definition of the coefficient of

>> determination. Biometrika 78: 691-692.

>>

>> See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or

>> ?summary.sarlm.

>>

>> There is no "R squared" for these models, the likelihood ratio is a better

>> comparative measure.

>>

>> Roger

>>

>> On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

>>

>>> Hello,

>>>

>>> I would like to know where I can find the Rsquared value in lagsarlm

>>>

>>> Thanks

>>>

>>>

>>

>> --

>> Roger Bivand

>> Department of Economics, Norwegian School of Economics,

>> Helleveien 30, N-5045 Bergen, Norway.

>> voice: +47 55 95 93 55; e-mail: [hidden email]

>> https://orcid.org/0000-0003-2392-6140

>> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>>

>

>

> --

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

What do you mean by: "what parameters of SAR we should expose"? What do

you mean by SAR? Do you mean the SAR model (simultaneous autoregressive

model, a.k.a. the simultaneous spatial error model) or the SAR model

(spatial autoregressive model a.k.a. the simultaneous spatial lag model)?

If the spatial lag model, only ever report impacts, never report the

betas. Please be more precise.

Roger

On Thu, 21 Mar 2019, Leonardo Matheus Servino wrote:

> Thanks, and one more question: what parameters of SAR we should expose in

> articles?

>

> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

> Livre

> de vírus. www.avast.com

> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.

> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

>

> Em qui, 21 de mar de 2019 às 10:09, Roger Bivand <[hidden email]>

> escreveu:

>

>> The Nagelkerke measure is optionally provided in the summary method:

>> Nagelkerke NJD (1991) A note on a general definition of the coefficient of

>> determination. Biometrika 78: 691-692.

>>

>> See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or

>> ?summary.sarlm.

>>

>> There is no "R squared" for these models, the likelihood ratio is a better

>> comparative measure.

>>

>> Roger

>>

>> On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

>>

>>> Hello,

>>>

>>> I would like to know where I can find the Rsquared value in lagsarlm

>>>

>>> Thanks

>>>

>>>

>>

>> --

>> Roger Bivand

>> Department of Economics, Norwegian School of Economics,

>> Helleveien 30, N-5045 Bergen, Norway.

>> voice: +47 55 95 93 55; e-mail: [hidden email]

>> https://orcid.org/0000-0003-2392-6140

>> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>>

>

>

> --

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

### Re: R squared in lagsarlm

Thanks, and one more question: what parameters of SAR we should expose in

articles?

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Livre

de vírus. www.avast.com

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Em qui, 21 de mar de 2019 às 10:09, Roger Bivand <[hidden email]>

escreveu:

> The Nagelkerke measure is optionally provided in the summary method:

> Nagelkerke NJD (1991) A note on a general definition of the coefficient of

> determination. Biometrika 78: 691-692.

>

> See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or

> ?summary.sarlm.

>

> There is no "R squared" for these models, the likelihood ratio is a better

> comparative measure.

>

> Roger

>

> On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

>

> > Hello,

> >

> > I would like to know where I can find the Rsquared value in lagsarlm

> >

> > Thanks

> >

> >

>

> --

> Roger Bivand

> Department of Economics, Norwegian School of Economics,

> Helleveien 30, N-5045 Bergen, Norway.

> voice: +47 55 95 93 55; e-mail: [hidden email]

> https://orcid.org/0000-0003-2392-6140

> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>

--

Leonardo Matheus Servino

Pós-Graduação em Evolução e Diversidade

Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares

09606-070 São Bernardo do Campo - SP

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

articles?

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Livre

de vírus. www.avast.com

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Em qui, 21 de mar de 2019 às 10:09, Roger Bivand <[hidden email]>

escreveu:

> The Nagelkerke measure is optionally provided in the summary method:

> Nagelkerke NJD (1991) A note on a general definition of the coefficient of

> determination. Biometrika 78: 691-692.

>

> See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or

> ?summary.sarlm.

>

> There is no "R squared" for these models, the likelihood ratio is a better

> comparative measure.

>

> Roger

>

> On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

>

> > Hello,

> >

> > I would like to know where I can find the Rsquared value in lagsarlm

> >

> > Thanks

> >

> >

>

> --

> Roger Bivand

> Department of Economics, Norwegian School of Economics,

> Helleveien 30, N-5045 Bergen, Norway.

> voice: +47 55 95 93 55; e-mail: [hidden email]

> https://orcid.org/0000-0003-2392-6140

> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>

--

Leonardo Matheus Servino

Pós-Graduação em Evolução e Diversidade

Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares

09606-070 São Bernardo do Campo - SP

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: R squared in lagsarlm

The Nagelkerke measure is optionally provided in the summary method:

Nagelkerke NJD (1991) A note on a general definition of the coefficient of

determination. Biometrika 78: 691-692.

See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or

?summary.sarlm.

There is no "R squared" for these models, the likelihood ratio is a better

comparative measure.

Roger

On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

> Hello,

>

> I would like to know where I can find the Rsquared value in lagsarlm

>

> Thanks

>

>

--

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

Nagelkerke NJD (1991) A note on a general definition of the coefficient of

determination. Biometrika 78: 691-692.

See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or

?summary.sarlm.

There is no "R squared" for these models, the likelihood ratio is a better

comparative measure.

Roger

On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

> Hello,

>

> I would like to know where I can find the Rsquared value in lagsarlm

>

> Thanks

>

>

--

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

### Unsubscribe from your list

Dear Mr/Madam,

Please unsubscribe from your list.

Thank you in advance

Kind Regards

Nina Philipova

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Please unsubscribe from your list.

Thank you in advance

Kind Regards

Nina Philipova

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### R squared in lagsarlm

Hello,

I would like to know where I can find the Rsquared value in lagsarlm

Thanks

--

Leonardo Matheus Servino

Pós-Graduação em Evolução e Diversidade

Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares

09606-070 São Bernardo do Campo - SP

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

I would like to know where I can find the Rsquared value in lagsarlm

Thanks

--

Leonardo Matheus Servino

Pós-Graduação em Evolução e Diversidade

Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares

09606-070 São Bernardo do Campo - SP

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Reverse y-axis with geom_sf

>

> Date: Tue, 19 Mar 2019 15:13:37 +0100

> From: Edzer Pebesma <[hidden email]>

> To: [hidden email]

> Subject: Re: [R-sig-Geo] Reverse y-axis with geom_sf

> Message-ID: <[hidden email]>

> Content-Type: text/plain; charset="utf-8"

>

>

> On 3/19/19 2:55 PM, Kent Johnson wrote:

>

> > Is there a way to invert the y axis while staying within sf (or possibly

> > sp?) The only answers I have found involve extracting the coordinates

> from

> > the sf objects and inverting or plotting from the raw data. Maybe by

> > creating a CRS with the correct orientation?

> >

> > For a very simple example with just a few vectors - the code below plots

> an

> > arrow pointing down; I would like to invert the y-axis so it points up.

> > library(sf)

> > library(ggplot2)

> > s1 <- rbind(c(9, 11), c(10, 10))

> > s2 <- rbind(c(11, 11), c(10, 10))

> > s3 <- rbind(c(10,14), c(10, 12), c(10,10))

> > mls <- st_multilinestring(list(s1,s2,s3))

> >

> > ggplot(mls) + geom_sf()

>

> You mean, like

>

> ggplot(mls * c(1, -1)) + geom_sf()

>

> ?

>

Yes, that might work well, with the addition of a correction to the axis

labels:

ggplot(mls * c(1, -1)) + geom_sf() +

scale_y_continuous(labels=function(x) -x)

I have a raster background that will need some adjustment too, that should

be manageable.

Thanks!

Kent

Date: Tue, 19 Mar 2019 19:11:03 +0000

> From: =?UTF-8?B?SmVzw7pz?= <[hidden email]>

> To: Kent Johnson <[hidden email]>

> Cc: [hidden email]

> Subject: Re: [R-sig-Geo] Reverse y-axis with geom_sf

> Message-ID:

> <

> [hidden email]>

> Content-Type: text/plain; charset="utf-8"

>

> You are welcome

>

> You could try converting sf to sp and use the corresponding geoms

> (geom_polygon, geom_point..etc.) plus coord_flip() or map the x and y

> aesthetics accordingly.

>

That, or just pulling the raw data out and plotting it directly, is kind of

a last resort. I would rather not have to do this level of data munging as

my actual data is moderately complex.

Thanks,

Kent

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> Date: Tue, 19 Mar 2019 15:13:37 +0100

> From: Edzer Pebesma <[hidden email]>

> To: [hidden email]

> Subject: Re: [R-sig-Geo] Reverse y-axis with geom_sf

> Message-ID: <[hidden email]>

> Content-Type: text/plain; charset="utf-8"

>

>

> On 3/19/19 2:55 PM, Kent Johnson wrote:

>

> > Is there a way to invert the y axis while staying within sf (or possibly

> > sp?) The only answers I have found involve extracting the coordinates

> from

> > the sf objects and inverting or plotting from the raw data. Maybe by

> > creating a CRS with the correct orientation?

> >

> > For a very simple example with just a few vectors - the code below plots

> an

> > arrow pointing down; I would like to invert the y-axis so it points up.

> > library(sf)

> > library(ggplot2)

> > s1 <- rbind(c(9, 11), c(10, 10))

> > s2 <- rbind(c(11, 11), c(10, 10))

> > s3 <- rbind(c(10,14), c(10, 12), c(10,10))

> > mls <- st_multilinestring(list(s1,s2,s3))

> >

> > ggplot(mls) + geom_sf()

>

> You mean, like

>

> ggplot(mls * c(1, -1)) + geom_sf()

>

> ?

>

Yes, that might work well, with the addition of a correction to the axis

labels:

ggplot(mls * c(1, -1)) + geom_sf() +

scale_y_continuous(labels=function(x) -x)

I have a raster background that will need some adjustment too, that should

be manageable.

Thanks!

Kent

Date: Tue, 19 Mar 2019 19:11:03 +0000

> From: =?UTF-8?B?SmVzw7pz?= <[hidden email]>

> To: Kent Johnson <[hidden email]>

> Cc: [hidden email]

> Subject: Re: [R-sig-Geo] Reverse y-axis with geom_sf

> Message-ID:

> <

> [hidden email]>

> Content-Type: text/plain; charset="utf-8"

>

> You are welcome

>

> You could try converting sf to sp and use the corresponding geoms

> (geom_polygon, geom_point..etc.) plus coord_flip() or map the x and y

> aesthetics accordingly.

>

That, or just pulling the raw data out and plotting it directly, is kind of

a last resort. I would rather not have to do this level of data munging as

my actual data is moderately complex.

Thanks,

Kent

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Reverse y-axis with geom_sf

You are welcome

You could try converting sf to sp and use the corresponding geoms

(geom_polygon, geom_point..etc.) plus coord_flip() or map the x and y

aesthetics accordingly.

El mar., 19 mar. 2019 a las 18:55, Kent Johnson (<[hidden email]>)

escribió:

> On Tue, Mar 19, 2019 at 1:54 PM Jesús <[hidden email]> wrote:

>

>> Hi Kent

>> Did you try using the coord_flip function from ggplot?

>> Cheers

>> Jesús

>>

>

> Yes, I did, coord_flip() doesn't work with geom_sf():

>

> > ggplot(mls) + geom_sf() + coord_flip()

> Error: geom_sf() must be used with coord_sf()

>

> Thanks for the suggestion!

> Kent

>

>>

>> El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)

>> escribió:

>>

>>> Hi,

>>>

>>> I am working with data representing cells in a tissue sample with lines

>>> and

>>> polygonal regions defined in the same space. The cells and polygons are

>>> represented and manipulated as simple features objects and visualized

>>> using

>>> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

>>> coordinate system of my data has the origin at the top left corner. For

>>> data with no CRS, geom_sf puts the origin at the bottom left so all my

>>> plots are inverted.

>>>

>>> Is there a way to invert the y axis while staying within sf (or possibly

>>> sp?) The only answers I have found involve extracting the coordinates

>>> from

>>> the sf objects and inverting or plotting from the raw data. Maybe by

>>> creating a CRS with the correct orientation?

>>>

>>> For a very simple example with just a few vectors - the code below plots

>>> an

>>> arrow pointing down; I would like to invert the y-axis so it points up.

>>> library(sf)

>>> library(ggplot2)

>>> s1 <- rbind(c(9, 11), c(10, 10))

>>> s2 <- rbind(c(11, 11), c(10, 10))

>>> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

>>> mls <- st_multilinestring(list(s1,s2,s3))

>>>

>>> ggplot(mls) + geom_sf()

>>>

>>> Thank you for any help,

>>> Kent Johnson

>>>

>>> [[alternative HTML version deleted]]

>>>

>>> _______________________________________________

>>> R-sig-Geo mailing list

>>> [hidden email]

>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>>

>>

>>

>> --

>> Jesús

>>

>

--

Jesús

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

You could try converting sf to sp and use the corresponding geoms

(geom_polygon, geom_point..etc.) plus coord_flip() or map the x and y

aesthetics accordingly.

El mar., 19 mar. 2019 a las 18:55, Kent Johnson (<[hidden email]>)

escribió:

> On Tue, Mar 19, 2019 at 1:54 PM Jesús <[hidden email]> wrote:

>

>> Hi Kent

>> Did you try using the coord_flip function from ggplot?

>> Cheers

>> Jesús

>>

>

> Yes, I did, coord_flip() doesn't work with geom_sf():

>

> > ggplot(mls) + geom_sf() + coord_flip()

> Error: geom_sf() must be used with coord_sf()

>

> Thanks for the suggestion!

> Kent

>

>>

>> El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)

>> escribió:

>>

>>> Hi,

>>>

>>> I am working with data representing cells in a tissue sample with lines

>>> and

>>> polygonal regions defined in the same space. The cells and polygons are

>>> represented and manipulated as simple features objects and visualized

>>> using

>>> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

>>> coordinate system of my data has the origin at the top left corner. For

>>> data with no CRS, geom_sf puts the origin at the bottom left so all my

>>> plots are inverted.

>>>

>>> Is there a way to invert the y axis while staying within sf (or possibly

>>> sp?) The only answers I have found involve extracting the coordinates

>>> from

>>> the sf objects and inverting or plotting from the raw data. Maybe by

>>> creating a CRS with the correct orientation?

>>>

>>> For a very simple example with just a few vectors - the code below plots

>>> an

>>> arrow pointing down; I would like to invert the y-axis so it points up.

>>> library(sf)

>>> library(ggplot2)

>>> s1 <- rbind(c(9, 11), c(10, 10))

>>> s2 <- rbind(c(11, 11), c(10, 10))

>>> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

>>> mls <- st_multilinestring(list(s1,s2,s3))

>>>

>>> ggplot(mls) + geom_sf()

>>>

>>> Thank you for any help,

>>> Kent Johnson

>>>

>>> [[alternative HTML version deleted]]

>>>

>>> _______________________________________________

>>> R-sig-Geo mailing list

>>> [hidden email]

>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>>

>>

>>

>> --

>> Jesús

>>

>

--

Jesús

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Reverse y-axis with geom_sf

On Tue, Mar 19, 2019 at 1:54 PM Jesús <[hidden email]> wrote:

> Hi Kent

> Did you try using the coord_flip function from ggplot?

> Cheers

> Jesús

>

Yes, I did, coord_flip() doesn't work with geom_sf():

> ggplot(mls) + geom_sf() + coord_flip()

Error: geom_sf() must be used with coord_sf()

Thanks for the suggestion!

Kent

>

> El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)

> escribió:

>

>> Hi,

>>

>> I am working with data representing cells in a tissue sample with lines

>> and

>> polygonal regions defined in the same space. The cells and polygons are

>> represented and manipulated as simple features objects and visualized

>> using

>> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

>> coordinate system of my data has the origin at the top left corner. For

>> data with no CRS, geom_sf puts the origin at the bottom left so all my

>> plots are inverted.

>>

>> Is there a way to invert the y axis while staying within sf (or possibly

>> sp?) The only answers I have found involve extracting the coordinates from

>> the sf objects and inverting or plotting from the raw data. Maybe by

>> creating a CRS with the correct orientation?

>>

>> For a very simple example with just a few vectors - the code below plots

>> an

>> arrow pointing down; I would like to invert the y-axis so it points up.

>> library(sf)

>> library(ggplot2)

>> s1 <- rbind(c(9, 11), c(10, 10))

>> s2 <- rbind(c(11, 11), c(10, 10))

>> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

>> mls <- st_multilinestring(list(s1,s2,s3))

>>

>> ggplot(mls) + geom_sf()

>>

>> Thank you for any help,

>> Kent Johnson

>>

>> [[alternative HTML version deleted]]

>>

>> _______________________________________________

>> R-sig-Geo mailing list

>> [hidden email]

>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>

>

>

> --

> Jesús

>

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> Hi Kent

> Did you try using the coord_flip function from ggplot?

> Cheers

> Jesús

>

Yes, I did, coord_flip() doesn't work with geom_sf():

> ggplot(mls) + geom_sf() + coord_flip()

Error: geom_sf() must be used with coord_sf()

Thanks for the suggestion!

Kent

>

> El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)

> escribió:

>

>> Hi,

>>

>> I am working with data representing cells in a tissue sample with lines

>> and

>> polygonal regions defined in the same space. The cells and polygons are

>> represented and manipulated as simple features objects and visualized

>> using

>> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

>> coordinate system of my data has the origin at the top left corner. For

>> data with no CRS, geom_sf puts the origin at the bottom left so all my

>> plots are inverted.

>>

>> Is there a way to invert the y axis while staying within sf (or possibly

>> sp?) The only answers I have found involve extracting the coordinates from

>> the sf objects and inverting or plotting from the raw data. Maybe by

>> creating a CRS with the correct orientation?

>>

>> For a very simple example with just a few vectors - the code below plots

>> an

>> arrow pointing down; I would like to invert the y-axis so it points up.

>> library(sf)

>> library(ggplot2)

>> s1 <- rbind(c(9, 11), c(10, 10))

>> s2 <- rbind(c(11, 11), c(10, 10))

>> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

>> mls <- st_multilinestring(list(s1,s2,s3))

>>

>> ggplot(mls) + geom_sf()

>>

>> Thank you for any help,

>> Kent Johnson

>>

>> [[alternative HTML version deleted]]

>>

>> _______________________________________________

>> R-sig-Geo mailing list

>> [hidden email]

>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>

>

>

> --

> Jesús

>

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Reverse y-axis with geom_sf

Hi Kent

Did you try using the coord_flip function from ggplot?

Cheers

Jesús

El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)

escribió:

> Hi,

>

> I am working with data representing cells in a tissue sample with lines and

> polygonal regions defined in the same space. The cells and polygons are

> represented and manipulated as simple features objects and visualized using

> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

> coordinate system of my data has the origin at the top left corner. For

> data with no CRS, geom_sf puts the origin at the bottom left so all my

> plots are inverted.

>

> Is there a way to invert the y axis while staying within sf (or possibly

> sp?) The only answers I have found involve extracting the coordinates from

> the sf objects and inverting or plotting from the raw data. Maybe by

> creating a CRS with the correct orientation?

>

> For a very simple example with just a few vectors - the code below plots an

> arrow pointing down; I would like to invert the y-axis so it points up.

> library(sf)

> library(ggplot2)

> s1 <- rbind(c(9, 11), c(10, 10))

> s2 <- rbind(c(11, 11), c(10, 10))

> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

> mls <- st_multilinestring(list(s1,s2,s3))

>

> ggplot(mls) + geom_sf()

>

> Thank you for any help,

> Kent Johnson

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>

--

Jesús

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Did you try using the coord_flip function from ggplot?

Cheers

Jesús

El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)

escribió:

> Hi,

>

> I am working with data representing cells in a tissue sample with lines and

> polygonal regions defined in the same space. The cells and polygons are

> represented and manipulated as simple features objects and visualized using

> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

> coordinate system of my data has the origin at the top left corner. For

> data with no CRS, geom_sf puts the origin at the bottom left so all my

> plots are inverted.

>

> Is there a way to invert the y axis while staying within sf (or possibly

> sp?) The only answers I have found involve extracting the coordinates from

> the sf objects and inverting or plotting from the raw data. Maybe by

> creating a CRS with the correct orientation?

>

> For a very simple example with just a few vectors - the code below plots an

> arrow pointing down; I would like to invert the y-axis so it points up.

> library(sf)

> library(ggplot2)

> s1 <- rbind(c(9, 11), c(10, 10))

> s2 <- rbind(c(11, 11), c(10, 10))

> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

> mls <- st_multilinestring(list(s1,s2,s3))

>

> ggplot(mls) + geom_sf()

>

> Thank you for any help,

> Kent Johnson

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>

--

Jesús

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Reverse y-axis with geom_sf

On 3/19/19 2:55 PM, Kent Johnson wrote:

> Hi,

>

> I am working with data representing cells in a tissue sample with lines and

> polygonal regions defined in the same space. The cells and polygons are

> represented and manipulated as simple features objects and visualized using

> ggplot2 and geom_sf. Mostly this works very well. The problem is that the

> coordinate system of my data has the origin at the top left corner. For

> data with no CRS, geom_sf puts the origin at the bottom left so all my

> plots are inverted.

>

> Is there a way to invert the y axis while staying within sf (or possibly

> sp?) The only answers I have found involve extracting the coordinates from

> the sf objects and inverting or plotting from the raw data. Maybe by

> creating a CRS with the correct orientation?

>

> For a very simple example with just a few vectors - the code below plots an

> arrow pointing down; I would like to invert the y-axis so it points up.

> library(sf)

> library(ggplot2)

> s1 <- rbind(c(9, 11), c(10, 10))

> s2 <- rbind(c(11, 11), c(10, 10))

> s3 <- rbind(c(10,14), c(10, 12), c(10,10))

> mls <- st_multilinestring(list(s1,s2,s3))

>

> ggplot(mls) + geom_sf() You mean, like

ggplot(mls * c(1, -1)) + geom_sf()

?

>

> Thank you for any help,

> Kent Johnson

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> --

Edzer Pebesma

Institute for Geoinformatics

Heisenbergstrasse 2, 48151 Muenster, Germany

Phone: +49 251 8333081

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

**pEpkey.asc**(2K) Download Attachment

### Reverse y-axis with geom_sf

Hi,

I am working with data representing cells in a tissue sample with lines and

polygonal regions defined in the same space. The cells and polygons are

represented and manipulated as simple features objects and visualized using

ggplot2 and geom_sf. Mostly this works very well. The problem is that the

coordinate system of my data has the origin at the top left corner. For

data with no CRS, geom_sf puts the origin at the bottom left so all my

plots are inverted.

Is there a way to invert the y axis while staying within sf (or possibly

sp?) The only answers I have found involve extracting the coordinates from

the sf objects and inverting or plotting from the raw data. Maybe by

creating a CRS with the correct orientation?

For a very simple example with just a few vectors - the code below plots an

arrow pointing down; I would like to invert the y-axis so it points up.

library(sf)

library(ggplot2)

s1 <- rbind(c(9, 11), c(10, 10))

s2 <- rbind(c(11, 11), c(10, 10))

s3 <- rbind(c(10,14), c(10, 12), c(10,10))

mls <- st_multilinestring(list(s1,s2,s3))

ggplot(mls) + geom_sf()

Thank you for any help,

Kent Johnson

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

I am working with data representing cells in a tissue sample with lines and

polygonal regions defined in the same space. The cells and polygons are

represented and manipulated as simple features objects and visualized using

ggplot2 and geom_sf. Mostly this works very well. The problem is that the

coordinate system of my data has the origin at the top left corner. For

data with no CRS, geom_sf puts the origin at the bottom left so all my

plots are inverted.

Is there a way to invert the y axis while staying within sf (or possibly

sp?) The only answers I have found involve extracting the coordinates from

the sf objects and inverting or plotting from the raw data. Maybe by

creating a CRS with the correct orientation?

For a very simple example with just a few vectors - the code below plots an

arrow pointing down; I would like to invert the y-axis so it points up.

library(sf)

library(ggplot2)

s1 <- rbind(c(9, 11), c(10, 10))

s2 <- rbind(c(11, 11), c(10, 10))

s3 <- rbind(c(10,14), c(10, 12), c(10,10))

mls <- st_multilinestring(list(s1,s2,s3))

ggplot(mls) + geom_sf()

Thank you for any help,

Kent Johnson

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Calculating weighted spatial means globally across grid cells using NetCDF file

Hi there,

I am currently working on a project that involves climate model data stored in a NetCDF file. I am currently trying to calculate "weighted" spatial annual "global" averages for precipitation. I need to do this for each of the 95 years of global precipitation data that I have. The idea would be to somehow apply weights to each grid cell by using the cosine of its latitude (which means latitude grid cells at the equator would have a weight of 1 (i.e. the cosine of 0 degrees is 1), and the poles would have a value of 1 (as the cosine of 90 is 1)). Then, I would be in a position to calculate annual weighted averages based on averaging each grid cell.

I have an idea how to do this conceptually, but I am not sure where to begin writing a script in R to apply the weights across all grid cells and then average these for each of the 95 years. I would greatly appreciate any help with this, or any resources that may be helpful!!!

At the very least, I have opened the .nc file and read-in the NetCDF variables, as shown below:

ncfname<-"MaxPrecCCCMACanESM2rcp45.nc"

Prec<-raster(ncfname)

print(Prec)

Model<-nc_open(ncfname)

get<-ncvar_get(Model,"onedaymax")longitude<-ncvar_get(Model, "lon")

latitude<-ncvar_get(Model, "lat")

Year<-ncvar_get(Model, "Year")

Additionally, let's say that I wanted to create a time series of these newly derived weighted averaged for a specific location or region, the following code that I previously used to show trends over the 95 years for one-day maximum precipitation works, but I would just need to change it slightly to use the annual weighted means? :

r_brick<-brick(get, xmn=min(latitude), xmx=max(latitude), ymn=min(longitude), ymx=max(longitude), crs=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs+ towgs84=0,0,0"))

r_brick<-flip(t(r_brick), direction='y')

randompointlon<-13.178

randompointlat<--59.548

Hope<-extract(r_brick, SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')

df<-data.frame(year=seq(from=1, to=95, by=1), Precipitation=t(Hope))

ggplot(data=df, aes(x=Year, y=Precipitation, group=1))+geom_line()+ggtitle("One-day maximum precipitation (mm/day) trend for Barbados for CanESM2 RCP4.5")

Also, if it helps, here is what the .nc file contains:

3 variables (excluding dimension variables):

double onedaymax[lon,lat,time] (Contiguous storage)

units: mm/day

double fivedaymax[lon,lat,time] (Contiguous storage)

units: mm/day

short Year[time] (Contiguous storage)

3 dimensions:

time Size:95

lat Size:64

units: degree North

lon Size:128

units: degree East

Again, any assistance would be extremely valuable with this! I look forward to your response!

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

I am currently working on a project that involves climate model data stored in a NetCDF file. I am currently trying to calculate "weighted" spatial annual "global" averages for precipitation. I need to do this for each of the 95 years of global precipitation data that I have. The idea would be to somehow apply weights to each grid cell by using the cosine of its latitude (which means latitude grid cells at the equator would have a weight of 1 (i.e. the cosine of 0 degrees is 1), and the poles would have a value of 1 (as the cosine of 90 is 1)). Then, I would be in a position to calculate annual weighted averages based on averaging each grid cell.

I have an idea how to do this conceptually, but I am not sure where to begin writing a script in R to apply the weights across all grid cells and then average these for each of the 95 years. I would greatly appreciate any help with this, or any resources that may be helpful!!!

At the very least, I have opened the .nc file and read-in the NetCDF variables, as shown below:

ncfname<-"MaxPrecCCCMACanESM2rcp45.nc"

Prec<-raster(ncfname)

print(Prec)

Model<-nc_open(ncfname)

get<-ncvar_get(Model,"onedaymax")longitude<-ncvar_get(Model, "lon")

latitude<-ncvar_get(Model, "lat")

Year<-ncvar_get(Model, "Year")

Additionally, let's say that I wanted to create a time series of these newly derived weighted averaged for a specific location or region, the following code that I previously used to show trends over the 95 years for one-day maximum precipitation works, but I would just need to change it slightly to use the annual weighted means? :

r_brick<-brick(get, xmn=min(latitude), xmx=max(latitude), ymn=min(longitude), ymx=max(longitude), crs=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs+ towgs84=0,0,0"))

r_brick<-flip(t(r_brick), direction='y')

randompointlon<-13.178

randompointlat<--59.548

Hope<-extract(r_brick, SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')

df<-data.frame(year=seq(from=1, to=95, by=1), Precipitation=t(Hope))

ggplot(data=df, aes(x=Year, y=Precipitation, group=1))+geom_line()+ggtitle("One-day maximum precipitation (mm/day) trend for Barbados for CanESM2 RCP4.5")

Also, if it helps, here is what the .nc file contains:

3 variables (excluding dimension variables):

double onedaymax[lon,lat,time] (Contiguous storage)

units: mm/day

double fivedaymax[lon,lat,time] (Contiguous storage)

units: mm/day

short Year[time] (Contiguous storage)

3 dimensions:

time Size:95

lat Size:64

units: degree North

lon Size:128

units: degree East

Again, any assistance would be extremely valuable with this! I look forward to your response!

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Correlograms of Moran's I with progressive Bonferroni correction

Hi Roger,

According to the book "Numerical Ecology" by Legendre&Legendre in 2012, a

progressive (sequential) Bonferroni correction is a modified version of

Bonferroni correction, where the Bonferroni-corrected level is computed for

each distance class separately instead of using a consistent level for all

distance classes. This is done by using for each distance class the number

of tests actually performed up to that distance class. For example, if we

have 10 distance classes, and we use a=0.05 as a probability level, then

the adjusted a (a') for the first distance class is a'=a/1=0.05, for the

second distance class is a'=a/2=0.025 ... for the 10th distance class is

a'=a/10=0.005.

I've checked the mpmcorrelogram package, it seems that this package is for

creating multivariate correlograms. But what I hope to get is correlograms

of autocorrelation over one variate (e.g. Moran's I).

Hope this is clearer. Thank you for your help.

Mingke

On Mon, Mar 18, 2019 at 5:41 AM Roger Bivand <[hidden email]> wrote:

> On Sun, 17 Mar 2019, Mingke Li wrote:

>

> > Dear list,

> >

> > I am trying to generate a correlogram of Moran's I, with symbols showing

> if

> > the coefficient is significant or not after the progressive Bonferroni

> > correction. Now I'm using the "correlog" function in the package ncf to

> > calculate the coefficients among all distance classes. I symbolized the

> > dots in the plot to show if they are significant or not (after

> progressive

> > Bonferroni correction), say, open circles for non-significant

> coefficients,

> > and solid circles for significant coefficients.

>

> Explain what you mean here by progressive Bonferroni correction, please.

> Could you rather see what is done in the mpmcorrelogram package, and

> report back if it makes sense?

>

> Roger

>

> >

> > These are the codes I used in R:

> >

> >> correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,

> > Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)

> >> for (i in list(1:length(correlog.L2.2014new$p))) {

> > correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i

> > }

> >> plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,

> > ylim=c(-0.1,0.7),

> > pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),

> > xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);

> > abline(h=0)

> >

> > I also found the function "sp.correlogram" in the package spdep to make

> the

> > correlogram with Bonferroni correction.

> >

> > Now I have three questions:

> >

> > 1. Can I set a "up-limit" to the "correlog" function? For example, if I

> > just need the first 80 distance classes to generate the graph (as shown

> in

> > the plot code), is it possible to let the "correlog" function skip the

> rest

> > distance classes to save the computation time?

> >

> > 2. Is my code of generating p values after the progressive Bonferroni

> > correction correct? If not, how should I fix it?

> >

> > 3. Now I'm kind of correcting the p value manually based on my

> > understanding of progressive Bonferroni correction. Is there any function

> > in any R packages for creating correlograms with progressive Bonferroni

> > correction? "sp.correlogram" has a parameter setting "p.adj.method" but

> it

> > seems do not have a progressive Bonferroni correction option?

> >

> > I just start to work with the correlograms recently; any advice or

> > solutions are welcome. Thank you in advance!

> >

> > Erin

> >

> > [[alternative HTML version deleted]]

> >

> > _______________________________________________

> > R-sig-Geo mailing list

> > [hidden email]

> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> >

>

> --

> Roger Bivand

> Department of Economics, Norwegian School of Economics,

> Helleveien 30, N-5045 Bergen, Norway.

> voice: +47 55 95 93 55; e-mail: [hidden email]

> https://orcid.org/0000-0003-2392-6140

> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

According to the book "Numerical Ecology" by Legendre&Legendre in 2012, a

progressive (sequential) Bonferroni correction is a modified version of

Bonferroni correction, where the Bonferroni-corrected level is computed for

each distance class separately instead of using a consistent level for all

distance classes. This is done by using for each distance class the number

of tests actually performed up to that distance class. For example, if we

have 10 distance classes, and we use a=0.05 as a probability level, then

the adjusted a (a') for the first distance class is a'=a/1=0.05, for the

second distance class is a'=a/2=0.025 ... for the 10th distance class is

a'=a/10=0.005.

I've checked the mpmcorrelogram package, it seems that this package is for

creating multivariate correlograms. But what I hope to get is correlograms

of autocorrelation over one variate (e.g. Moran's I).

Hope this is clearer. Thank you for your help.

Mingke

On Mon, Mar 18, 2019 at 5:41 AM Roger Bivand <[hidden email]> wrote:

> On Sun, 17 Mar 2019, Mingke Li wrote:

>

> > Dear list,

> >

> > I am trying to generate a correlogram of Moran's I, with symbols showing

> if

> > the coefficient is significant or not after the progressive Bonferroni

> > correction. Now I'm using the "correlog" function in the package ncf to

> > calculate the coefficients among all distance classes. I symbolized the

> > dots in the plot to show if they are significant or not (after

> progressive

> > Bonferroni correction), say, open circles for non-significant

> coefficients,

> > and solid circles for significant coefficients.

>

> Explain what you mean here by progressive Bonferroni correction, please.

> Could you rather see what is done in the mpmcorrelogram package, and

> report back if it makes sense?

>

> Roger

>

> >

> > These are the codes I used in R:

> >

> >> correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,

> > Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)

> >> for (i in list(1:length(correlog.L2.2014new$p))) {

> > correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i

> > }

> >> plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,

> > ylim=c(-0.1,0.7),

> > pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),

> > xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);

> > abline(h=0)

> >

> > I also found the function "sp.correlogram" in the package spdep to make

> the

> > correlogram with Bonferroni correction.

> >

> > Now I have three questions:

> >

> > 1. Can I set a "up-limit" to the "correlog" function? For example, if I

> > just need the first 80 distance classes to generate the graph (as shown

> in

> > the plot code), is it possible to let the "correlog" function skip the

> rest

> > distance classes to save the computation time?

> >

> > 2. Is my code of generating p values after the progressive Bonferroni

> > correction correct? If not, how should I fix it?

> >

> > 3. Now I'm kind of correcting the p value manually based on my

> > understanding of progressive Bonferroni correction. Is there any function

> > in any R packages for creating correlograms with progressive Bonferroni

> > correction? "sp.correlogram" has a parameter setting "p.adj.method" but

> it

> > seems do not have a progressive Bonferroni correction option?

> >

> > I just start to work with the correlograms recently; any advice or

> > solutions are welcome. Thank you in advance!

> >

> > Erin

> >

> > [[alternative HTML version deleted]]

> >

> > _______________________________________________

> > R-sig-Geo mailing list

> > [hidden email]

> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> >

>

> --

> Roger Bivand

> Department of Economics, Norwegian School of Economics,

> Helleveien 30, N-5045 Bergen, Norway.

> voice: +47 55 95 93 55; e-mail: [hidden email]

> https://orcid.org/0000-0003-2392-6140

> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Error in run GAM (Biomod 2)

Hello

I am trying to run several algorithms in biomod 2 (GLM, GAM, ANN, SRE) but

I received the following menssage.

Model=GAM

GAM_mgcv algorithm chosen

Automatic formula generation...

> GAM (mgcv) modelling...Error in

smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) :

A term has fewer unique covariate combinations than specified maximum

degrees of freedom

Error in predict(model.bm, Data[, expl_var_names, drop = FALSE], on_0_1000

= TRUE) :

object 'model.bm' not found

*** inherits(g.pred,'try-error')

! Note : Lactuca.global_AllData_RUN1_GAM failed!

I have 19 presences and 1019 pseudo-absences ...

It is because the low number of presences?

Thanks

Lara

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

I am trying to run several algorithms in biomod 2 (GLM, GAM, ANN, SRE) but

I received the following menssage.

Model=GAM

GAM_mgcv algorithm chosen

Automatic formula generation...

> GAM (mgcv) modelling...Error in

smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) :

A term has fewer unique covariate combinations than specified maximum

degrees of freedom

Error in predict(model.bm, Data[, expl_var_names, drop = FALSE], on_0_1000

= TRUE) :

object 'model.bm' not found

*** inherits(g.pred,'try-error')

! Note : Lactuca.global_AllData_RUN1_GAM failed!

I have 19 presences and 1019 pseudo-absences ...

It is because the low number of presences?

Thanks

Lara

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: Correlograms of Moran's I with progressive Bonferroni correction

On Sun, 17 Mar 2019, Mingke Li wrote:

> Dear list,

>

> I am trying to generate a correlogram of Moran's I, with symbols showing if

> the coefficient is significant or not after the progressive Bonferroni

> correction. Now I'm using the "correlog" function in the package ncf to

> calculate the coefficients among all distance classes. I symbolized the

> dots in the plot to show if they are significant or not (after progressive

> Bonferroni correction), say, open circles for non-significant coefficients,

> and solid circles for significant coefficients.

Explain what you mean here by progressive Bonferroni correction, please.

Could you rather see what is done in the mpmcorrelogram package, and

report back if it makes sense?

Roger

>

> These are the codes I used in R:

>

>> correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,

> Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)

>> for (i in list(1:length(correlog.L2.2014new$p))) {

> correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i

> }

>> plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,

> ylim=c(-0.1,0.7),

> pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),

> xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);

> abline(h=0)

>

> I also found the function "sp.correlogram" in the package spdep to make the

> correlogram with Bonferroni correction.

>

> Now I have three questions:

>

> 1. Can I set a "up-limit" to the "correlog" function? For example, if I

> just need the first 80 distance classes to generate the graph (as shown in

> the plot code), is it possible to let the "correlog" function skip the rest

> distance classes to save the computation time?

>

> 2. Is my code of generating p values after the progressive Bonferroni

> correction correct? If not, how should I fix it?

>

> 3. Now I'm kind of correcting the p value manually based on my

> understanding of progressive Bonferroni correction. Is there any function

> in any R packages for creating correlograms with progressive Bonferroni

> correction? "sp.correlogram" has a parameter setting "p.adj.method" but it

> seems do not have a progressive Bonferroni correction option?

>

> I just start to work with the correlograms recently; any advice or

> solutions are welcome. Thank you in advance!

>

> Erin

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>

--

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

> Dear list,

>

> I am trying to generate a correlogram of Moran's I, with symbols showing if

> the coefficient is significant or not after the progressive Bonferroni

> correction. Now I'm using the "correlog" function in the package ncf to

> calculate the coefficients among all distance classes. I symbolized the

> dots in the plot to show if they are significant or not (after progressive

> Bonferroni correction), say, open circles for non-significant coefficients,

> and solid circles for significant coefficients.

Explain what you mean here by progressive Bonferroni correction, please.

Could you rather see what is done in the mpmcorrelogram package, and

report back if it makes sense?

Roger

>

> These are the codes I used in R:

>

>> correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,

> Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)

>> for (i in list(1:length(correlog.L2.2014new$p))) {

> correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i

> }

>> plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,

> ylim=c(-0.1,0.7),

> pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),

> xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);

> abline(h=0)

>

> I also found the function "sp.correlogram" in the package spdep to make the

> correlogram with Bonferroni correction.

>

> Now I have three questions:

>

> 1. Can I set a "up-limit" to the "correlog" function? For example, if I

> just need the first 80 distance classes to generate the graph (as shown in

> the plot code), is it possible to let the "correlog" function skip the rest

> distance classes to save the computation time?

>

> 2. Is my code of generating p values after the progressive Bonferroni

> correction correct? If not, how should I fix it?

>

> 3. Now I'm kind of correcting the p value manually based on my

> understanding of progressive Bonferroni correction. Is there any function

> in any R packages for creating correlograms with progressive Bonferroni

> correction? "sp.correlogram" has a parameter setting "p.adj.method" but it

> seems do not have a progressive Bonferroni correction option?

>

> I just start to work with the correlograms recently; any advice or

> solutions are welcome. Thank you in advance!

>

> Erin

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>

--

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

### Re: editing a correlogram

On Sun, 17 Mar 2019, Leonardo Matheus Servino wrote:

> My script:

No, not your script, a *reproducible* example, using a built-in data set.

Nobody can run your code without your data, and we don't need your data.

Did you read my reply? Why have you quoted the numerical arguments - a

clear error?

For me:

> par(adj=0.5, family="serif", cex.axis=1.5, xaxs="r", cex.axis=2.5,

+ cex.lab=2.5, las=1, tcl=-0.25, lwd=1.8, ps=5, mex=0.7, lty="blank")

> plot(Ispc)

does do something, but whether this is what you consider prettier isn't my

problem. If you prefer, take the output of the print method and use any

plotting functionality you chose.

Roger

>

> library(spdep)

> setwd('C:/Dados')

> dados_I_langsdorffii<-read.csv('I_langsdorffii.csv', sep=';')

> coords<-cbind(dados_I_langsdorffii$LONG, dados_I_langsdorffii$LAT)

> coords1<-as.matrix(coords)

> source("plot.links.r")

> plot.links(coords, thresh = 0.5, text = F)

> vizinho<-dnearneigh(as.matrix(coords1), 0, 0.5)

> summary(vizinho)

> corre.sp <- sp.correlogram(vizinho, dados_I_langsdorffii$MEDIANA_CRC, order

> =5, method = "I",zero.policy = TRUE)

> print(corre.sp, p.adj.method = "holm")

> par(adj="0.5",family="serif",cex.axis="1.5",xaxs="r",cex.axis="2.5",cex.lab="2.5",las="1",tcl="-0.25",lwd="1.8",

> ps="5", mex="0.7", lty="blank")

> plot(corre.sp, p.adj.method = "holm", main="",ylim=c(-1,1))

>

> Em sáb, 16 de mar de 2019 às 19:04, Roger Bivand <[hidden email]>

> escreveu:

>

>> On Sat, 16 Mar 2019, Ben Tupper wrote:

>>

>>> Hi,

>>>

>>> In this case the spdep::plot.spcor() function, which I think you are

>>> using, doesn't provide the mechanism for the caller to override the

>>> default pch value. You can see this by looking at the pl.spcor function

>>> (as shown way below.) I think it may be easiest for you to simply

>>> rewrite the function with the plotting parameters assigned as arguments.

>>

>> Thanks, indeed the ... should be passed through to plotting functions,

>> and I'll look at doing this. My preference would be to extract the

>> components of the returned object needed for customised plotting, not

>> trying to finesse the plot method, which was always meant for guidance,

>> like other diagnostic plots.

>>

>> As Rolf said, an example of the code you are using (on a built-in data

>> set) to show what you want would make things easier, say based on the help

>> page example. Note that print method returns its calculations invisibly

>> too.

>>

>> nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1],

>> quiet=TRUE)

>> rn <- as.character(nc.sids$FIPS)

>> ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal",

>> package="spData")[1],

>> region.id=rn)

>> ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +

>> sqrt((nc.sids$SID74+1)/nc.sids$BIR74))

>> tr.SIDS74 <- ft.SID74*sqrt(nc.sids$BIR74)

>> Ispc <- sp.correlogram(ncCC89_nb, tr.SIDS74, order=8, method="I",

>> zero.policy=TRUE)

>> str(Ispc)

>> str(print(Ispc, "bonferroni"))

>> Ispc_b <- as.data.frame(print(Ispc, "bonferroni"))

>> Ispc_b$lag <- 1:8

>> library(ggplot2)

>> ggplot(Ispc_b) + geom_point(aes(x=lag, y=estimate))

>> + geom_hline(yintercept=0)

>>

>> Or whatever you feel like doing.

>>

>> Roger

>>

>>>

>>> Cheers,

>>> Ben

>>>

>>>

>>>> spdep::plot.spcor

>>> function (x, main, ylab, ylim, ...)

>>> {

>>> if (missing(main))

>>> main <- x$var

>>> if ((x$method == "I") || (x$method == "C")) {

>>> lags <- as.integer(rownames(x$res))

>>> to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

>>> sd2 <- rep(0, nrow(x$res))

>>> sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

>>> if (missing(ylim)) {

>>> ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

>>> }

>>> if (missing(ylab))

>>> if (x$method == "I")

>>> ylab <- "Moran's I"

>>> if (x$method == "C")

>>> ylab <- "Geary's C"

>>> plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

>>> main = main, ylab = ylab, xaxt = "n")

>>> arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

>>> length = 0.1, angle = 90)

>>> arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

>>> length = 0.1, angle = 90)

>>> axis(1, at = lags)

>>> abline(h = x$res[1, 2])

>>> }

>>> else {

>>> res <- as.vector(x$res)

>>> lags <- as.integer(names(x$res))

>>> if (missing(ylim))

>>> ylim <- c(-1, 1)

>>> if (missing(ylab))

>>> ylab <- "Spatial autocorrelation"

>>> plot(lags, res, type = "h", ylim = ylim, main = main,

>>> ylab = ylab, lwd = 4, xaxt = "n")

>>> axis(1, at = lags)

>>> abline(h = 0)

>>> }

>>> }

>>> <bytecode: 0x7fb8799d0e40>

>>> <environment: namespace:spdep>

>>>

>>>

>>>

>>>> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <

>> [hidden email]> wrote:

>>>>

>>>> I tried the function par() and arguments inside the plot(), but some

>>>> parameters doesn't change.

>>>> For example, the argument pch=, which changes the symbols that

>> represents

>>>> the points in the plot doesn't work.

>>>>

>>>>

>>>> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <

>> [hidden email] <mailto:[hidden email]>>

>>>> escreveu:

>>>>

>>>>> Of course.

>>>>>

>>>>> The ... argument to the plot method means that you can use standard

>>>>> base graphics options to customize as you wish.

>>>>>

>>>>> ?par gives the whole list, although they may not all be useful for

>>>>> correlograms.

>>>>>

>>>>> If you have specific questions after you try customizing to your

>>>>> liking, the list can certainly help with details.

>>>>>

>>>>> Sarah

>>>>>

>>>>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

>>>>> <[hidden email]> wrote:

>>>>>>

>>>>>> Hello,

>>>>>>

>>>>>> I've been tried to use the function "sp.correlogram". After plot the

>>>>>> correlogram, I would like to edit the grafic's appearence, to publish

>> it.

>>>>>> It is possible?

>>>>>>

>>>>>> Thanks

>>>>>>

>>>>>> --

>>>>>> Leonardo Matheus Servino

>>>>>> Pós-Graduação em Evolução e Diversidade

>>>>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>>>>> Humanas

>>>>>>

>>>>>

>>>>> --

>>>>> Sarah Goslee (she/her)

>>>>> http://www.numberwright.com

>>>>>

>>>>

>>>>

>>>> --

>>>> Leonardo Matheus Servino

>>>> Pós-Graduação em Evolução e Diversidade

>>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>> Humanas

>>>>

>>>> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

>>>>

>>>> Rua Arcturus, 3. Jardim Antares

>>>> 09606-070 São Bernardo do Campo - SP

>>>>

>>>> [[alternative HTML version deleted]]

>>>>

>>>> _______________________________________________

>>>> R-sig-Geo mailing list

>>>> [hidden email] <mailto:[hidden email]>

>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <

>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

>>> Ben Tupper

>>> Bigelow Laboratory for Ocean Sciences

>>> 60 Bigelow Drive, P.O. Box 380

>>> East Boothbay, Maine 04544

>>> http://www.bigelow.org

>>>

>>> Ecological Forecasting: https://eco.bigelow.org/

>>>

>>>

>>>

>>>

>>>

>>>

>>> [[alternative HTML version deleted]]

>>>

>>> _______________________________________________

>>> R-sig-Geo mailing list

>>> [hidden email]

>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>>

>>

>> --

>> Roger Bivand

>> Department of Economics, Norwegian School of Economics,

>> Helleveien 30, N-5045 Bergen, Norway.

>> voice: +47 55 95 93 55; e-mail: [hidden email]

>> https://orcid.org/0000-0003-2392-6140

>> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>

>

>

> --

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

> My script:

No, not your script, a *reproducible* example, using a built-in data set.

Nobody can run your code without your data, and we don't need your data.

Did you read my reply? Why have you quoted the numerical arguments - a

clear error?

For me:

> par(adj=0.5, family="serif", cex.axis=1.5, xaxs="r", cex.axis=2.5,

+ cex.lab=2.5, las=1, tcl=-0.25, lwd=1.8, ps=5, mex=0.7, lty="blank")

> plot(Ispc)

does do something, but whether this is what you consider prettier isn't my

problem. If you prefer, take the output of the print method and use any

plotting functionality you chose.

Roger

>

> library(spdep)

> setwd('C:/Dados')

> dados_I_langsdorffii<-read.csv('I_langsdorffii.csv', sep=';')

> coords<-cbind(dados_I_langsdorffii$LONG, dados_I_langsdorffii$LAT)

> coords1<-as.matrix(coords)

> source("plot.links.r")

> plot.links(coords, thresh = 0.5, text = F)

> vizinho<-dnearneigh(as.matrix(coords1), 0, 0.5)

> summary(vizinho)

> corre.sp <- sp.correlogram(vizinho, dados_I_langsdorffii$MEDIANA_CRC, order

> =5, method = "I",zero.policy = TRUE)

> print(corre.sp, p.adj.method = "holm")

> par(adj="0.5",family="serif",cex.axis="1.5",xaxs="r",cex.axis="2.5",cex.lab="2.5",las="1",tcl="-0.25",lwd="1.8",

> ps="5", mex="0.7", lty="blank")

> plot(corre.sp, p.adj.method = "holm", main="",ylim=c(-1,1))

>

> Em sáb, 16 de mar de 2019 às 19:04, Roger Bivand <[hidden email]>

> escreveu:

>

>> On Sat, 16 Mar 2019, Ben Tupper wrote:

>>

>>> Hi,

>>>

>>> In this case the spdep::plot.spcor() function, which I think you are

>>> using, doesn't provide the mechanism for the caller to override the

>>> default pch value. You can see this by looking at the pl.spcor function

>>> (as shown way below.) I think it may be easiest for you to simply

>>> rewrite the function with the plotting parameters assigned as arguments.

>>

>> Thanks, indeed the ... should be passed through to plotting functions,

>> and I'll look at doing this. My preference would be to extract the

>> components of the returned object needed for customised plotting, not

>> trying to finesse the plot method, which was always meant for guidance,

>> like other diagnostic plots.

>>

>> As Rolf said, an example of the code you are using (on a built-in data

>> set) to show what you want would make things easier, say based on the help

>> page example. Note that print method returns its calculations invisibly

>> too.

>>

>> nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1],

>> quiet=TRUE)

>> rn <- as.character(nc.sids$FIPS)

>> ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal",

>> package="spData")[1],

>> region.id=rn)

>> ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +

>> sqrt((nc.sids$SID74+1)/nc.sids$BIR74))

>> tr.SIDS74 <- ft.SID74*sqrt(nc.sids$BIR74)

>> Ispc <- sp.correlogram(ncCC89_nb, tr.SIDS74, order=8, method="I",

>> zero.policy=TRUE)

>> str(Ispc)

>> str(print(Ispc, "bonferroni"))

>> Ispc_b <- as.data.frame(print(Ispc, "bonferroni"))

>> Ispc_b$lag <- 1:8

>> library(ggplot2)

>> ggplot(Ispc_b) + geom_point(aes(x=lag, y=estimate))

>> + geom_hline(yintercept=0)

>>

>> Or whatever you feel like doing.

>>

>> Roger

>>

>>>

>>> Cheers,

>>> Ben

>>>

>>>

>>>> spdep::plot.spcor

>>> function (x, main, ylab, ylim, ...)

>>> {

>>> if (missing(main))

>>> main <- x$var

>>> if ((x$method == "I") || (x$method == "C")) {

>>> lags <- as.integer(rownames(x$res))

>>> to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

>>> sd2 <- rep(0, nrow(x$res))

>>> sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

>>> if (missing(ylim)) {

>>> ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

>>> }

>>> if (missing(ylab))

>>> if (x$method == "I")

>>> ylab <- "Moran's I"

>>> if (x$method == "C")

>>> ylab <- "Geary's C"

>>> plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

>>> main = main, ylab = ylab, xaxt = "n")

>>> arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

>>> length = 0.1, angle = 90)

>>> arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

>>> length = 0.1, angle = 90)

>>> axis(1, at = lags)

>>> abline(h = x$res[1, 2])

>>> }

>>> else {

>>> res <- as.vector(x$res)

>>> lags <- as.integer(names(x$res))

>>> if (missing(ylim))

>>> ylim <- c(-1, 1)

>>> if (missing(ylab))

>>> ylab <- "Spatial autocorrelation"

>>> plot(lags, res, type = "h", ylim = ylim, main = main,

>>> ylab = ylab, lwd = 4, xaxt = "n")

>>> axis(1, at = lags)

>>> abline(h = 0)

>>> }

>>> }

>>> <bytecode: 0x7fb8799d0e40>

>>> <environment: namespace:spdep>

>>>

>>>

>>>

>>>> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <

>> [hidden email]> wrote:

>>>>

>>>> I tried the function par() and arguments inside the plot(), but some

>>>> parameters doesn't change.

>>>> For example, the argument pch=, which changes the symbols that

>> represents

>>>> the points in the plot doesn't work.

>>>>

>>>>

>>>> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <

>> [hidden email] <mailto:[hidden email]>>

>>>> escreveu:

>>>>

>>>>> Of course.

>>>>>

>>>>> The ... argument to the plot method means that you can use standard

>>>>> base graphics options to customize as you wish.

>>>>>

>>>>> ?par gives the whole list, although they may not all be useful for

>>>>> correlograms.

>>>>>

>>>>> If you have specific questions after you try customizing to your

>>>>> liking, the list can certainly help with details.

>>>>>

>>>>> Sarah

>>>>>

>>>>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

>>>>> <[hidden email]> wrote:

>>>>>>

>>>>>> Hello,

>>>>>>

>>>>>> I've been tried to use the function "sp.correlogram". After plot the

>>>>>> correlogram, I would like to edit the grafic's appearence, to publish

>> it.

>>>>>> It is possible?

>>>>>>

>>>>>> Thanks

>>>>>>

>>>>>> --

>>>>>> Leonardo Matheus Servino

>>>>>> Pós-Graduação em Evolução e Diversidade

>>>>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>>>>> Humanas

>>>>>>

>>>>>

>>>>> --

>>>>> Sarah Goslee (she/her)

>>>>> http://www.numberwright.com

>>>>>

>>>>

>>>>

>>>> --

>>>> Leonardo Matheus Servino

>>>> Pós-Graduação em Evolução e Diversidade

>>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>> Humanas

>>>>

>>>> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

>>>>

>>>> Rua Arcturus, 3. Jardim Antares

>>>> 09606-070 São Bernardo do Campo - SP

>>>>

>>>> [[alternative HTML version deleted]]

>>>>

>>>> _______________________________________________

>>>> R-sig-Geo mailing list

>>>> [hidden email] <mailto:[hidden email]>

>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <

>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

>>> Ben Tupper

>>> Bigelow Laboratory for Ocean Sciences

>>> 60 Bigelow Drive, P.O. Box 380

>>> East Boothbay, Maine 04544

>>> http://www.bigelow.org

>>>

>>> Ecological Forecasting: https://eco.bigelow.org/

>>>

>>>

>>>

>>>

>>>

>>>

>>> [[alternative HTML version deleted]]

>>>

>>> _______________________________________________

>>> R-sig-Geo mailing list

>>> [hidden email]

>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>>

>>

>> --

>> Roger Bivand

>> Department of Economics, Norwegian School of Economics,

>> Helleveien 30, N-5045 Bergen, Norway.

>> voice: +47 55 95 93 55; e-mail: [hidden email]

>> https://orcid.org/0000-0003-2392-6140

>> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

>

>

>

> --

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

### Re: editing a correlogram

My script:

library(spdep)

setwd('C:/Dados')

dados_I_langsdorffii<-read.csv('I_langsdorffii.csv', sep=';')

coords<-cbind(dados_I_langsdorffii$LONG, dados_I_langsdorffii$LAT)

coords1<-as.matrix(coords)

source("plot.links.r")

plot.links(coords, thresh = 0.5, text = F)

vizinho<-dnearneigh(as.matrix(coords1), 0, 0.5)

summary(vizinho)

corre.sp <- sp.correlogram(vizinho, dados_I_langsdorffii$MEDIANA_CRC, order

=5, method = "I",zero.policy = TRUE)

print(corre.sp, p.adj.method = "holm")

par(adj="0.5",family="serif",cex.axis="1.5",xaxs="r",cex.axis="2.5",cex.lab="2.5",las="1",tcl="-0.25",lwd="1.8",

ps="5", mex="0.7", lty="blank")

plot(corre.sp, p.adj.method = "holm", main="",ylim=c(-1,1))

Em sáb, 16 de mar de 2019 às 19:04, Roger Bivand <[hidden email]>

escreveu:

> On Sat, 16 Mar 2019, Ben Tupper wrote:

>

> > Hi,

> >

> > In this case the spdep::plot.spcor() function, which I think you are

> > using, doesn't provide the mechanism for the caller to override the

> > default pch value. You can see this by looking at the pl.spcor function

> > (as shown way below.) I think it may be easiest for you to simply

> > rewrite the function with the plotting parameters assigned as arguments.

>

> Thanks, indeed the ... should be passed through to plotting functions,

> and I'll look at doing this. My preference would be to extract the

> components of the returned object needed for customised plotting, not

> trying to finesse the plot method, which was always meant for guidance,

> like other diagnostic plots.

>

> As Rolf said, an example of the code you are using (on a built-in data

> set) to show what you want would make things easier, say based on the help

> page example. Note that print method returns its calculations invisibly

> too.

>

> nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1],

> quiet=TRUE)

> rn <- as.character(nc.sids$FIPS)

> ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal",

> package="spData")[1],

> region.id=rn)

> ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +

> sqrt((nc.sids$SID74+1)/nc.sids$BIR74))

> tr.SIDS74 <- ft.SID74*sqrt(nc.sids$BIR74)

> Ispc <- sp.correlogram(ncCC89_nb, tr.SIDS74, order=8, method="I",

> zero.policy=TRUE)

> str(Ispc)

> str(print(Ispc, "bonferroni"))

> Ispc_b <- as.data.frame(print(Ispc, "bonferroni"))

> Ispc_b$lag <- 1:8

> library(ggplot2)

> ggplot(Ispc_b) + geom_point(aes(x=lag, y=estimate))

> + geom_hline(yintercept=0)

>

> Or whatever you feel like doing.

>

> Roger

>

> >

> > Cheers,

> > Ben

> >

> >

> >> spdep::plot.spcor

> > function (x, main, ylab, ylim, ...)

> > {

> > if (missing(main))

> > main <- x$var

> > if ((x$method == "I") || (x$method == "C")) {

> > lags <- as.integer(rownames(x$res))

> > to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

> > sd2 <- rep(0, nrow(x$res))

> > sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

> > if (missing(ylim)) {

> > ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

> > }

> > if (missing(ylab))

> > if (x$method == "I")

> > ylab <- "Moran's I"

> > if (x$method == "C")

> > ylab <- "Geary's C"

> > plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

> > main = main, ylab = ylab, xaxt = "n")

> > arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

> > length = 0.1, angle = 90)

> > arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

> > length = 0.1, angle = 90)

> > axis(1, at = lags)

> > abline(h = x$res[1, 2])

> > }

> > else {

> > res <- as.vector(x$res)

> > lags <- as.integer(names(x$res))

> > if (missing(ylim))

> > ylim <- c(-1, 1)

> > if (missing(ylab))

> > ylab <- "Spatial autocorrelation"

> > plot(lags, res, type = "h", ylim = ylim, main = main,

> > ylab = ylab, lwd = 4, xaxt = "n")

> > axis(1, at = lags)

> > abline(h = 0)

> > }

> > }

> > <bytecode: 0x7fb8799d0e40>

> > <environment: namespace:spdep>

> >

> >

> >

> >> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <

> [hidden email]> wrote:

> >>

> >> I tried the function par() and arguments inside the plot(), but some

> >> parameters doesn't change.

> >> For example, the argument pch=, which changes the symbols that

> represents

> >> the points in the plot doesn't work.

> >>

> >>

> >> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <

> [hidden email] <mailto:[hidden email]>>

> >> escreveu:

> >>

> >>> Of course.

> >>>

> >>> The ... argument to the plot method means that you can use standard

> >>> base graphics options to customize as you wish.

> >>>

> >>> ?par gives the whole list, although they may not all be useful for

> >>> correlograms.

> >>>

> >>> If you have specific questions after you try customizing to your

> >>> liking, the list can certainly help with details.

> >>>

> >>> Sarah

> >>>

> >>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

> >>> <[hidden email]> wrote:

> >>>>

> >>>> Hello,

> >>>>

> >>>> I've been tried to use the function "sp.correlogram". After plot the

> >>>> correlogram, I would like to edit the grafic's appearence, to publish

> it.

> >>>> It is possible?

> >>>>

> >>>> Thanks

> >>>>

> >>>> --

> >>>> Leonardo Matheus Servino

> >>>> Pós-Graduação em Evolução e Diversidade

> >>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

> >>> Humanas

> >>>>

> >>>

> >>> --

> >>> Sarah Goslee (she/her)

> >>> http://www.numberwright.com

> >>>

> >>

> >>

> >> --

> >> Leonardo Matheus Servino

> >> Pós-Graduação em Evolução e Diversidade

> >> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

> Humanas

> >>

> >> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

> >>

> >> Rua Arcturus, 3. Jardim Antares

> >> 09606-070 São Bernardo do Campo - SP

> >>

> >> [[alternative HTML version deleted]]

> >>

> >> _______________________________________________

> >> R-sig-Geo mailing list

> >> [hidden email] <mailto:[hidden email]>

> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

> > Ben Tupper

> > Bigelow Laboratory for Ocean Sciences

> > 60 Bigelow Drive, P.O. Box 380

> > East Boothbay, Maine 04544

> > http://www.bigelow.org

> >

> > Ecological Forecasting: https://eco.bigelow.org/

> >

> >

> >

> >

> >

> >

> > [[alternative HTML version deleted]]

> >

> > _______________________________________________

> > R-sig-Geo mailing list

> > [hidden email]

> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> >

>

> --

> Roger Bivand

> Department of Economics, Norwegian School of Economics,

> Helleveien 30, N-5045 Bergen, Norway.

> voice: +47 55 95 93 55; e-mail: [hidden email]

> https://orcid.org/0000-0003-2392-6140

> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

--

Leonardo Matheus Servino

Pós-Graduação em Evolução e Diversidade

Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares

09606-070 São Bernardo do Campo - SP

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

library(spdep)

setwd('C:/Dados')

dados_I_langsdorffii<-read.csv('I_langsdorffii.csv', sep=';')

coords<-cbind(dados_I_langsdorffii$LONG, dados_I_langsdorffii$LAT)

coords1<-as.matrix(coords)

source("plot.links.r")

plot.links(coords, thresh = 0.5, text = F)

vizinho<-dnearneigh(as.matrix(coords1), 0, 0.5)

summary(vizinho)

corre.sp <- sp.correlogram(vizinho, dados_I_langsdorffii$MEDIANA_CRC, order

=5, method = "I",zero.policy = TRUE)

print(corre.sp, p.adj.method = "holm")

par(adj="0.5",family="serif",cex.axis="1.5",xaxs="r",cex.axis="2.5",cex.lab="2.5",las="1",tcl="-0.25",lwd="1.8",

ps="5", mex="0.7", lty="blank")

plot(corre.sp, p.adj.method = "holm", main="",ylim=c(-1,1))

Em sáb, 16 de mar de 2019 às 19:04, Roger Bivand <[hidden email]>

escreveu:

> On Sat, 16 Mar 2019, Ben Tupper wrote:

>

> > Hi,

> >

> > In this case the spdep::plot.spcor() function, which I think you are

> > using, doesn't provide the mechanism for the caller to override the

> > default pch value. You can see this by looking at the pl.spcor function

> > (as shown way below.) I think it may be easiest for you to simply

> > rewrite the function with the plotting parameters assigned as arguments.

>

> Thanks, indeed the ... should be passed through to plotting functions,

> and I'll look at doing this. My preference would be to extract the

> components of the returned object needed for customised plotting, not

> trying to finesse the plot method, which was always meant for guidance,

> like other diagnostic plots.

>

> As Rolf said, an example of the code you are using (on a built-in data

> set) to show what you want would make things easier, say based on the help

> page example. Note that print method returns its calculations invisibly

> too.

>

> nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1],

> quiet=TRUE)

> rn <- as.character(nc.sids$FIPS)

> ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal",

> package="spData")[1],

> region.id=rn)

> ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +

> sqrt((nc.sids$SID74+1)/nc.sids$BIR74))

> tr.SIDS74 <- ft.SID74*sqrt(nc.sids$BIR74)

> Ispc <- sp.correlogram(ncCC89_nb, tr.SIDS74, order=8, method="I",

> zero.policy=TRUE)

> str(Ispc)

> str(print(Ispc, "bonferroni"))

> Ispc_b <- as.data.frame(print(Ispc, "bonferroni"))

> Ispc_b$lag <- 1:8

> library(ggplot2)

> ggplot(Ispc_b) + geom_point(aes(x=lag, y=estimate))

> + geom_hline(yintercept=0)

>

> Or whatever you feel like doing.

>

> Roger

>

> >

> > Cheers,

> > Ben

> >

> >

> >> spdep::plot.spcor

> > function (x, main, ylab, ylim, ...)

> > {

> > if (missing(main))

> > main <- x$var

> > if ((x$method == "I") || (x$method == "C")) {

> > lags <- as.integer(rownames(x$res))

> > to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

> > sd2 <- rep(0, nrow(x$res))

> > sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

> > if (missing(ylim)) {

> > ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

> > }

> > if (missing(ylab))

> > if (x$method == "I")

> > ylab <- "Moran's I"

> > if (x$method == "C")

> > ylab <- "Geary's C"

> > plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

> > main = main, ylab = ylab, xaxt = "n")

> > arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

> > length = 0.1, angle = 90)

> > arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

> > length = 0.1, angle = 90)

> > axis(1, at = lags)

> > abline(h = x$res[1, 2])

> > }

> > else {

> > res <- as.vector(x$res)

> > lags <- as.integer(names(x$res))

> > if (missing(ylim))

> > ylim <- c(-1, 1)

> > if (missing(ylab))

> > ylab <- "Spatial autocorrelation"

> > plot(lags, res, type = "h", ylim = ylim, main = main,

> > ylab = ylab, lwd = 4, xaxt = "n")

> > axis(1, at = lags)

> > abline(h = 0)

> > }

> > }

> > <bytecode: 0x7fb8799d0e40>

> > <environment: namespace:spdep>

> >

> >

> >

> >> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <

> [hidden email]> wrote:

> >>

> >> I tried the function par() and arguments inside the plot(), but some

> >> parameters doesn't change.

> >> For example, the argument pch=, which changes the symbols that

> represents

> >> the points in the plot doesn't work.

> >>

> >>

> >> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <

> [hidden email] <mailto:[hidden email]>>

> >> escreveu:

> >>

> >>> Of course.

> >>>

> >>> The ... argument to the plot method means that you can use standard

> >>> base graphics options to customize as you wish.

> >>>

> >>> ?par gives the whole list, although they may not all be useful for

> >>> correlograms.

> >>>

> >>> If you have specific questions after you try customizing to your

> >>> liking, the list can certainly help with details.

> >>>

> >>> Sarah

> >>>

> >>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

> >>> <[hidden email]> wrote:

> >>>>

> >>>> Hello,

> >>>>

> >>>> I've been tried to use the function "sp.correlogram". After plot the

> >>>> correlogram, I would like to edit the grafic's appearence, to publish

> it.

> >>>> It is possible?

> >>>>

> >>>> Thanks

> >>>>

> >>>> --

> >>>> Leonardo Matheus Servino

> >>>> Pós-Graduação em Evolução e Diversidade

> >>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

> >>> Humanas

> >>>>

> >>>

> >>> --

> >>> Sarah Goslee (she/her)

> >>> http://www.numberwright.com

> >>>

> >>

> >>

> >> --

> >> Leonardo Matheus Servino

> >> Pós-Graduação em Evolução e Diversidade

> >> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

> Humanas

> >>

> >> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

> >>

> >> Rua Arcturus, 3. Jardim Antares

> >> 09606-070 São Bernardo do Campo - SP

> >>

> >> [[alternative HTML version deleted]]

> >>

> >> _______________________________________________

> >> R-sig-Geo mailing list

> >> [hidden email] <mailto:[hidden email]>

> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

> > Ben Tupper

> > Bigelow Laboratory for Ocean Sciences

> > 60 Bigelow Drive, P.O. Box 380

> > East Boothbay, Maine 04544

> > http://www.bigelow.org

> >

> > Ecological Forecasting: https://eco.bigelow.org/

> >

> >

> >

> >

> >

> >

> > [[alternative HTML version deleted]]

> >

> > _______________________________________________

> > R-sig-Geo mailing list

> > [hidden email]

> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> >

>

> --

> Roger Bivand

> Department of Economics, Norwegian School of Economics,

> Helleveien 30, N-5045 Bergen, Norway.

> voice: +47 55 95 93 55; e-mail: [hidden email]

> https://orcid.org/0000-0003-2392-6140

> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

--

Leonardo Matheus Servino

Pós-Graduação em Evolução e Diversidade

Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares

09606-070 São Bernardo do Campo - SP

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Correlograms of Moran's I with progressive Bonferroni correction

Dear list,

I am trying to generate a correlogram of Moran's I, with symbols showing if

the coefficient is significant or not after the progressive Bonferroni

correction. Now I'm using the "correlog" function in the package ncf to

calculate the coefficients among all distance classes. I symbolized the

dots in the plot to show if they are significant or not (after progressive

Bonferroni correction), say, open circles for non-significant coefficients,

and solid circles for significant coefficients.

These are the codes I used in R:

>correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,

Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)

>for (i in list(1:length(correlog.L2.2014new$p))) {

correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i

}

>plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,

ylim=c(-0.1,0.7),

pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),

xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);

abline(h=0)

I also found the function "sp.correlogram" in the package spdep to make the

correlogram with Bonferroni correction.

Now I have three questions:

1. Can I set a "up-limit" to the "correlog" function? For example, if I

just need the first 80 distance classes to generate the graph (as shown in

the plot code), is it possible to let the "correlog" function skip the rest

distance classes to save the computation time?

2. Is my code of generating p values after the progressive Bonferroni

correction correct? If not, how should I fix it?

3. Now I'm kind of correcting the p value manually based on my

understanding of progressive Bonferroni correction. Is there any function

in any R packages for creating correlograms with progressive Bonferroni

correction? "sp.correlogram" has a parameter setting "p.adj.method" but it

seems do not have a progressive Bonferroni correction option?

I just start to work with the correlograms recently; any advice or

solutions are welcome. Thank you in advance!

Erin

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

I am trying to generate a correlogram of Moran's I, with symbols showing if

the coefficient is significant or not after the progressive Bonferroni

correction. Now I'm using the "correlog" function in the package ncf to

calculate the coefficients among all distance classes. I symbolized the

dots in the plot to show if they are significant or not (after progressive

Bonferroni correction), say, open circles for non-significant coefficients,

and solid circles for significant coefficients.

These are the codes I used in R:

>correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,

Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)

>for (i in list(1:length(correlog.L2.2014new$p))) {

correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i

}

>plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,

ylim=c(-0.1,0.7),

pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),

xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);

abline(h=0)

I also found the function "sp.correlogram" in the package spdep to make the

correlogram with Bonferroni correction.

Now I have three questions:

1. Can I set a "up-limit" to the "correlog" function? For example, if I

just need the first 80 distance classes to generate the graph (as shown in

the plot code), is it possible to let the "correlog" function skip the rest

distance classes to save the computation time?

2. Is my code of generating p values after the progressive Bonferroni

correction correct? If not, how should I fix it?

3. Now I'm kind of correcting the p value manually based on my

understanding of progressive Bonferroni correction. Is there any function

in any R packages for creating correlograms with progressive Bonferroni

correction? "sp.correlogram" has a parameter setting "p.adj.method" but it

seems do not have a progressive Bonferroni correction option?

I just start to work with the correlograms recently; any advice or

solutions are welcome. Thank you in advance!

Erin

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

### Re: editing a correlogram

On Sat, 16 Mar 2019, Ben Tupper wrote:

> Hi,

>

> In this case the spdep::plot.spcor() function, which I think you are

> using, doesn't provide the mechanism for the caller to override the

> default pch value. You can see this by looking at the pl.spcor function

> (as shown way below.) I think it may be easiest for you to simply

> rewrite the function with the plotting parameters assigned as arguments.

Thanks, indeed the ... should be passed through to plotting functions,

and I'll look at doing this. My preference would be to extract the

components of the returned object needed for customised plotting, not

trying to finesse the plot method, which was always meant for guidance,

like other diagnostic plots.

As Rolf said, an example of the code you are using (on a built-in data

set) to show what you want would make things easier, say based on the help

page example. Note that print method returns its calculations invisibly

too.

nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1],

quiet=TRUE)

rn <- as.character(nc.sids$FIPS)

ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal",

package="spData")[1],

region.id=rn)

ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +

sqrt((nc.sids$SID74+1)/nc.sids$BIR74))

tr.SIDS74 <- ft.SID74*sqrt(nc.sids$BIR74)

Ispc <- sp.correlogram(ncCC89_nb, tr.SIDS74, order=8, method="I",

zero.policy=TRUE)

str(Ispc)

str(print(Ispc, "bonferroni"))

Ispc_b <- as.data.frame(print(Ispc, "bonferroni"))

Ispc_b$lag <- 1:8

library(ggplot2)

ggplot(Ispc_b) + geom_point(aes(x=lag, y=estimate))

+ geom_hline(yintercept=0)

Or whatever you feel like doing.

Roger

>

> Cheers,

> Ben

>

>

>> spdep::plot.spcor

> function (x, main, ylab, ylim, ...)

> {

> if (missing(main))

> main <- x$var

> if ((x$method == "I") || (x$method == "C")) {

> lags <- as.integer(rownames(x$res))

> to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

> sd2 <- rep(0, nrow(x$res))

> sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

> if (missing(ylim)) {

> ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

> }

> if (missing(ylab))

> if (x$method == "I")

> ylab <- "Moran's I"

> if (x$method == "C")

> ylab <- "Geary's C"

> plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

> main = main, ylab = ylab, xaxt = "n")

> arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

> length = 0.1, angle = 90)

> arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

> length = 0.1, angle = 90)

> axis(1, at = lags)

> abline(h = x$res[1, 2])

> }

> else {

> res <- as.vector(x$res)

> lags <- as.integer(names(x$res))

> if (missing(ylim))

> ylim <- c(-1, 1)

> if (missing(ylab))

> ylab <- "Spatial autocorrelation"

> plot(lags, res, type = "h", ylim = ylim, main = main,

> ylab = ylab, lwd = 4, xaxt = "n")

> axis(1, at = lags)

> abline(h = 0)

> }

> }

> <bytecode: 0x7fb8799d0e40>

> <environment: namespace:spdep>

>

>

>

>> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <[hidden email]> wrote:

>>

>> I tried the function par() and arguments inside the plot(), but some

>> parameters doesn't change.

>> For example, the argument pch=, which changes the symbols that represents

>> the points in the plot doesn't work.

>>

>>

>> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <[hidden email] <mailto:[hidden email]>>

>> escreveu:

>>

>>> Of course.

>>>

>>> The ... argument to the plot method means that you can use standard

>>> base graphics options to customize as you wish.

>>>

>>> ?par gives the whole list, although they may not all be useful for

>>> correlograms.

>>>

>>> If you have specific questions after you try customizing to your

>>> liking, the list can certainly help with details.

>>>

>>> Sarah

>>>

>>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

>>> <[hidden email]> wrote:

>>>>

>>>> Hello,

>>>>

>>>> I've been tried to use the function "sp.correlogram". After plot the

>>>> correlogram, I would like to edit the grafic's appearence, to publish it.

>>>> It is possible?

>>>>

>>>> Thanks

>>>>

>>>> --

>>>> Leonardo Matheus Servino

>>>> Pós-Graduação em Evolução e Diversidade

>>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>>> Humanas

>>>>

>>>

>>> --

>>> Sarah Goslee (she/her)

>>> http://www.numberwright.com

>>>

>>

>>

>> --

>> Leonardo Matheus Servino

>> Pós-Graduação em Evolução e Diversidade

>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

>>

>> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

>>

>> Rua Arcturus, 3. Jardim Antares

>> 09606-070 São Bernardo do Campo - SP

>>

>> [[alternative HTML version deleted]]

>>

>> _______________________________________________

>> R-sig-Geo mailing list

>> [hidden email] <mailto:[hidden email]>

>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

> Ben Tupper

> Bigelow Laboratory for Ocean Sciences

> 60 Bigelow Drive, P.O. Box 380

> East Boothbay, Maine 04544

> http://www.bigelow.org

>

> Ecological Forecasting: https://eco.bigelow.org/

>

>

>

>

>

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> --

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

> Hi,

>

> In this case the spdep::plot.spcor() function, which I think you are

> using, doesn't provide the mechanism for the caller to override the

> default pch value. You can see this by looking at the pl.spcor function

> (as shown way below.) I think it may be easiest for you to simply

> rewrite the function with the plotting parameters assigned as arguments.

Thanks, indeed the ... should be passed through to plotting functions,

and I'll look at doing this. My preference would be to extract the

components of the returned object needed for customised plotting, not

trying to finesse the plot method, which was always meant for guidance,

like other diagnostic plots.

As Rolf said, an example of the code you are using (on a built-in data

set) to show what you want would make things easier, say based on the help

page example. Note that print method returns its calculations invisibly

too.

nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1],

quiet=TRUE)

rn <- as.character(nc.sids$FIPS)

ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal",

package="spData")[1],

region.id=rn)

ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +

sqrt((nc.sids$SID74+1)/nc.sids$BIR74))

tr.SIDS74 <- ft.SID74*sqrt(nc.sids$BIR74)

Ispc <- sp.correlogram(ncCC89_nb, tr.SIDS74, order=8, method="I",

zero.policy=TRUE)

str(Ispc)

str(print(Ispc, "bonferroni"))

Ispc_b <- as.data.frame(print(Ispc, "bonferroni"))

Ispc_b$lag <- 1:8

library(ggplot2)

ggplot(Ispc_b) + geom_point(aes(x=lag, y=estimate))

+ geom_hline(yintercept=0)

Or whatever you feel like doing.

Roger

>

> Cheers,

> Ben

>

>

>> spdep::plot.spcor

> function (x, main, ylab, ylim, ...)

> {

> if (missing(main))

> main <- x$var

> if ((x$method == "I") || (x$method == "C")) {

> lags <- as.integer(rownames(x$res))

> to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

> sd2 <- rep(0, nrow(x$res))

> sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

> if (missing(ylim)) {

> ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

> }

> if (missing(ylab))

> if (x$method == "I")

> ylab <- "Moran's I"

> if (x$method == "C")

> ylab <- "Geary's C"

> plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

> main = main, ylab = ylab, xaxt = "n")

> arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

> length = 0.1, angle = 90)

> arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

> length = 0.1, angle = 90)

> axis(1, at = lags)

> abline(h = x$res[1, 2])

> }

> else {

> res <- as.vector(x$res)

> lags <- as.integer(names(x$res))

> if (missing(ylim))

> ylim <- c(-1, 1)

> if (missing(ylab))

> ylab <- "Spatial autocorrelation"

> plot(lags, res, type = "h", ylim = ylim, main = main,

> ylab = ylab, lwd = 4, xaxt = "n")

> axis(1, at = lags)

> abline(h = 0)

> }

> }

> <bytecode: 0x7fb8799d0e40>

> <environment: namespace:spdep>

>

>

>

>> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <[hidden email]> wrote:

>>

>> I tried the function par() and arguments inside the plot(), but some

>> parameters doesn't change.

>> For example, the argument pch=, which changes the symbols that represents

>> the points in the plot doesn't work.

>>

>>

>> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <[hidden email] <mailto:[hidden email]>>

>> escreveu:

>>

>>> Of course.

>>>

>>> The ... argument to the plot method means that you can use standard

>>> base graphics options to customize as you wish.

>>>

>>> ?par gives the whole list, although they may not all be useful for

>>> correlograms.

>>>

>>> If you have specific questions after you try customizing to your

>>> liking, the list can certainly help with details.

>>>

>>> Sarah

>>>

>>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

>>> <[hidden email]> wrote:

>>>>

>>>> Hello,

>>>>

>>>> I've been tried to use the function "sp.correlogram". After plot the

>>>> correlogram, I would like to edit the grafic's appearence, to publish it.

>>>> It is possible?

>>>>

>>>> Thanks

>>>>

>>>> --

>>>> Leonardo Matheus Servino

>>>> Pós-Graduação em Evolução e Diversidade

>>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>>> Humanas

>>>>

>>>

>>> --

>>> Sarah Goslee (she/her)

>>> http://www.numberwright.com

>>>

>>

>>

>> --

>> Leonardo Matheus Servino

>> Pós-Graduação em Evolução e Diversidade

>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

>>

>> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

>>

>> Rua Arcturus, 3. Jardim Antares

>> 09606-070 São Bernardo do Campo - SP

>>

>> [[alternative HTML version deleted]]

>>

>> _______________________________________________

>> R-sig-Geo mailing list

>> [hidden email] <mailto:[hidden email]>

>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

> Ben Tupper

> Bigelow Laboratory for Ocean Sciences

> 60 Bigelow Drive, P.O. Box 380

> East Boothbay, Maine 04544

> http://www.bigelow.org

>

> Ecological Forecasting: https://eco.bigelow.org/

>

>

>

>

>

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email]

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

> --

Roger Bivand

Department of Economics, Norwegian School of Economics,

Helleveien 30, N-5045 Bergen, Norway.

voice: +47 55 95 93 55; e-mail: [hidden email]

https://orcid.org/0000-0003-2392-6140

https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway

### Re: editing a correlogram

Hi,

In this case the spdep::plot.spcor() function, which I think you are using, doesn't provide the mechanism for the caller to override the default pch value. You can see this by looking at the pl.spcor function (as shown way below.) I think it may be easiest for you to simply rewrite the function with the plotting parameters assigned as arguments.

Cheers,

Ben

> spdep::plot.spcor

function (x, main, ylab, ylim, ...)

{

if (missing(main))

main <- x$var

if ((x$method == "I") || (x$method == "C")) {

lags <- as.integer(rownames(x$res))

to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

sd2 <- rep(0, nrow(x$res))

sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

if (missing(ylim)) {

ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

}

if (missing(ylab))

if (x$method == "I")

ylab <- "Moran's I"

if (x$method == "C")

ylab <- "Geary's C"

plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

main = main, ylab = ylab, xaxt = "n")

arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

length = 0.1, angle = 90)

arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

length = 0.1, angle = 90)

axis(1, at = lags)

abline(h = x$res[1, 2])

}

else {

res <- as.vector(x$res)

lags <- as.integer(names(x$res))

if (missing(ylim))

ylim <- c(-1, 1)

if (missing(ylab))

ylab <- "Spatial autocorrelation"

plot(lags, res, type = "h", ylim = ylim, main = main,

ylab = ylab, lwd = 4, xaxt = "n")

axis(1, at = lags)

abline(h = 0)

}

}

<bytecode: 0x7fb8799d0e40>

<environment: namespace:spdep>

> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <[hidden email]> wrote:

>

> I tried the function par() and arguments inside the plot(), but some

> parameters doesn't change.

> For example, the argument pch=, which changes the symbols that represents

> the points in the plot doesn't work.

>

>

> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <[hidden email] <mailto:[hidden email]>>

> escreveu:

>

>> Of course.

>>

>> The ... argument to the plot method means that you can use standard

>> base graphics options to customize as you wish.

>>

>> ?par gives the whole list, although they may not all be useful for

>> correlograms.

>>

>> If you have specific questions after you try customizing to your

>> liking, the list can certainly help with details.

>>

>> Sarah

>>

>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

>> <[hidden email]> wrote:

>>>

>>> Hello,

>>>

>>> I've been tried to use the function "sp.correlogram". After plot the

>>> correlogram, I would like to edit the grafic's appearence, to publish it.

>>> It is possible?

>>>

>>> Thanks

>>>

>>> --

>>> Leonardo Matheus Servino

>>> Pós-Graduação em Evolução e Diversidade

>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>> Humanas

>>>

>>

>> --

>> Sarah Goslee (she/her)

>> http://www.numberwright.com

>>

>

>

> --

> Leonardo Matheus Servino

> Pós-Graduação em Evolução e Diversidade

> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

>

> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

>

> Rua Arcturus, 3. Jardim Antares

> 09606-070 São Bernardo do Campo - SP

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email] <mailto:[hidden email]>

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo> Ben Tupper

Bigelow Laboratory for Ocean Sciences

60 Bigelow Drive, P.O. Box 380

East Boothbay, Maine 04544

http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

In this case the spdep::plot.spcor() function, which I think you are using, doesn't provide the mechanism for the caller to override the default pch value. You can see this by looking at the pl.spcor function (as shown way below.) I think it may be easiest for you to simply rewrite the function with the plotting parameters assigned as arguments.

Cheers,

Ben

> spdep::plot.spcor

function (x, main, ylab, ylim, ...)

{

if (missing(main))

main <- x$var

if ((x$method == "I") || (x$method == "C")) {

lags <- as.integer(rownames(x$res))

to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))

sd2 <- rep(0, nrow(x$res))

sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])

if (missing(ylim)) {

ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))

}

if (missing(ylab))

if (x$method == "I")

ylab <- "Moran's I"

if (x$method == "C")

ylab <- "Geary's C"

plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim,

main = main, ylab = ylab, xaxt = "n")

arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2,

length = 0.1, angle = 90)

arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2,

length = 0.1, angle = 90)

axis(1, at = lags)

abline(h = x$res[1, 2])

}

else {

res <- as.vector(x$res)

lags <- as.integer(names(x$res))

if (missing(ylim))

ylim <- c(-1, 1)

if (missing(ylab))

ylab <- "Spatial autocorrelation"

plot(lags, res, type = "h", ylim = ylim, main = main,

ylab = ylab, lwd = 4, xaxt = "n")

axis(1, at = lags)

abline(h = 0)

}

}

<bytecode: 0x7fb8799d0e40>

<environment: namespace:spdep>

> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <[hidden email]> wrote:

>

> I tried the function par() and arguments inside the plot(), but some

> parameters doesn't change.

> For example, the argument pch=, which changes the symbols that represents

> the points in the plot doesn't work.

>

>

> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <[hidden email] <mailto:[hidden email]>>

> escreveu:

>

>> Of course.

>>

>> The ... argument to the plot method means that you can use standard

>> base graphics options to customize as you wish.

>>

>> ?par gives the whole list, although they may not all be useful for

>> correlograms.

>>

>> If you have specific questions after you try customizing to your

>> liking, the list can certainly help with details.

>>

>> Sarah

>>

>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino

>> <[hidden email]> wrote:

>>>

>>> Hello,

>>>

>>> I've been tried to use the function "sp.correlogram". After plot the

>>> correlogram, I would like to edit the grafic's appearence, to publish it.

>>> It is possible?

>>>

>>> Thanks

>>>

>>> --

>>> Leonardo Matheus Servino

>>> Pós-Graduação em Evolução e Diversidade

>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e

>> Humanas

>>>

>>

>> --

>> Sarah Goslee (she/her)

>> http://www.numberwright.com

>>

>

>

> --

> Leonardo Matheus Servino

> Pós-Graduação em Evolução e Diversidade

> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

>

> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

>

> Rua Arcturus, 3. Jardim Antares

> 09606-070 São Bernardo do Campo - SP

>

> [[alternative HTML version deleted]]

>

> _______________________________________________

> R-sig-Geo mailing list

> [hidden email] <mailto:[hidden email]>

> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo> Ben Tupper

Bigelow Laboratory for Ocean Sciences

60 Bigelow Drive, P.O. Box 380

East Boothbay, Maine 04544

http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/

[[alternative HTML version deleted]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]

https://stat.ethz.ch/mailman/listinfo/r-sig-geo