Re: [R-sig-Geo] BIG DATABASE

2018-05-25 Thread Javier Moreira
Thanks so much!

El vie., 25 may. 2018 9:51, Roger Bivand <roger.biv...@nhh.no> escribió:

> On Fri, 25 May 2018, Javier Moreira wrote:
>
> > Can I use this answer to ask exactly for what it's mentioned.
> > R and Postgis mostly for Easter files.
> > Can you point books, online courses, tutorials, GitHub pages, anything,
> to
> > better understand this?
> > I had been struggling to find info.
>
> For rpostgis, see:
>
> https://journal.r-project.org/archive/2018/RJ-2018-025/index.html
>
> and the supplementary material linked there to replicate the results in
> the online article (should be in the 2018-1 issue).
>
> Roger
>
> >
> > Thanks!
> >
> > El vie., 25 may. 2018 1:35, Tom Philippi <tephili...@gmail.com>
> escribió:
> >
> >> What Roger said (as always).
> >>
> >> Note that if you use tidyverse and magrittr, dplyr and tidyverse tools
> work
> >> well with databases via DBI.  sqldf also works with multiple SQL
> database
> >> backends if you're an ol dog like me and don't use tidyverse much.
> >>
> >> Also, since this is r-sig-*GEO*, note that postgreSQL has postGIS for
> >> spatial data, which does far more than the automatic tiling of large
> >> rasters in package raster.  I'm seeing wonderful performance working
> with a
> >> 340M observation >100GB dataset of bird observation data in R via
> postGIS,
> >> even with "only" 32GB RAM and constrained to running win7, not
> linux/unix.
> >>
> >> One alternative is that if your database is running on massive hardware
> >> (tons of memory, many cores, etc.), it is possible to run R within both
> >> postgreSQL and now MS SQL Server, the first free, the second an
> additional
> >> cost add-on, and both usually at the cost of painful negotiations with
> DA
> >> administrators for permissions to run your ad hoc R code on their SQL
> >> server.  If you have the hardware, you can even run R with hadoop,
> although
> >> I've never done that with spatial data.
> >>
> >> Tom 0
> >>
> >>
> >> On Thu, May 24, 2018 at 5:04 AM, Roger Bivand <roger.biv...@nhh.no>
> wrote:
> >>
> >>> On Thu, 24 May 2018, Yaya Bamba wrote:
> >>>
> >>> Thanks to all of you. I will try with the package  RMySQL and see.
> >>>>
> >>>
> >>> Maybe look more generally through the packages depending on and
> importing
> >>> from DBI (https://cran.r-project.org/package=DBI) to see what is
> >>> available - there are many more than RMySQL.
> >>>
> >>> and use the Official Statistics and HPC Task Views:
> >>>
> >>> https://cran.r-project.org/view=OfficialStatistics
> >>>
> >>> https://cran.r-project.org/view=HighPerformanceComputing
> >>>
> >>> to see how typical workflows (not necessarily DB-based) can be handled.
> >>> The HPC TV has a section on large memory and out-of-memory approaches.
> If
> >>> your data are spatial in raster format, the raster package provides
> some
> >>> out-of-memory functionality. In sf, spatial vector data may be read
> from
> >>> databases too.
> >>>
> >>> Roger
> >>>
> >>>
> >>>
> >>>> 2018-05-24 11:33 GMT+00:00 Andres Diaz Loaiza <madi...@gmail.com>:
> >>>>
> >>>> Hello Yaya,
> >>>>>
> >>>>> Many years ago I work with a database in MySQL connected to R through
> >> the
> >>>>> package RMySQL​. The data was stored in the MySQL and I was
> connecting
> >>>>> and
> >>>>> using the data from R
> >>>>>
> >>>>> you should have a look in:
> >>>>>
> >>>>> https://cran.r-project.org/web/packages/RMySQL/index.html
> >>>>>
> >>>>> Cheers,
> >>>>>
> >>>>> Andres
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>> --
> >>> Roger Bivand
> >>> Department of Economics, Norwegian School of Economics,
> >>> Helleveien 30, N-5045 Bergen, Norway.
> >>> voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no
> >>> http://orcid.org/-0003-2392-6140
> >>> https://scholar.google.no/citations?user=AWeghB0J=en
> >>> ___
> >>> R-sig-Geo mailing list
> >>> R-sig-Geo@r-project.org
> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>>
> >>>
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ___
> >> R-sig-Geo mailing list
> >> R-sig-Geo@r-project.org
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>
> >
> >   [[alternative HTML version deleted]]
> >
> > ___
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > 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: roger.biv...@nhh.no
> http://orcid.org/-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0J=en

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] BIG DATABASE

2018-05-25 Thread Javier Moreira
Can I use this answer to ask exactly for what it's mentioned.
R and Postgis mostly for Easter files.
Can you point books, online courses, tutorials, GitHub pages, anything, to
better understand this?
I had been struggling to find info.

Thanks!

El vie., 25 may. 2018 1:35, Tom Philippi  escribió:

> What Roger said (as always).
>
> Note that if you use tidyverse and magrittr, dplyr and tidyverse tools work
> well with databases via DBI.  sqldf also works with multiple SQL database
> backends if you're an ol dog like me and don't use tidyverse much.
>
> Also, since this is r-sig-*GEO*, note that postgreSQL has postGIS for
> spatial data, which does far more than the automatic tiling of large
> rasters in package raster.  I'm seeing wonderful performance working with a
> 340M observation >100GB dataset of bird observation data in R via postGIS,
> even with "only" 32GB RAM and constrained to running win7, not linux/unix.
>
> One alternative is that if your database is running on massive hardware
> (tons of memory, many cores, etc.), it is possible to run R within both
> postgreSQL and now MS SQL Server, the first free, the second an additional
> cost add-on, and both usually at the cost of painful negotiations with DA
> administrators for permissions to run your ad hoc R code on their SQL
> server.  If you have the hardware, you can even run R with hadoop, although
> I've never done that with spatial data.
>
> Tom 0
>
>
> On Thu, May 24, 2018 at 5:04 AM, Roger Bivand  wrote:
>
> > On Thu, 24 May 2018, Yaya Bamba wrote:
> >
> > Thanks to all of you. I will try with the package  RMySQL and see.
> >>
> >
> > Maybe look more generally through the packages depending on and importing
> > from DBI (https://cran.r-project.org/package=DBI) to see what is
> > available - there are many more than RMySQL.
> >
> > and use the Official Statistics and HPC Task Views:
> >
> > https://cran.r-project.org/view=OfficialStatistics
> >
> > https://cran.r-project.org/view=HighPerformanceComputing
> >
> > to see how typical workflows (not necessarily DB-based) can be handled.
> > The HPC TV has a section on large memory and out-of-memory approaches. If
> > your data are spatial in raster format, the raster package provides some
> > out-of-memory functionality. In sf, spatial vector data may be read from
> > databases too.
> >
> > Roger
> >
> >
> >
> >> 2018-05-24 11:33 GMT+00:00 Andres Diaz Loaiza :
> >>
> >> Hello Yaya,
> >>>
> >>> Many years ago I work with a database in MySQL connected to R through
> the
> >>> package RMySQL​. The data was stored in the MySQL and I was connecting
> >>> and
> >>> using the data from R
> >>>
> >>> you should have a look in:
> >>>
> >>> https://cran.r-project.org/web/packages/RMySQL/index.html
> >>>
> >>> Cheers,
> >>>
> >>> Andres
> >>>
> >>>
> >>
> >>
> >>
> >>
> > --
> > Roger Bivand
> > Department of Economics, Norwegian School of Economics,
> > Helleveien 30, N-5045 Bergen, Norway.
> > voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no
> > http://orcid.org/-0003-2392-6140
> > https://scholar.google.no/citations?user=AWeghB0J=en
> > ___
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] testing nlme models for spatial correlation

2017-08-02 Thread Javier Moreira
Thanks,
I try the random effects to the level of TRATAMIENTO, and works fine.
For the cross or nested, what hapens is, if you dont use all the 3 randoms
the degrees of freedom arent correct.
Thanks for your time.



El 2 ago. 2017 5:52 a. m., "Thierry Onkelinx" <thierry.onkel...@inbo.be>
escribió:

> Dear Javier,
>
> It looks like you have only one observation for each combination of BLOQUE/
> AMBIENTE/ TRATAMIENTO/ SUBMUESTREO. That is an observation level random
> effect (OLRE) which doesn't make sense with a Gaussian distribution. The
> ORLE and the residual would model the exact same thing. Model2 doesn't make
> sense.
>
> Two other problems: BLOQUE has only 3 levels and AMBIENTE and TRAITAMIENTO
> are both used in the fixed and the random part. See
> http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#
> should-i-treat-factor-xxx-as-fixed-or-random. AMBIENTE and TRAITAMIENTO
> are rather crossed than nested. See http://bbolker.github.io/
> mixedmodels-misc/glmmFAQ.html#nested-or-crossed and
> https://www.muscardinus.be/2017/07/lme4-random-effects/
>
> I can't reproduce the error you get on model4. The output seems
> reasonable, although it has the same problems as model2.
>
> Your dataset is suitable for the SPDE approach in INLA.
>
> I would recommend that you consult a (local) statistician.
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2017-08-01 17:03 GMT+02:00 Javier Moreira <javiermore...@gmail.com>:
>
>> ​​Sorry, the error is
>>
>> Error in corFactor.corSpatial(object) :
>>   NA/NaN/Inf in foreign function call (arg 1)
>> In addition: Warning messages:
>> 1: In min(unlist(attr(object, "covariate"))) :
>>   no non-missing arguments to min; returning Inf
>> 2: In min(unlist(attr(object, "covariate"))) :
>>   no non-missing arguments to min; returning Inf
>>
>> and i attach the data to this mail.
>> ​
>>  base_modelo3.csv
>> <https://drive.google.com/file/d/0B6YImu-ZATe4bEFKTlAxci1PNW8/view?usp=drive_web>
>> ​
>> thanks!
>>
>> 2017-08-01 11:42 GMT-03:00 Thierry Onkelinx <thierry.onkel...@inbo.be>:
>>
>>> Dear Javier,
>>>
>>> Your problem is hard to understand without a reproducible example. You
>>> only gives the code, not the data nor the error message.
>>>
>>> Best regards,
>>>
>>> ir. Thierry Onkelinx
>>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>>> and Forest
>>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>>> Kliniekstraat 25
>>> 1070 Anderlecht
>>> Belgium
>>>
>>> To call in the statistician after the experiment is done may be no more
>>> than asking him to perform a post-mortem examination: he may be able to say
>>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does not
>>> ensure that a reasonable answer can be extracted from a given body of data.
>>> ~ John Tukey
>>>
>>> 2017-08-01 16:36 GMT+02:00 Javier Moreira <javiermore...@gmail.com>:
>>>
>>>> Thanks Thierry,
>>>> I would check that info.
>>>> Any ideas why if i choose the finest level of random effects as
>>>> /SUBMUESTREO and run model 4 (with correlation) wont let me?
>>>> If i undesrtand you wel, you adress more the second question i made, im
>>>> all right?
>>>> Thanks!
>>>>
>>>>
>>>> El 1 ago. 2017 8:10 a. m., "Thierry Onkelinx" <thierry.onkel...@inbo.be>
>>>> escribió:
>>>>
>>>> Dear Javier,
>>>>
>>>> The correlation structure in nlme only works on the residuals within
>>>> the finest level of random effect. Observations in different random effect
>>>>

Re: [R-sig-Geo] testing nlme models for spatial correlation

2017-08-01 Thread Javier Moreira
​​Sorry, the error is

Error in corFactor.corSpatial(object) :
  NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning messages:
1: In min(unlist(attr(object, "covariate"))) :
  no non-missing arguments to min; returning Inf
2: In min(unlist(attr(object, "covariate"))) :
  no non-missing arguments to min; returning Inf

and i attach the data to this mail.
​
 base_modelo3.csv
<https://drive.google.com/file/d/0B6YImu-ZATe4bEFKTlAxci1PNW8/view?usp=drive_web>
​
thanks!

2017-08-01 11:42 GMT-03:00 Thierry Onkelinx <thierry.onkel...@inbo.be>:

> Dear Javier,
>
> Your problem is hard to understand without a reproducible example. You
> only gives the code, not the data nor the error message.
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2017-08-01 16:36 GMT+02:00 Javier Moreira <javiermore...@gmail.com>:
>
>> Thanks Thierry,
>> I would check that info.
>> Any ideas why if i choose the finest level of random effects as
>> /SUBMUESTREO and run model 4 (with correlation) wont let me?
>> If i undesrtand you wel, you adress more the second question i made, im
>> all right?
>> Thanks!
>>
>>
>> El 1 ago. 2017 8:10 a. m., "Thierry Onkelinx" <thierry.onkel...@inbo.be>
>> escribió:
>>
>> Dear Javier,
>>
>> The correlation structure in nlme only works on the residuals within the
>> finest level of random effect. Observations in different random effect are
>> independent.
>>
>> Have a look at the INLA package (http://www.r-inla.org). INLA allows for
>> correlated random effects. So you have spatial correlation among the random
>> effects (instead of among residuals). INLA has options for correlations
>> along a 2D regular grid, a neighbourhood graph or a mesh. If you want an
>> book on this, I recommend Zuur et al (2017) Beginner's Guide to Spatial,
>> Temporal and Spatial-Temporal Ecological Data Analysis with R-INLA.
>>
>> Best regards,
>>
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>> and Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of data.
>> ~ John Tukey
>>
>> 2017-08-01 11:31 GMT+02:00 Javier Moreira <javiermore...@gmail.com>:
>>
>>> hi,
>>> im trying to generate different models to account for spatial
>>> correlation.
>>> Im using nlme package, and mixed models, in order to compare two models,
>>> one that doesnt include the spatial correlation and one that does.
>>>
>>> Its a nested design, one that has 4 leves,
>>> BLOQUE/ AMBIENTE/ TRATAMIENTO/ SUBMUESTREO
>>> Its a harvest set data, with multiple point of data/ treatment, so the
>>> last
>>> level account for another term in the error for "sub-muestreo".
>>>
>>> My first problem its, when i try to add de correlation term to the
>>> model, i
>>> cant, when the random effects are taken to the level /SUBMUESTREO, and i
>>> have to leave it to the level of TRATAMIENTO.
>>> When i do that, i have 2 differences between models, the term accounting
>>> for sub-muestreo, and the spatial correlation.
>>>
>>> #MODELO 2##
>>> attach(base_modelo3)
>>> str(base_modelo3)
>>> data1=base_modelo3
>>> str(data1)
>>> data1=groupedData(REND.~1|BLOQUE/AMBIENTE/TRATAMIENTO/SUBMUESTREO,
>>> data=data1, units=list(y="(to

Re: [R-sig-Geo] testing nlme models for spatial correlation

2017-08-01 Thread Javier Moreira
Thanks Thierry,
I would check that info.
Any ideas why if i choose the finest level of random effects as
/SUBMUESTREO and run model 4 (with correlation) wont let me?
If i undesrtand you wel, you adress more the second question i made, im all
right?
Thanks!

El 1 ago. 2017 8:10 a. m., "Thierry Onkelinx" <thierry.onkel...@inbo.be>
escribió:

Dear Javier,

The correlation structure in nlme only works on the residuals within the
finest level of random effect. Observations in different random effect are
independent.

Have a look at the INLA package (http://www.r-inla.org). INLA allows for
correlated random effects. So you have spatial correlation among the random
effects (instead of among residuals). INLA has options for correlations
along a 2D regular grid, a neighbourhood graph or a mesh. If you want an
book on this, I recommend Zuur et al (2017) Beginner's Guide to Spatial,
Temporal and Spatial-Temporal Ecological Data Analysis with R-INLA.

Best regards,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2017-08-01 11:31 GMT+02:00 Javier Moreira <javiermore...@gmail.com>:

> hi,
> im trying to generate different models to account for spatial correlation.
> Im using nlme package, and mixed models, in order to compare two models,
> one that doesnt include the spatial correlation and one that does.
>
> Its a nested design, one that has 4 leves,
> BLOQUE/ AMBIENTE/ TRATAMIENTO/ SUBMUESTREO
> Its a harvest set data, with multiple point of data/ treatment, so the last
> level account for another term in the error for "sub-muestreo".
>
> My first problem its, when i try to add de correlation term to the model, i
> cant, when the random effects are taken to the level /SUBMUESTREO, and i
> have to leave it to the level of TRATAMIENTO.
> When i do that, i have 2 differences between models, the term accounting
> for sub-muestreo, and the spatial correlation.
>
> #MODELO 2##
> attach(base_modelo3)
> str(base_modelo3)
> data1=base_modelo3
> str(data1)
> data1=groupedData(REND.~1|BLOQUE/AMBIENTE/TRATAMIENTO/SUBMUESTREO,
> data=data1, units=list(y="(ton/ha)"))
> data1$TRATAMIENTO =factor(data1$TRATAMIENTO)
> data1$BLOQUE =factor(data1$BLOQUE)
> data1$AMBIENTE =factor(data1$AMBIENTE)
>
> modelo2_MM<-lme(REND.~1+TRATAMIENTO*AMBIENTE,
> random=~1|BLOQUE/AMBIENTE/TRATAMIENTO/SUBMUESTREO,
> weights=varComb(varIdent(form=~1|TRATAMIENTO)),
> data=data1,
> control=lmeControl(niterEM=150,msMaxIter=200))
> summary(modelo2_MM)
> anova(modelo2_MM)
>
> ##MODELO 4##
>
> modelo4_MM<-lme(REND.~1+TRATAMIENTO*AMBIENTE,
> random=~1|BLOQUE/AMBIENTE/TRATAMIENTO,
> weights=varComb(varIdent(form=~1|TRATAMIENTO)),
> correlation=corExp(form=~X+Y,nugget=T),
> data=data1,
> control=lmeControl(niterEM=150,msMaxIter=200))
> summary(modelo4_MM)
> anova(modelo4_MM)
>
> My second problem is, that i need to get the specific parameter for the
> error term that belongs to the spatial correlation, in order to map it. For
> what i watch, what lme does is send it to the general error, and so, what i
> could do is make the differences between the residuals of these two models.
> so, its essetial to get the exact same model, except for the correlation
> structure.
> If anybody knows how to get the specific term of error accounting for the
> correlation, it would be wonderful.
>
> E24=residuals(modelo24_3,type = "response")
> E40=residuals(modelo4_MM,type = "response")
> EE=E24-E40
> post=data.frame(E24,E40,EE,data1$X,data1$Y)
>
> coordinates(post)<-c("data1.X","data1.Y")
> coor_post<-coordinates(post)
>
> bubble(post,"E24",main="residuos modelo 2")
> bubble(post,"E40",main="residuos modelo 4")
> bubble(post,"EE",main="Est.espacial removida por Modelo 4")
>
> thanks!
>
> --
> Javier Moreira de Souza
> Ingeniero Agrónomo
> 099 406 006
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[R-sig-Geo] testing nlme models for spatial correlation

2017-08-01 Thread Javier Moreira
hi,
im trying to generate different models to account for spatial correlation.
Im using nlme package, and mixed models, in order to compare two models,
one that doesnt include the spatial correlation and one that does.

Its a nested design, one that has 4 leves,
BLOQUE/ AMBIENTE/ TRATAMIENTO/ SUBMUESTREO
Its a harvest set data, with multiple point of data/ treatment, so the last
level account for another term in the error for "sub-muestreo".

My first problem its, when i try to add de correlation term to the model, i
cant, when the random effects are taken to the level /SUBMUESTREO, and i
have to leave it to the level of TRATAMIENTO.
When i do that, i have 2 differences between models, the term accounting
for sub-muestreo, and the spatial correlation.

#MODELO 2##
attach(base_modelo3)
str(base_modelo3)
data1=base_modelo3
str(data1)
data1=groupedData(REND.~1|BLOQUE/AMBIENTE/TRATAMIENTO/SUBMUESTREO,
data=data1, units=list(y="(ton/ha)"))
data1$TRATAMIENTO =factor(data1$TRATAMIENTO)
data1$BLOQUE =factor(data1$BLOQUE)
data1$AMBIENTE =factor(data1$AMBIENTE)

modelo2_MM<-lme(REND.~1+TRATAMIENTO*AMBIENTE,
random=~1|BLOQUE/AMBIENTE/TRATAMIENTO/SUBMUESTREO,
weights=varComb(varIdent(form=~1|TRATAMIENTO)),
data=data1,
control=lmeControl(niterEM=150,msMaxIter=200))
summary(modelo2_MM)
anova(modelo2_MM)

##MODELO 4##

modelo4_MM<-lme(REND.~1+TRATAMIENTO*AMBIENTE,
random=~1|BLOQUE/AMBIENTE/TRATAMIENTO,
weights=varComb(varIdent(form=~1|TRATAMIENTO)),
correlation=corExp(form=~X+Y,nugget=T),
data=data1,
control=lmeControl(niterEM=150,msMaxIter=200))
summary(modelo4_MM)
anova(modelo4_MM)

My second problem is, that i need to get the specific parameter for the
error term that belongs to the spatial correlation, in order to map it. For
what i watch, what lme does is send it to the general error, and so, what i
could do is make the differences between the residuals of these two models.
so, its essetial to get the exact same model, except for the correlation
structure.
If anybody knows how to get the specific term of error accounting for the
correlation, it would be wonderful.

E24=residuals(modelo24_3,type = "response")
E40=residuals(modelo4_MM,type = "response")
EE=E24-E40
post=data.frame(E24,E40,EE,data1$X,data1$Y)

coordinates(post)<-c("data1.X","data1.Y")
coor_post<-coordinates(post)

bubble(post,"E24",main="residuos modelo 2")
bubble(post,"E40",main="residuos modelo 4")
bubble(post,"EE",main="Est.espacial removida por Modelo 4")

thanks!

-- 
Javier Moreira de Souza
Ingeniero Agrónomo
099 406 006

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[R-sig-Geo] spatial structure of residuals in nlme mixed model

2017-07-19 Thread Javier Moreira
hi,
im trying to asses about the diference in puting the spatial estructure in
a mixed linear model.
What i need to do is to compare the actual distribution of the residuals of
two models, one that consider the correlation and one that not.

model with and without:

*without*

modelo3_MM<-lme(REND_SE~1+TRATAMIENTO*AMBIENTE,

 random=list(BLOQUE=pdIdent(~1),AMBIENTE=pdIdent(~1),TRATAMIENTO=pdIdent(~1)),
 data=data1,
 control=lmeControl(niterEM=150,msMaxIter=200))
modelo33_MM<-update(modelo3_MM,
weights=varComb(varIdent(form=~1|TRATAMIENTO)))

*with*
modelo34_MM<-update(modelo33_MM,
correlation=corExp(form=~1|BLOQUE/AMBIENTE/TRATAMIENTO))

until now, what i could do is to cheq the existance of that structure by
computing the semivariogram to the residuals.

plot(Variogram(modelo33_MM))

plot((modelo34_MM,resType="n",robust=T))

the question is how can i do the next step and krige this residuals in
order to get a map of predicted values and variance values?
im used to do it wity gstat package but i cant figured out with an object
of class "lme"

thanks

-- 
Javier Moreira de Souza
Ingeniero Agrónomo
099 406 006

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[R-sig-Geo] adjust a polynomial function to a rasterVis time serie

2017-07-03 Thread Javier Moreira
hi,
i have to raster stacks with sequence of ndvi, from diferent satellites.
Both are time series with ndvi data, but the dates dont match. So, i need
to adjust a polynomial to each one in order to predict the ndvi for the
same date.
Im watching rasterVis package, using bowplot, and that let me create the
grafic to generate this, but, how can i create a function over that?

thanks!


-- 
Javier Moreira de Souza
Ingeniero Agrónomo
099 406 006

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: [R-sig-Geo] gstat or geoR create variogram with sets of bounding boxes

2017-05-24 Thread Javier Moreira
THAT WORK FINE,
THANKS!

2017-05-24 7:17 GMT-03:00 Dr. Benedikt Gräler <b.grae...@52north.org>:

> Dear Javier,
>
> if I got you right, you seem to be looking for a "pooled estimation of
> within-strata variograms" as the help page on the function "variogram()" of
> gstat calls it. At first, define an indicator for each of your points that
> identifies the ID of the polygon it belongs to, then include it as
> regressor and set dX=0.5:
>
> Try the example below for the meuse data set where only point-pairs of the
> same soil type (corresponding to your polygon Ids) are considered and then
> a pooled variogram is calculated.
>
> HTH,
>
>  Ben
>
>
> library(sp)
> library(gstat)
>
> data(meuse)
> coordinates(meuse) <- ~x+y
>
> spplot(meuse, "zinc")
> spplot(meuse, "soil")
>
> vAll <- variogram(zinc~soil, meuse)
> plot(vAll)
>
> vWithinSoils <- variogram(zinc~soil, meuse, dX=0.5)
> plot(vWithinSoils)
>
>
>
>
> On 23/05/2017 17:23, Javier Moreira wrote:
>
>> hi,
>> im trying to make a variogram that consider a limit made by a bounding
>> box,
>> but not just one, but dividing the area of the hole set of points in
>> different subzones (treatments in this case).
>> I have tried to do so with bounding box in geoR, but i cant do it.
>> Also, another way its to use anisotropy, but when try to put an alpha
>> parameter in geostat, doesnt make any change that without it.
>> bottom line, i have to perform a variogram that includes only the points
>> in
>> 1 direction, or, tell the variogram to limit the surface to a polygon (
>> several ones)
>>
>> if any one can help,
>> thanks
>>
>>
> --
> Dr. Benedikt Gräler
> 52°North Initiative for Geospatial Open Source Software GmbH
> Martin-Luther-King-Weg 24
> 48155 Muenster, Germany
>
> E-Mail: b.grae...@52north.org
> Fon: +49-(0)-251/396371-39
> Fax: +49-(0)-251/396371-11
>
> http://52north.org/
> Twitter: @FiveTwoN
>
> General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
> Local Court Muenster HRB 10849
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Javier Moreira de Souza
Ingeniero Agrónomo
099 406 006

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[R-sig-Geo] gstat or geoR create variogram with sets of bounding boxes

2017-05-23 Thread Javier Moreira
hi,
im trying to make a variogram that consider a limit made by a bounding box,
but not just one, but dividing the area of the hole set of points in
different subzones (treatments in this case).
I have tried to do so with bounding box in geoR, but i cant do it.
Also, another way its to use anisotropy, but when try to put an alpha
parameter in geostat, doesnt make any change that without it.
bottom line, i have to perform a variogram that includes only the points in
1 direction, or, tell the variogram to limit the surface to a polygon (
several ones)

if any one can help,
thanks

-- 
Javier Moreira de Souza
Ingeniero Agrónomo
099 406 006

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo