Subscribe to R-sig-geo feed
This is an archive for 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: 48 min 51 sec ago

Re: tpk files

Thu, 04/11/2019 - 10:52
I think the issue is, most GDAL installations don't have the Geopackage raster driver [1] installed by default, which lists "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on my Homebrew installation of GDAL, this driver wasn't built out of the box. If you rebuild GDAL with this additional driver, or find a prebuilt binary which has it, it should be able to open. A simple test is if `gdalinfo EMU.gpkg` returns information about the dataset outside of R.

1. https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=

On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]> wrote:

    What did you try? The instructions at the top say:
   
    "Download 3.3GB tile package and rename extension from .tpk to .zip.
    Extract to get EMU.gpkg"
   
    If that's a valid GeoPackage then `sf` should be able to read it. Not sure
    what might be in the geopackage though, "tile package" sounds like rasters,
    but GeoPackages are generally vector...
   
    I'll try in five minutes when all 3.3Gb have downloaded....
   
    On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
    wrote:
   
    > Hi,
    >
    > I would like to open (and use) a 'tpk' file from arcgis in r.
    > For example:
    >
    > https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
    >
    > I tried raster and sf package, but no luck.
    >
    > Any ideia if we can do this in r?
    >
    > Thank you very much in advance,
    >
    > Best wishes,
    > M.
    >
    >         [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-Geo mailing list
    > [hidden email]
    > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
    >
   
    [[alternative HTML version deleted]]
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
   


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: tpk files

Thu, 04/11/2019 - 10:41
What did you try? The instructions at the top say:

"Download 3.3GB tile package and rename extension from .tpk to .zip.
Extract to get EMU.gpkg"

If that's a valid GeoPackage then `sf` should be able to read it. Not sure
what might be in the geopackage though, "tile package" sounds like rasters,
but GeoPackages are generally vector...

I'll try in five minutes when all 3.3Gb have downloaded....

On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
wrote:

> Hi,
>
> I would like to open (and use) a 'tpk' file from arcgis in r.
> For example:
>
> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>
> I tried raster and sf package, but no luck.
>
> Any ideia if we can do this in r?
>
> Thank you very much in advance,
>
> Best wishes,
> M.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

tpk files

Thu, 04/11/2019 - 09:37
Hi,

I would like to open (and use) a 'tpk' file from arcgis in r.
For example:
https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6

I tried raster and sf package, but no luck.

Any ideia if we can do this in r?

Thank you very much in advance,

Best wishes,
M.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

spreml function

Thu, 04/11/2019 - 07:48
Dear,
I have a problem with “spreml” function in R.
I have a dataset of 26000 observation, like points.
I have imported the shp file in R, and .gal file calculated previously in GEODA.
When i run spreml, an error comes:
Error in as.vector(x) : no method for coercing this S4 class to a vector
below the function:
mapsart <- spreml(fm, data = map, w = maplistw, errors="sr", lag=TRUE, method="BFGS”)


Can you help me to solve this problem?

Regards

Federico



        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: Mosaic

Wed, 04/10/2019 - 19:41
Take a look at the "mosaic" function of the raster package.
Greetings, -- Thiago V. dos Santos
Postdoctoral Research FellowDepartment of Climate and Space Science and EngineeringUniversity of Michigan

    On Thursday, April 4, 2019, 10:46:05 AM EDT, Fatih Kara <[hidden email]> wrote:  
 
 Hi,
I am working with time series Landsat data and creating mosaic images.
What would you offer me to create seamless, color balanced, and smooth mosaic images from multiple Landsat 8 images?

Thanks,

--
Fatih Kara

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
 
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: Common Factors test in R

Wed, 04/10/2019 - 08:30
Thank you very much :)

-----Original Message-----
From: Roger Bivand [mailto:[hidden email]]
Sent: Tuesday, April 9, 2019 12:43 PM
To: Hulényi Martin <[hidden email]>
Cc: [hidden email]
Subject: RE: [R-sig-Geo] Common Factors test in R

On Mon, 8 Apr 2019, Hulényi Martin wrote:

> Thank you very much.
>
>
> I tried it with lrtest, but i got the following error:
>> lrtest(durbin1, spem)
> Error in UseMethod("logLik") :
>  no applicable method for 'logLik' applied to an object of class "splm"
> As you said, it might have been caused by the fact that panel spatial
> error model does not produce log likelihood.

No, you need to attract the attention of the package maintainer, and either contribute the missing method (spml is maximum likelihood based, so does have the value internally, it is simply neither returned, nor made accessible by a logLik() method), or hope that the maintainer might do so.
The package lives on R-Forge at

https://r-forge.r-project.org/projects/splm/

so you can check out the package with anonymous SVN:

svn checkout svn://svn.r-forge.r-project.org/svnroot/splm/

make the changes, build and install locally, check the results, and take svn diff diffs to send back to the maintainer. That is after all how open source software works. You could start in R/spreml.R, checking to see where the optimized objective function values go and where they are returned if they are.

In your case:

> spem$logLik
NULL
> durbin$logLik
[1] -8678.189

Even without working on the code:

debug(spml)
debug(splm:::spfeml)
debug(sperrorlm)

lets you see what is going on to some extent (for spem). In the spem case, opt$objective is assigned to LL, but not returned by sperrorlm() in R/likelihoodsFE.R line 466/467. Had it been, writing logLik() methods would be easier, although seeing which model is nested in which given all the variants is hard.

Further, Durbin impacts are not (yet) available, I think.


>
> Would you say that using slmtest to compare the two models is better?
>

No, it doesn't compare two spatial models, but tests aspatial panel models for many kinds of mis-specification if I understand correctly.

Hope this helps,

Roger

>
> Best regards,
>
> Martin
>
> -----Original Message-----
> From: Roger Bivand [mailto:[hidden email]]
> Sent: Friday, April 5, 2019 9:35 PM
> To: Hulényi Martin <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [R-sig-Geo] Common Factors test in R
>
> On Fri, 5 Apr 2019, Hulényi Martin wrote:
>
>> Hello,
>> I would like to perform a common factor test, conducted using
>> likelihood ratio test on spatial error model and spatial durbin model
>> (both in panel format).
>> I have not found a command in R, that would help me to conduct the test.
>> Hence, I am trying to perform the test manuallly using the splm
>> package and data available in the splm and plm packages.
>
>> Here is my code:
>> library(splm)
>> library(plm)
>>
>> data(Produc, package="plm")
>> data(usaww)
>>
>> Produc <- pdata.frame(Produc, index = c("state", "year"))
>>
>> usaww<- mat2listw(usaww, style="W")
>>
>> Produc$slagUnemp <- slag(Produc$unemp, listw = usaww)
>>
>> durbin <- spml(gsp~unemp + slagUnemp,
>>                data=Produc, listw=usaww,  effect = "twoways",
>>                 model="within", lag=TRUE, spatial.error = "none",
>>                  quiet = FALSE)
>> spem  <- spml(gsp ~ unemp,
>>                data=Produc, listw=usaww,  effect = "twoways",
>>                model="within", lag=FALSE, spatial.error = "b",
>>                quiet = FALSE)
>> Is it correct to take the last value of the function from the console
>> output to compute the likelihood ratio?
>
> Without checking whether the likelihoods are compatible (here probably are), you will not see whether the fitting functions concentrate them, possibly differently. Here both are lag=TRUE but one has spatial.error="none", the other "b", so without reading the code, you can't tell. It would be a good idea if these models had logLik() methods, because then lmtest::lrtest() should work. It then handles the degrees of freedom accounting between the models.
>
> Hope this helps,
>
> Roger
>
>> Meaning, in this example, to calculate 2*(function(non-nested) -
>> function(nested)) = 2*(10261.79 - 10255.74) = 12.1?
>> If it is correct, how can I compute the significance values?
>> If it is not correct, is there a better way to compute this?
>>
>> Autorom tejto spr???vy elektronickej po???ty je Martin Hul???nyi. T???to spr???va je ur???en??? v???lu???ne jej adres???tovi. Inform???cie a ???daje, ktor??? s??? v nej uveden???, alebo ktor??? s??? obsiahnut??? v jej prilo???en???ch s???boroch, m???u by??? inform???ciami alebo ???dajmi chr???nen???mi pod???a platn???ch pr???vnych predpisov v Slovenskej republike. V pr???pade, ak nie ste ur???en??? ako prij???mate??? tejto spr???vy alebo jeho opr???vnen??? z???stupca, upozor???ujeme V???s, ???e inform???cie a ???daje v nej uveden??? nie ste opr???vnen??? sprac???va???, ani ich spr???stupni??? alebo poskytn?????? tretej osobe alebo ich zverejni???. Ak ste nedopatren???m prijali alebo zachytili tuto spr???vu elektronickej po???ty, dovo???ujeme si V???s po???iada???, aby ste ju zaslali sp??? na elektronick??? adresu jej odosielate???a, a aby ste ju n???sledne zmazali zo svojho po??????ta???a a z Va???ej schr???nky elektronickej po???ty. Odosielate??? tejto spr???vy nenesie zodpovednos??? za ???kody sp???soben??? nespr???vnym pou???it???m tejto spr???vy elektronickej po???ty a jej pr???loh.
>>
>> The author of this e-mail message is Martin Hul???nyi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
>> [eco.jpg]       Pred vytla???en???m tohto mailu zv???te pros???m vplyv na ???ivotn??? prostredie. ???akujeme.
>> Please consider the environment before printing this e-mail. Thanks
>>
>> [[alternative HTML version deleted]]
>>
>>
>
> --
> 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
> Autorom tejto správy elektronickej pošty je Martin Hulényi. Táto správa je určená výlučne jej adresátovi. Informácie a údaje, ktoré sú v nej uvedené, alebo ktoré sú obsiahnuté v jej priložených súboroch, môžu byť informáciami alebo údajmi chránenými podľa platných právnych predpisov v Slovenskej republike. V prípade, ak nie ste určený ako prijímateľ tejto správy alebo jeho oprávnený zástupca, upozorňujeme Vás, že informácie a údaje v nej uvedené nie ste oprávnený spracúvať, ani ich sprístupniť alebo poskytnúť tretej osobe alebo ich zverejniť. Ak ste nedopatrením prijali alebo zachytili tuto správu elektronickej pošty, dovoľujeme si Vás požiadať, aby ste ju zaslali späť na elektronickú adresu jej odosielateľa, a aby ste ju následne zmazali zo svojho počítača a z Vašej schránky elektronickej pošty. Odosielateľ tejto správy nenesie zodpovednosť za škody spôsobené nesprávnym použitím tejto správy elektronickej pošty a jej príloh.
>
> The author of this e-mail message is Martin Hulényi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
> [eco.jpg]       Pred vytlačením tohto mailu zvážte prosím vplyv na životné prostredie. Ďakujeme.
> Please consider the environment before printing this e-mail. 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
Autorom tejto správy elektronickej pošty je Martin Hulényi. Táto správa je určená výlučne jej adresátovi. Informácie a údaje, ktoré sú v nej uvedené, alebo ktoré sú obsiahnuté v jej priložených súboroch, môžu byť informáciami alebo údajmi chránenými podľa platných právnych predpisov v Slovenskej republike. V prípade, ak nie ste určený ako prijímateľ tejto správy alebo jeho oprávnený zástupca, upozorňujeme Vás, že informácie a údaje v nej uvedené nie ste oprávnený spracúvať, ani ich sprístupniť alebo poskytnúť tretej osobe alebo ich zverejniť. Ak ste nedopatrením prijali alebo zachytili tuto správu elektronickej pošty, dovoľujeme si Vás požiadať, aby ste ju zaslali späť na elektronickú adresu jej odosielateľa, a aby ste ju následne zmazali zo svojho počítača a z Vašej schránky elektronickej pošty. Odosielateľ tejto správy nenesie zodpovednosť za škody spôsobené nesprávnym použitím tejto správy elektronickej pošty a jej príloh.

The author of this e-mail message is Martin Hulényi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: Simultaneous autoregressive model with temporal dimension

Tue, 04/09/2019 - 16:07
Hi Erin,

You might want to try CARBayesST package as well which has a couple of
autoregressive models it supports too.

Good luck

Jailos

On 09/04/2019 15:55, Mingke Li wrote:
> Dear list,
>
>
> I�m currently working with the simultaneous autoregressive mixed models by �lagsarlm� function in the package �spdep�. I have 5 years� data in 5 separate datasets, and the locations of the sample points (and also the sample size) don't vary from year to year; each sample point has different observed values in different years. Based on the 5 datasets, now I have 5 models, with the common set of predictors but different values (coefficients) from year to year.
>
>
> My question is, how can I get a �generalized� simultaneous autoregressive model for all years? In other words, can I extend my current model to a mixed model like GLMM by introducing the year as a random effect, as implemented in �lme4::glmer�? How should I add in the temporal dimension in the simultaneous autoregressive model?
>
>
> Any thoughts or advice 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
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: Simultaneous autoregressive model with temporal dimension

Tue, 04/09/2019 - 14:46
Thank you Roger. I'll look into the package.

Erin
________________________________
From: Roger Bivand <[hidden email]>
Sent: April 9, 2019 2:30 PM
To: Mingke Li
Cc: R-sig-geo Mailing List
Subject: Re: [R-sig-Geo] Simultaneous autoregressive model with temporal dimension

✉CAUTION: This email comes from outside of UNB. Do not open any links or attachments unless you recognize the sender and know the content is safe.

On Tue, 9 Apr 2019, Mingke Li wrote:

> Dear list,
>
>
> I???m currently working with the simultaneous autoregressive mixed
> models by ???lagsarlm??? function in the package ???spdep???. I have 5
> years??? data in 5 separate datasets, and the locations of the sample
> points (and also the sample size) don't vary from year to year; each
> sample point has different observed values in different years. Based on
> the 5 datasets, now I have 5 models, with the common set of predictors
> but different values (coefficients) from year to year.
>
>
> My question is, how can I get a ???generalized??? simultaneous
> autoregressive model for all years? In other words, can I extend my
> current model to a mixed model like GLMM by introducing the year as a
> random effect, as implemented in ???lme4::glmer???? How should I add in
> the temporal dimension in the simultaneous autoregressive model?
>
Please try the splm package; it is based on the plm package approach, but
includes spatial panel models. As far as I am aware, few of the mixed
models support an mrf spatially structured random effect that is not ICAR.

Hope this helps,

Roger

>
> Any thoughts or advice are welcome. Thank you in advance.
>
>
> Erin
>
>
>       [[alternative HTML version deleted]]
>
>
--
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

Re: Simultaneous autoregressive model with temporal dimension

Tue, 04/09/2019 - 12:30
On Tue, 9 Apr 2019, Mingke Li wrote:

> Dear list,
>
>
> I???m currently working with the simultaneous autoregressive mixed
> models by ???lagsarlm??? function in the package ???spdep???. I have 5
> years??? data in 5 separate datasets, and the locations of the sample
> points (and also the sample size) don't vary from year to year; each
> sample point has different observed values in different years. Based on
> the 5 datasets, now I have 5 models, with the common set of predictors
> but different values (coefficients) from year to year.
>
>
> My question is, how can I get a ???generalized??? simultaneous
> autoregressive model for all years? In other words, can I extend my
> current model to a mixed model like GLMM by introducing the year as a
> random effect, as implemented in ???lme4::glmer???? How should I add in
> the temporal dimension in the simultaneous autoregressive model?
>
Please try the splm package; it is based on the plm package approach, but
includes spatial panel models. As far as I am aware, few of the mixed
models support an mrf spatially structured random effect that is not ICAR.

Hope this helps,

Roger

>
> Any thoughts or advice are welcome. Thank you in advance.
>
>
> Erin
>
>
> [[alternative HTML version deleted]]
>
>
--
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

Creating a mean line plot

Tue, 04/09/2019 - 10:57
Hi there,
I am trying to create a mean line plot that shows the mean of a series of separate line plots that correspond to two climate models. Let's first try getting the mean of two line plots. To create the separate line plots, here is what I did to set up the x and y axis variables:

####Getting cumulative emissions data for x-axis: 1-dimensional ####

#For CanESM model#

ncfname <- "cumulative_emissions_1pctCO2.nc"
Model1 <- nc_open(ncfname)
get <- ncvar_get(Model1, "cum_co2_emi-CanESM2")     #units of terratones of carbon (TtC) for x-axis (140 values)
#For IPSL LR Model#
#Getting cumulative emissions data for x-axis IPSL LR 1pctCO2 IPSL <- ncvar_get(Model1, "cum_co2_emi-IPSL-CM5A-LR")     #units of terratones of carbon (TtC) for x-axis (140 values)

############################################################################################################

#####Getting precipitation data for y-axis - these are 3-dimensional####

#For CanESM2 model#
Model2 <- brick("MaxPrecCCCMACanESM21pctCO2.nc", var="onedaymax")


#For IPSL LR Model#
Model10 <- brick("MaxPrecIPSLIPSL-CM5A-LR1pctCO2.nc", var="onedaymax")
#############################################################################################################
To create plots for a specific location:
lonlat <- cbind(103,3)          #specifies a specific longitude and latitude
Hope2 <- extract(Model2,lonlat)      #CanESM2
Hope6 <- extract(Model10,lonlat)   #start IPSL CM5A LR
plot(get,Hope2, type="l",col="green", lwd="3", xlab="Cumulative CO2 emissions (TtC)", ylab="One-day maximum precipitation (mm/day)", main="One-day maximum precipitation for random location for 1pctCO2 scenario")
lines(IPSL, Hope6, type="l", lwd="3", col="green")
#############################################################################################################
So, the idea would be to create a plot that shows the mean of these two plots. Given what I showed above, how should I go about creating the mean of these two green line plots? Would you have to get the mean of the x-values, and then obtain the mean of the y-values, and then plot these?
Thanks, and any help would be greatly appreciated!
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Simultaneous autoregressive model with temporal dimension

Tue, 04/09/2019 - 09:55
Dear list,


I�m currently working with the simultaneous autoregressive mixed models by �lagsarlm� function in the package �spdep�. I have 5 years� data in 5 separate datasets, and the locations of the sample points (and also the sample size) don't vary from year to year; each sample point has different observed values in different years. Based on the 5 datasets, now I have 5 models, with the common set of predictors but different values (coefficients) from year to year.


My question is, how can I get a �generalized� simultaneous autoregressive model for all years? In other words, can I extend my current model to a mixed model like GLMM by introducing the year as a random effect, as implemented in �lme4::glmer�? How should I add in the temporal dimension in the simultaneous autoregressive model?


Any thoughts or advice 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: Common Factors test in R

Tue, 04/09/2019 - 05:43
On Mon, 8 Apr 2019, Hulényi Martin wrote:

> Thank you very much.
>
>
> I tried it with lrtest, but i got the following error:
>> lrtest(durbin1, spem)
> Error in UseMethod("logLik") :
>  no applicable method for 'logLik' applied to an object of class "splm"
> As you said, it might have been caused by the fact that panel spatial
> error model does not produce log likelihood.

No, you need to attract the attention of the package maintainer, and
either contribute the missing method (spml is maximum likelihood based, so
does have the value internally, it is simply neither returned, nor made
accessible by a logLik() method), or hope that the maintainer might do so.
The package lives on R-Forge at

https://r-forge.r-project.org/projects/splm/

so you can check out the package with anonymous SVN:

svn checkout svn://svn.r-forge.r-project.org/svnroot/splm/

make the changes, build and install locally, check the results, and take
svn diff diffs to send back to the maintainer. That is after all how open
source software works. You could start in R/spreml.R, checking to see
where the optimized objective function values go and where they are
returned if they are.

In your case:

> spem$logLik
NULL
> durbin$logLik
[1] -8678.189

Even without working on the code:

debug(spml)
debug(splm:::spfeml)
debug(sperrorlm)

lets you see what is going on to some extent (for spem). In the spem case,
opt$objective is assigned to LL, but not returned by sperrorlm() in
R/likelihoodsFE.R line 466/467. Had it been, writing logLik() methods
would be easier, although seeing which model is nested in which given all
the variants is hard.

Further, Durbin impacts are not (yet) available, I think.


>
> Would you say that using slmtest to compare the two models is better?
>

No, it doesn't compare two spatial models, but tests aspatial panel models
for many kinds of mis-specification if I understand correctly.

Hope this helps,

Roger

>
> Best regards,
>
> Martin
>
> -----Original Message-----
> From: Roger Bivand [mailto:[hidden email]]
> Sent: Friday, April 5, 2019 9:35 PM
> To: Hulényi Martin <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [R-sig-Geo] Common Factors test in R
>
> On Fri, 5 Apr 2019, Hulényi Martin wrote:
>
>> Hello,
>> I would like to perform a common factor test, conducted using
>> likelihood ratio test on spatial error model and spatial durbin model
>> (both in panel format).
>> I have not found a command in R, that would help me to conduct the test.
>> Hence, I am trying to perform the test manuallly using the splm
>> package and data available in the splm and plm packages.
>
>> Here is my code:
>> library(splm)
>> library(plm)
>>
>> data(Produc, package="plm")
>> data(usaww)
>>
>> Produc <- pdata.frame(Produc, index = c("state", "year"))
>>
>> usaww<- mat2listw(usaww, style="W")
>>
>> Produc$slagUnemp <- slag(Produc$unemp, listw = usaww)
>>
>> durbin <- spml(gsp~unemp + slagUnemp,
>>                data=Produc, listw=usaww,  effect = "twoways",
>>                 model="within", lag=TRUE, spatial.error = "none",
>>                  quiet = FALSE)
>> spem  <- spml(gsp ~ unemp,
>>                data=Produc, listw=usaww,  effect = "twoways",
>>                model="within", lag=FALSE, spatial.error = "b",
>>                quiet = FALSE)
>> Is it correct to take the last value of the function from the console
>> output to compute the likelihood ratio?
>
> Without checking whether the likelihoods are compatible (here probably are), you will not see whether the fitting functions concentrate them, possibly differently. Here both are lag=TRUE but one has spatial.error="none", the other "b", so without reading the code, you can't tell. It would be a good idea if these models had logLik() methods, because then lmtest::lrtest() should work. It then handles the degrees of freedom accounting between the models.
>
> Hope this helps,
>
> Roger
>
>> Meaning, in this example, to calculate 2*(function(non-nested) -
>> function(nested)) = 2*(10261.79 - 10255.74) = 12.1?
>> If it is correct, how can I compute the significance values?
>> If it is not correct, is there a better way to compute this?
>>
>> Autorom tejto spr???vy elektronickej po???ty je Martin Hul???nyi. T???to spr???va je ur???en??? v???lu???ne jej adres???tovi. Inform???cie a ???daje, ktor??? s??? v nej uveden???, alebo ktor??? s??? obsiahnut??? v jej prilo???en???ch s???boroch, m???u by??? inform???ciami alebo ???dajmi chr???nen???mi pod???a platn???ch pr???vnych predpisov v Slovenskej republike. V pr???pade, ak nie ste ur???en??? ako prij???mate??? tejto spr???vy alebo jeho opr???vnen??? z???stupca, upozor???ujeme V???s, ???e inform???cie a ???daje v nej uveden??? nie ste opr???vnen??? sprac???va???, ani ich spr???stupni??? alebo poskytn?????? tretej osobe alebo ich zverejni???. Ak ste nedopatren???m prijali alebo zachytili tuto spr???vu elektronickej po???ty, dovo???ujeme si V???s po???iada???, aby ste ju zaslali sp??? na elektronick??? adresu jej odosielate???a, a aby ste ju n???sledne zmazali zo svojho po??????ta???a a z Va???ej schr???nky elektronickej po???ty. Odosielate??? tejto spr???vy nenesie zodpovednos??? za ???kody sp???soben??? nespr???vnym pou???it???m tejto spr???vy elektronickej po???ty a jej pr???loh.
>>
>> The author of this e-mail message is Martin Hul???nyi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
>> [eco.jpg]       Pred vytla???en???m tohto mailu zv???te pros???m vplyv na ???ivotn??? prostredie. ???akujeme.
>> Please consider the environment before printing this e-mail. Thanks
>>
>> [[alternative HTML version deleted]]
>>
>>
>
> --
> 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
> Autorom tejto správy elektronickej pošty je Martin Hulényi. Táto správa je určená výlučne jej adresátovi. Informácie a údaje, ktoré sú v nej uvedené, alebo ktoré sú obsiahnuté v jej priložených súboroch, môžu byť informáciami alebo údajmi chránenými podľa platných právnych predpisov v Slovenskej republike. V prípade, ak nie ste určený ako prijímateľ tejto správy alebo jeho oprávnený zástupca, upozorňujeme Vás, že informácie a údaje v nej uvedené nie ste oprávnený spracúvať, ani ich sprístupniť alebo poskytnúť tretej osobe alebo ich zverejniť. Ak ste nedopatrením prijali alebo zachytili tuto správu elektronickej pošty, dovoľujeme si Vás požiadať, aby ste ju zaslali späť na elektronickú adresu jej odosielateľa, a aby ste ju následne zmazali zo svojho počítača a z Vašej schránky elektronickej pošty. Odosielateľ tejto správy nenesie zodpovednosť za škody spôsobené nesprávnym použitím tejto správy elektronickej pošty a jej príloh.
>
> The author of this e-mail message is Martin Hulényi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
> [eco.jpg]       Pred vytlačením tohto mailu zvážte prosím vplyv na životné prostredie. Ďakujeme.
> Please consider the environment before printing this e-mail. 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

Re: Common Factors test in R

Mon, 04/08/2019 - 09:18
Thank you very much.


I tried it with lrtest, but i got the following error:
> lrtest(durbin1, spem)
Error in UseMethod("logLik") :
  no applicable method for 'logLik' applied to an object of class "splm"
As you said, it might have been caused by the fact that panel spatial error model does not produce log likelihood.

Would you say that using slmtest to compare the two models is better?


Best regards,

Martin

-----Original Message-----
From: Roger Bivand [mailto:[hidden email]]
Sent: Friday, April 5, 2019 9:35 PM
To: Hulényi Martin <[hidden email]>
Cc: [hidden email]
Subject: Re: [R-sig-Geo] Common Factors test in R

On Fri, 5 Apr 2019, Hulényi Martin wrote:

> Hello,
> I would like to perform a common factor test, conducted using
> likelihood ratio test on spatial error model and spatial durbin model
> (both in panel format).
> I have not found a command in R, that would help me to conduct the test.
> Hence, I am trying to perform the test manuallly using the splm
> package and data available in the splm and plm packages.

> Here is my code:
> library(splm)
> library(plm)
>
> data(Produc, package="plm")
> data(usaww)
>
> Produc <- pdata.frame(Produc, index = c("state", "year"))
>
> usaww<- mat2listw(usaww, style="W")
>
> Produc$slagUnemp <- slag(Produc$unemp, listw = usaww)
>
> durbin <- spml(gsp~unemp + slagUnemp,
>                data=Produc, listw=usaww,  effect = "twoways",
>                 model="within", lag=TRUE, spatial.error = "none",
>                  quiet = FALSE)
> spem  <- spml(gsp ~ unemp,
>                data=Produc, listw=usaww,  effect = "twoways",
>                model="within", lag=FALSE, spatial.error = "b",
>                quiet = FALSE)
> Is it correct to take the last value of the function from the console
> output to compute the likelihood ratio?
Without checking whether the likelihoods are compatible (here probably are), you will not see whether the fitting functions concentrate them, possibly differently. Here both are lag=TRUE but one has spatial.error="none", the other "b", so without reading the code, you can't tell. It would be a good idea if these models had logLik() methods, because then lmtest::lrtest() should work. It then handles the degrees of freedom accounting between the models.

Hope this helps,

Roger

> Meaning, in this example, to calculate 2*(function(non-nested) -
> function(nested)) = 2*(10261.79 - 10255.74) = 12.1?
> If it is correct, how can I compute the significance values?
> If it is not correct, is there a better way to compute this?
>
> Autorom tejto spr???vy elektronickej po???ty je Martin Hul???nyi. T???to spr???va je ur???en??? v???lu???ne jej adres???tovi. Inform???cie a ???daje, ktor??? s??? v nej uveden???, alebo ktor??? s??? obsiahnut??? v jej prilo???en???ch s???boroch, m???u by??? inform???ciami alebo ???dajmi chr???nen???mi pod???a platn???ch pr???vnych predpisov v Slovenskej republike. V pr???pade, ak nie ste ur???en??? ako prij???mate??? tejto spr???vy alebo jeho opr???vnen??? z???stupca, upozor???ujeme V???s, ???e inform???cie a ???daje v nej uveden??? nie ste opr???vnen??? sprac???va???, ani ich spr???stupni??? alebo poskytn?????? tretej osobe alebo ich zverejni???. Ak ste nedopatren???m prijali alebo zachytili tuto spr???vu elektronickej po???ty, dovo???ujeme si V???s po???iada???, aby ste ju zaslali sp??? na elektronick??? adresu jej odosielate???a, a aby ste ju n???sledne zmazali zo svojho po??????ta???a a z Va???ej schr???nky elektronickej po???ty. Odosielate??? tejto spr???vy nenesie zodpovednos??? za ???kody sp???soben??? nespr???vnym pou???it???m tejto spr???vy elektronickej po???ty a jej pr???loh.
>
> The author of this e-mail message is Martin Hul???nyi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
> [eco.jpg]       Pred vytla???en???m tohto mailu zv???te pros???m vplyv na ???ivotn??? prostredie. ???akujeme.
> Please consider the environment before printing this e-mail. Thanks
>
> [[alternative HTML version deleted]]
>
>
--
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
Autorom tejto správy elektronickej pošty je Martin Hulényi. Táto správa je určená výlučne jej adresátovi. Informácie a údaje, ktoré sú v nej uvedené, alebo ktoré sú obsiahnuté v jej priložených súboroch, môžu byť informáciami alebo údajmi chránenými podľa platných právnych predpisov v Slovenskej republike. V prípade, ak nie ste určený ako prijímateľ tejto správy alebo jeho oprávnený zástupca, upozorňujeme Vás, že informácie a údaje v nej uvedené nie ste oprávnený spracúvať, ani ich sprístupniť alebo poskytnúť tretej osobe alebo ich zverejniť. Ak ste nedopatrením prijali alebo zachytili tuto správu elektronickej pošty, dovoľujeme si Vás požiadať, aby ste ju zaslali späť na elektronickú adresu jej odosielateľa, a aby ste ju následne zmazali zo svojho počítača a z Vašej schránky elektronickej pošty. Odosielateľ tejto správy nenesie zodpovednosť za škody spôsobené nesprávnym použitím tejto správy elektronickej pošty a jej príloh.

The author of this e-mail message is Martin Hulényi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
[eco.jpg]       Pred vytlačením tohto mailu zvážte prosím vplyv na životné prostredie. Ďakujeme.
Please consider the environment before printing this e-mail. Thanks
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: [FORGED] Getting averaged variable importance from bootstrap with the cubist models

Mon, 04/08/2019 - 03:23
I am sorry for sections of the code that could adversely affect (e.g.
rm(list = ls())) your computers. Still learning in R. I agree that the code
could have been better presented and will work on it .
Best,
Ozias

On Mon, 8 Apr 2019 at 09:52, Roman Luštrik <[hidden email]> wrote:

> Running reproducible examples in clear sessions should be something that is
> not very hard to do, far far away from (semi)production environment.
> Also, people might not stand idly while their work computer is being
> damaged in a fire-hazardous way.
>
> Cheers,
> Roman
>
> On Mon, Apr 8, 2019 at 4:09 AM Rolf Turner <[hidden email]>
> wrote:
>
> > On 8/04/19 3:52 AM, Hounkpatin Ozias wrote:
> >
> > <SNIP>
> >
> > > rm(list = ls())
> >
> > <SNIP>
> >
> > NOOOOOOOOOOOOOOOOOO!!!!  Don't do this to other people!!!  As (I think
> > it was) Jenny Bryan said at the NZSA Conference in December 2017:  "If
> > you do this I will come to your office and set fire to your computer!!!"
> >
> > cheers,
> >
> > Rolf Turner
> >
> > --
> > Honorary Research Fellow
> > Department of Statistics
> > University of Auckland
> > Phone: +64-9-373-7599 ext. 88276
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>
> --
> In God we trust, all others bring data.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: Monte Carlo Simulation

Mon, 04/08/2019 - 02:55
On Sat, 6 Apr 2019, Leonardo Matheus Servino wrote:

> Hello, group.
>
> I would like to make a monte carlo simulation in the residuals of a gls
> model, to verify the spatial autocorrelation. Is it possible?

Could you please be more specific, perhaps adding a toy example? Have you
looked at ?lme4::mcmcsamp for an explanation of some issues? Could you
rather fit a variogram model random effect in the correlation argument and
see whether it is worth retaining? Simulating from dependent data is not
without problems.

Roger

>
> Thanks
>
> [[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: [FORGED] Getting averaged variable importance from bootstrap with the cubist models

Mon, 04/08/2019 - 02:51
Running reproducible examples in clear sessions should be something that is
not very hard to do, far far away from (semi)production environment.
Also, people might not stand idly while their work computer is being
damaged in a fire-hazardous way.

Cheers,
Roman

On Mon, Apr 8, 2019 at 4:09 AM Rolf Turner <[hidden email]> wrote:

> On 8/04/19 3:52 AM, Hounkpatin Ozias wrote:
>
> <SNIP>
>
> > rm(list = ls())
>
> <SNIP>
>
> NOOOOOOOOOOOOOOOOOO!!!!  Don't do this to other people!!!  As (I think
> it was) Jenny Bryan said at the NZSA Conference in December 2017:  "If
> you do this I will come to your office and set fire to your computer!!!"
>
> cheers,
>
> Rolf Turner
>
> --
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
In God we trust, all others bring data.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: [FORGED] Getting averaged variable importance from bootstrap with the cubist models

Sun, 04/07/2019 - 21:08
On 8/04/19 3:52 AM, Hounkpatin Ozias wrote:

<SNIP>

> rm(list = ls())

<SNIP>

NOOOOOOOOOOOOOOOOOO!!!!  Don't do this to other people!!!  As (I think
it was) Jenny Bryan said at the NZSA Conference in December 2017:  "If
you do this I will come to your office and set fire to your computer!!!"

cheers,

Rolf Turner

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Getting averaged variable importance from bootstrap with the cubist models

Sun, 04/07/2019 - 10:52
Dear All,

I am using a Bootstrapping approach with the Cubist model. It is possible
to get the variable importance (percentages  in variable usage in the
models) after running the models. For each run of the model based on the
random sampling, the variable importance is
different. A robust estimate may be determined by taking the average of all
the percentages of usage for each specific variable involved in the models.
For this purpose, I have (1) saved each model to disk,  (2) read back in R
each model, (2) got the variable importance
 for each model, (3) got a final table with all the models and the
percentages allocated by each model for the variables. the final table I am
expecting should like the table below. It is possible to do  it manually by
calling in each model but the workload is too high when you have 100 number
of bootstraps.

Here below a reproducible example with dataset from the ithir package. I
have limited the bootstrap to 3 for quick run. Also below I have shown how
I could get the table focusing on one model at a time.

Is there anyway to have all the models called in a loop, and extract the
variable importance for each model and arrange them finally
to get the table instead of doing it for each model separately ? I am
actually running the models 100 times.

I will appreciate any help.

Expected table-------------------------------------------------------
Variables VImp cubist.type
MRVBF 62.5 Vimp.cubist1
AACN 72.5 Vimp.cubist1
NDVI 41 Vimp.cubist1
Mid_Slope_Positon 24.5 Vimp.cubist1
Landsat_Band1 24 Vimp.cubist1
Terrain_Ruggedness_Index 44.5 Vimp.cubist1
TWI 42 Vimp.cubist1
Hillshading 41.5 Vimp.cubist1
Slope 41.5 Vimp.cubist1
Light_insolation 16 Vimp.cubist1
Elevation 11.5 Vimp.cubist1
MRVBF 81.5 Vimp.cubist2
Elevation 48.5 Vimp.cubist2
NDVI 62.5 Vimp.cubist2
Mid_Slope_Positon 43 Vimp.cubist2
TWI 54.5 Vimp.cubist2
AACN 41.5 Vimp.cubist2
Landsat_Band1 38.5 Vimp.cubist2
Hillshading 37.5 Vimp.cubist2
Terrain_Ruggedness_Index 27 Vimp.cubist2
Slope 21 Vimp.cubist2
Light_insolation 20.5 Vimp.cubist2
MRVBF 78 Vimp.cubist3
Hillshading 62 Vimp.cubist3
TWI 57 Vimp.cubist3
Terrain_Ruggedness_Index 55.5 Vimp.cubist3
AACN 55 Vimp.cubist3
Light_insolation 38.5 Vimp.cubist3
NDVI 50.5 Vimp.cubist3
Slope 49 Vimp.cubist3
Landsat_Band1 47.5 Vimp.cubist3
Mid_Slope_Positon 45.5 Vimp.cubist3
Elevation 31.5 Vimp.cubist3


## REPRODUCIBLE EXAMPLE

rm(list = ls())

library(Cubist)
library(ithir) # install.packages("ithir", repos="
http://R-Forge.R-project.org <http://r-forge.r-project.org/>")
library(caret)

#Set a working directory
setwd("")

# Point data
data(HV_subsoilpH)

# subset data for modeling
set.seed(123)
training <- sample(nrow(HV_subsoilpH), 0.7 * nrow(HV_subsoilpH))
cDat <- HV_subsoilpH[training, ]
vDat <- HV_subsoilpH[-training, ]

#Create folder to store models
dir.create("models", recursive = TRUE)

# Number of bootstraps
nbag <- 3

# Fit cubist models for each bootstrap
for (i in 1:nbag) {
  trainingREP <- sample.int(nrow(cDat), 1.0 * nrow(cDat),replace = TRUE)
  fit_cubist <- cubist(x = cDat[trainingREP,
                                c("Terrain_Ruggedness_Index",
                                  "AACN", "Landsat_Band1", "Elevation",
"Hillshading",
                                  "Light_insolation", "Mid_Slope_Positon",
"MRVBF", "NDVI",
                                  "TWI", "Slope")],
                       y = cDat$pH60_100cm[trainingREP],
cubistControl(rules = 5,
                                       extrapolation = 5), committees = 3)

  modelFile <-paste(getwd(), "./models/",sep = "", "bootMod_", i,".rds")
  saveRDS(object = fit_cubist, file = modelFile)
}


# List all files in directory
c.models <- list.files(path = paste(getwd(),"./models",
                      sep = ""), pattern = "\\.rds$", full.names = TRUE)

#Reads the models
fit_cubist<-  readRDS(c.models[i])
varImp(fit_cubist) # But it only give variable importance for the final
model

#Alternatively, I can call the model one by one and apply varImp
#Call models one by one
fit_cubist1<-  readRDS("./models/bootMod_1.rds")
fit_cubist2<-  readRDS("./models/bootMod_2.rds")
fit_cubist3<-  readRDS("./models/bootMod_3.rds")

#Apply varImp on each model
VImp1<-varImp(fit_cubist1)
VImp2<-varImp(fit_cubist2)
VImp3<-varImp(fit_cubist3)

#Get a data frame for each variable importance
cub.VImp1<-as.data.frame(VImp1[1])
names(cub.VImp1)[1]<-"VImp"
cub.VImp2<-as.data.frame(VImp2[1])
names(cub.VImp2)[1]<-"VImp"
cub.VImp3<-as.data.frame(VImp3[1])
names(cub.VImp3)[1]<-"VImp"

#Create a column for each variable importance related to each model
cub.VImp1$cubist.type<-"Vimp.cubist1"
cub.VImp2$cubist.type<-"Vimp.cubist2"
cub.VImp3$cubist.type<-"Vimp.cubist3"

#Join the row names to each dataframe
cub.VImp1<-setNames(cbind(rownames(cub.VImp1),
cub.VImp1),c("Variables","VImp","cubist.model"))
cub.VImp2<-setNames(cbind(rownames(cub.VImp2),
cub.VImp2),c("Variables","VImp","cubist.model"))
cub.VImp3<-setNames(cbind(rownames(cub.VImp3),
cub.VImp3),c("Variables","VImp","cubist.model"))

#Bind all the models df together by rows
All.VarImp<-bind_rows(cub.VImp1,cub.VImp2,cub.VImp3)

#Get the average of variable importance for each variable
mean.VarImp <- ddply(All.VarImp, .(Variables), summarise,
               mean = mean(VImp),
               sd   = sd( VImp))
mean.VarImp


Ozias Hounkpatin

Post doc



Sveriges lantbruksuniversitet

Swedish University of Agricultural Sciences



Dept. of Soil and Environment

PO Box 1234, SE-123 45 Uppsala

Visiting address: Lennart Hjems våg 9

Phone: +46 18 67 12 51, Mobile: +46 72 207 85 62

[hidden email] , www.slu.se

Hounkpatin Ozias <[hidden email]>
17:41 (10 minutes ago)
to R-sig-geo
ReplyForward
<https://drive.google.com/u/0/settings/storage?hl=en-GB>
<https://www.google.com/intl/en-GB/policies/terms/>
<https://www.google.com/intl/en-GB/policies/privacy/>
<https://www.google.com/gmail/about/policy/>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Monte Carlo Simulation

Fri, 04/05/2019 - 18:31
Hello, group.

I would like to make a monte carlo simulation in the residuals of a gls
model, to verify the spatial autocorrelation. Is it possible?

Thanks

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

spdep: model fitting functions moving to new package spatialreg

Fri, 04/05/2019 - 15:06
I am sorry to have to disturb users of the spdep package who have used it
to fit spatial regression models.

The package has become large and hard to maintain. Functions to create and
handle spatial neighbours, and to test for spatial autocorrelation remain
in spdep. Functions to fit spatial regression models are now in the new
package spatialreg (1.1-3 on CRAN). They are _also_ in spdep 1.1-2 now on
its way to CRAN.

If you use spdep as you have done until now, the versions of the functions
in spdep will be used if you have not installed spatialreg, and you will
see warnings that the spdep functions are deprecated. If you have
installed spatialreg, you will see warnings too, but the estimation will
be done using the spatialreg namespace internally. If you install
spatialreg, and attach spdep followed by spatialreg, you will see that the
spdep model fitting functions are masked by their equivalents in
spatialreg.

During May, I expect to make the spdep versions of the model fitting
functions defunct, gradually removing the masking problem. Most use of
spdep by packages importing its namespace or attaching it only use
functions creating and handling neighbour objects. The division of
functionalities will benefit that majority of packages, because spdep will
load faster and draw in fewer packages on which it depends. However,
improving workflows for users of those packages means that users of model
fitting functions will need to use spdep for neighbour objects and in
addition spatialreg for model estimation and evaluation.

This split was discussed on github:

https://github.com/r-spatial/spdep/issues/31

and twitter: https://twitter.com/RogerBivand/status/1105023658341351424

Please take up issues on github:

https://github.com/r-spatial/spdep/issues
https://github.com/r-spatial/spatialreg/issues

on this list or by direct email.

I hope that this reconfiguration will improve the software going forward.

Grateful for feedback,

Roger

--
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

Pages