[R-sig-Geo] help using SVC_mle of library varycoef

2023-07-23 Thread Emanuele Barca
Hi, this is emanuele barca and I would like to learn the library 
varycoef.
I created a simulation of an ideal spatial dataset (gaussian) and 
applied SVC_mle function:


set.seed(1234)

library(gstat)

# create structure
nx <- 100
ny <- 100
xy <- expand.grid(1:nx, 1:ny)
names(xy) <- c("x","y")

g.dummy <- gstat(formula = z ~ 1 + x + I(y^0.5), locations = ~ x + y, 
dummy = T, beta = c(1, 0.01, 0.005),
 model = vgm(psill = 0.025, range = 20, model = 'Ste', 
kappa = 10), nmax = 20)


yy <- predict(g.dummy, newdata = xy, nsim = 1)


xy.reduced <- as.data.frame(matrix(ncol = 3, nrow = 0))
for (i in 1:5000){
  xy.reduced[i, ] <- yy[i*2, 1:3]
}

Fact<- 20/100 #% of reduction about 80%
training <- sample(nrow(xy.reduced), trunc(Fact*nrow(xy.reduced)))
Xtraining <- xy.reduced[training, ]
Xtest <- xy.reduced[-training, ]
df_train <- Xtraining
colnames(df_train) <- c("X", "Y", "sim")

fit_svc <- SVC_mle(sim ~ X + Y, data = df_train, locs = df_train[, 
1:2])#

coef(fit_svc)
summary(fit_svc)

but it returns an error of the covariance matrix.
 Could someone help me to overcome the error?

thanks in advance

emanuele

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


[R-sig-Geo] automatic assessment of linear coregionalization model

2020-06-30 Thread Emanuele Barca

Dear friend,

I am trying to garner a result similar to that of autofitvariogram() 
function with fit.lmc() function.

But results are not good.
The following is my code:

g <- gstat(id = "Balance", formula = Balance ~ 1, data = mydata.sp, set 
= list(nocheck = 1))
g <- gstat(g, id = "Ancillary", formula = Ancillary ~ 1, data = r.sp, 
set = list(nocheck = 1))

v.g <- variogram(g)
g.fit <- fit.lmc(v.g, g, vgm("Exp",
model.df$range[2]), fit.method = 1, correct.diagonal = 1.01) # 
fit.lmc = TRUE,

g.fit

the outcome is
data:
Balance : formula = Balance`~`1 ; data dim = 74 x 1
Ancillary : formula = Ancillary`~`1 ; data dim = 18683 x 1
variograms:
 model psillrange
Balance[1] Nug 10.864143 0.00
Balance[2] Exp  8.128785 12946.87
Ancillary[1]   Nug 43.803405 0.00
Ancillary[2]   Exp 52.100889 16156.90
Balance.Ancillary[1]   Nug 21.598834 0.00
Balance.Ancillary[2]   Exp 20.375770 16151.70
set nocheck = 1;

the results are too weird. Is a data problem?


thanks in advance

emanuele barca

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


Re: [R-sig-Geo] regression-kriging and co-kriging (Edzer Pebesma)

2019-08-15 Thread Emanuele Barca
------

Message: 2
Date: Thu, 15 Aug 2019 08:33:59 +0200
From: Edzer Pebesma 
To: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] regression-kriging and co-kriging
Message-ID: 
Content-Type: text/plain; charset="utf-8"



On 8/12/19 8:21 PM, Emanuele Barca wrote:

Dear Edzer,

maybe I found the solution. I found this in the predict function help:
"When a non-stationary (i.e., non-constant) mean is used, both for
simulation and prediction purposes the variogram model defined should 
be

that of the residual process, and not that of the raw observations"
Since my data were, actually, non-stationary, I applied the universal
co-kriging instead usual co-kriging.
now the maps of regression-kring and co-kriging are actually similar s
expected.
did I understand correctly the quoted sentence?


I think so, but hard to be sure given the information you provide.



regards

emanuele barca
--


Message: 2
Date: Sat, 10 Aug 2019 10:41:38 +0200
From: Edzer Pebesma 
To: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] regression-kriging and co-kriging
Message-ID: 
Content-Type: text/plain; charset="utf-8"

Hard to tell from your script. Maybe give a reproducible example?

On 8/6/19 1:07 PM, Emanuele Barca wrote:

Dear  r-sig-geo friends,

I produced two maps garnered in the following way:

# for regression-kriging
Piezo.map <-autoKrige(LivStat ~  Z, input_data = mydata.sp, new_data
= covariates,  model = "Ste")

Piezork.pred <- Piezo.map$krige_output$var1.pred
Piezork.coords <- Piezo.map$krige_output@coords
Piezork.out <- as.data.frame(cbind(Piezork.coords, Piezork.pred))
colnames(Piezork.out)[1:2] <- c("X", "Y")
coordinates(Piezork.out) = ~ X + Y
gridded(Piezork.out) <- TRUE

spplot(Piezork.out, main = list(label = "R-k Hydraulic head", cex =
1.5))

#for co-kriging
g <- gstat(id = "Piezo", formula = LivStat ~ 1, data = mydata.sp, 
set

= list(nocheck = 1))
g <- gstat(g, id = "Z", formula = Z ~ 1, data = mydata.sp, set =
list(nocheck = 1))

v.g <- variogram(g)

#g <- gstat(g, id = "Piezo", model = vgm(150, "Mat", 1350, 0.0, 
kappa

= 1.9), fill.all = T)#
g <- gstat(g, id = "Piezo", model = vgm(0.7, "Ste", 1300, 18, kappa 
=

1.9), fill.all = T)#
g.fit <- fit.lmc(v.g, g, fit.lmc = TRUE, correct.diagonal = 1.01) #
fit multivariable variogram model , fit.lmc = TRUE, correct.diagonal
= 1.01
g.fit
plot(v.g, model = g.fit, main = "Fitted Variogram Models - Raw 
Data")#

#gridded(covariates) <- TRUE
g.cok <- predict(g.fit, newdata = covariates)#grid

g.cok.pred <- g.cok@data$Piezo.pred
 <- na.omit(g.cok.pred)
g.cok.coords <- g.cok@coords
g.cok.out <- as.data.frame(cbind(g.cok.coords, g.cok.pred))
colnames(g.cok.out)[1:2] <- c("X", "Y")
coordinates(g.cok.out) = ~ X + Y
gridded(g.cok.out) <- TRUE
spplot(g.cok.out, main = list(label = "Hydraulic head with
Co-kriging", cex = 1.5))

###


I am unable to understand why the first map appears as a raster and
the second not, notwithstanding the fact that they are both computed
on the same "covariates" DEM???

where is the mistake???

regards

emanuele


Emanuele Barca   Researcher
Water Research Institute   (IRSA-CNR)
Via De Blasio, 5   70123 Bari (Italy)
Phone +39 080 5820535   Fax  +39 080 5313365
Mobile +39 340 3420689
_



---
Questa e-mail è stata controllata per individuare virus con Avast
antivirus.
https://www.avast.com/antivirus

[[alternative HTML version deleted]]

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



--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

-- next part --
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2472 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190810/b5cb9d77/attachment-0001.bin>



--

Subject: Digest Footer

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


--

End of R-sig-Geo Digest, Vol 192, Issue 7
*


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


--
Edzer Pebesma
Institute for Geoinformatics

[R-sig-Geo] regression-kriging and co-kriging

2019-08-12 Thread Emanuele Barca

Dear Edzer,

maybe I found the solution. I found this in the predict function help: 
"When a non-stationary (i.e., non-constant) mean is used, both for 
simulation and prediction purposes the variogram model defined should be 
that of the residual process, and not that of the raw observations"
Since my data were, actually, non-stationary, I applied the universal 
co-kriging instead usual co-kriging.
now the maps of regression-kring and co-kriging are actually similar s 
expected.

did I understand correctly the quoted sentence?

regards

emanuele barca
--


Message: 2
Date: Sat, 10 Aug 2019 10:41:38 +0200
From: Edzer Pebesma 
To: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] regression-kriging and co-kriging
Message-ID: 
Content-Type: text/plain; charset="utf-8"

Hard to tell from your script. Maybe give a reproducible example?

On 8/6/19 1:07 PM, Emanuele Barca wrote:

Dear  r-sig-geo friends,

I produced two maps garnered in the following way:

# for regression-kriging
Piezo.map <-autoKrige(LivStat ~  Z, input_data = mydata.sp, new_data
= covariates,  model = "Ste")

Piezork.pred <- Piezo.map$krige_output$var1.pred
Piezork.coords <- Piezo.map$krige_output@coords
Piezork.out <- as.data.frame(cbind(Piezork.coords, Piezork.pred))
colnames(Piezork.out)[1:2] <- c("X", "Y")
coordinates(Piezork.out) = ~ X + Y
gridded(Piezork.out) <- TRUE

spplot(Piezork.out, main = list(label = "R-k Hydraulic head", cex = 
1.5))


#for co-kriging
g <- gstat(id = "Piezo", formula = LivStat ~ 1, data = mydata.sp, set
= list(nocheck = 1))
g <- gstat(g, id = "Z", formula = Z ~ 1, data = mydata.sp, set =
list(nocheck = 1))

v.g <- variogram(g)

#g <- gstat(g, id = "Piezo", model = vgm(150, "Mat", 1350, 0.0, kappa
= 1.9), fill.all = T)#
g <- gstat(g, id = "Piezo", model = vgm(0.7, "Ste", 1300, 18, kappa =
1.9), fill.all = T)#
g.fit <- fit.lmc(v.g, g, fit.lmc = TRUE, correct.diagonal = 1.01) #
fit multivariable variogram model , fit.lmc = TRUE, correct.diagonal = 
1.01

g.fit
plot(v.g, model = g.fit, main = "Fitted Variogram Models - Raw Data")#
#gridded(covariates) <- TRUE
g.cok <- predict(g.fit, newdata = covariates)#grid

g.cok.pred <- g.cok@data$Piezo.pred
 <- na.omit(g.cok.pred)
g.cok.coords <- g.cok@coords
g.cok.out <- as.data.frame(cbind(g.cok.coords, g.cok.pred))
colnames(g.cok.out)[1:2] <- c("X", "Y")
coordinates(g.cok.out) = ~ X + Y
gridded(g.cok.out) <- TRUE
spplot(g.cok.out, main = list(label = "Hydraulic head with
Co-kriging", cex = 1.5))

###

I am unable to understand why the first map appears as a raster and
the second not, notwithstanding the fact that they are both computed
on the same "covariates" DEM???

where is the mistake???

regards

emanuele


Emanuele Barca   Researcher
Water Research Institute   (IRSA-CNR)
Via De Blasio, 5   70123 Bari (Italy)
Phone +39 080 5820535   Fax  +39 080 5313365
Mobile +39 340 3420689
_



---
Questa e-mail è stata controllata per individuare virus con Avast 
antivirus.

https://www.avast.com/antivirus

[[alternative HTML version deleted]]

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



--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

-- next part --
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2472 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190810/b5cb9d77/attachment-0001.bin>


--

Subject: Digest Footer

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


--

End of R-sig-Geo Digest, Vol 192, Issue 7
*


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


[R-sig-Geo] regression-kriging and co-kriging

2019-08-06 Thread Emanuele Barca
Dear  r-sig-geo friends,

I produced two maps garnered in the following way:

# for regression-kriging
Piezo.map <-autoKrige(LivStat ~  Z, input_data = mydata.sp, new_data
= covariates,  model = "Ste")

Piezork.pred <- Piezo.map$krige_output$var1.pred
Piezork.coords <- Piezo.map$krige_output@coords
Piezork.out <- as.data.frame(cbind(Piezork.coords, Piezork.pred))
colnames(Piezork.out)[1:2] <- c("X", "Y")
coordinates(Piezork.out) = ~ X + Y
gridded(Piezork.out) <- TRUE

spplot(Piezork.out, main = list(label = "R-k Hydraulic head", cex = 1.5))

#for co-kriging
g <- gstat(id = "Piezo", formula = LivStat ~ 1, data = mydata.sp, set
= list(nocheck = 1))
g <- gstat(g, id = "Z", formula = Z ~ 1, data = mydata.sp, set =
list(nocheck = 1))

v.g <- variogram(g)

#g <- gstat(g, id = "Piezo", model = vgm(150, "Mat", 1350, 0.0, kappa
= 1.9), fill.all = T)#
g <- gstat(g, id = "Piezo", model = vgm(0.7, "Ste", 1300, 18, kappa =
1.9), fill.all = T)#
g.fit <- fit.lmc(v.g, g, fit.lmc = TRUE, correct.diagonal = 1.01) #
fit multivariable variogram model , fit.lmc = TRUE, correct.diagonal = 1.01
g.fit
plot(v.g, model = g.fit, main = "Fitted Variogram Models - Raw Data")#
#gridded(covariates) <- TRUE
g.cok <- predict(g.fit, newdata = covariates)#grid

g.cok.pred <- g.cok@data$Piezo.pred
 <- na.omit(g.cok.pred)
g.cok.coords <- g.cok@coords
g.cok.out <- as.data.frame(cbind(g.cok.coords, g.cok.pred))
colnames(g.cok.out)[1:2] <- c("X", "Y")
coordinates(g.cok.out) = ~ X + Y
gridded(g.cok.out) <- TRUE
spplot(g.cok.out, main = list(label = "Hydraulic head with
Co-kriging", cex = 1.5))

###

I am unable to understand why the first map appears as a raster and
the second not, notwithstanding the fact that they are both computed
on the same "covariates" DEM???

where is the mistake???

regards

emanuele


Emanuele Barca   Researcher
Water Research Institute   (IRSA-CNR)
Via De Blasio, 5   70123 Bari (Italy)
Phone +39 080 5820535   Fax  +39 080 5313365
Mobile +39 340 3420689
_



---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus

[[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] problems in anisotropy detection

2019-07-12 Thread Emanuele Barca

Dear friends,

I have a dataset of hydraulic heads, mydata =  and i would 
like to check for anisotropy.


In R I found 3 functions to carry out such task:

1. likfit

x_geodata <- as.geodata(mydata, coord.cols = 1:2, data.col = 3,
covar.col = 4)
fit_mle  <- likfit(x_geodata,
   fix.nugget = FALSE,
   cov.model = "exponential", psiA = 0, psiR = 1,
   ini = c(var(Y), 1), fix.psiA = FALSE, fix.psiR = 
FALSE,

   hessian = TRUE)

that detects no anisotropy.

2. estimateAnisotropy

mydata.sp <- mydata
coordinates(mydata.sp) = ~ X + Y
estimateAnisotropy(mydata.sp, depVar = "LivStat", "LivStat ~ Z")

that returns the following

[generalized least squares trend estimation]
$`ratio`
[1] 1.340775

$direction
[1] -35.29765

$Q
  Q11  Q22  Q12
[1,] 1.926136e-05 2.329241e-05 5.721893e-06

$doRotation
[1] TRUE

finally,

3. estiStAni

vmod1 <- fit.variogram(vgm1, vgm(18, "Ste", 1300, 0.78, kappa = 1.7))
estiStAni(vgm1, c(10, 150), "vgm", vmod1)

that returns an error:

Error in `$<-.data.frame`(`*tmp*`, "dir.hor", value = 0) :
  replacement has 1 row, data has 0.

I am very puzzled, can anyone help me understanding if there is 
anisotropy in my dataset?


thanks

emanuele

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


Re: [R-sig-Geo] auto-correlation of nominal variables (Rich Shepard)

2019-06-19 Thread Emanuele Barca

Thank you Rich for your suggestion, is indeed intersting!

Actually, my interest is in finding a clustering tendency of 
crop-classes.


Therefore, joincount.multi of spdep library is perfect for my aims.

I would like to find a function for representing graphically such 
tendency.


thanks once more.

emanuele



Il 2019-06-19 12:00 r-sig-geo-requ...@r-project.org ha scritto:

Send R-sig-Geo mailing list submissions to
r-sig-geo@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
or, via email, send a message with subject or body 'help' to
r-sig-geo-requ...@r-project.org

You can reach the person managing the list at
r-sig-geo-ow...@r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-Geo digest..."


Today's Topics:

   1. GAM parameters: Biomod 2 (Lara Silva)
   2. Re: auto-correlation of nominal variables (Rich Shepard)

--

Message: 1
Date: Tue, 18 Jun 2019 13:46:08 +
From: Lara Silva 
To: r-sig-ecol...@r-project.org, r-sig-geo@r-project.org
Subject: [R-sig-Geo] GAM parameters: Biomod 2
Message-ID:

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

Hello,

I am using Biomod 2 to modelling species distribution. I ran some
algorithms like GAM, GLM, RF and CTA.

I did not change the parameters. How can I known the quadratic terms of 
GAM?



I used the variables with form linear (e.g.  precipitation, altimetry,
temperature) I did not use temperature ^2.


Any suggestions?

Regards,


Lara






<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
Sem
vírus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[[alternative HTML version deleted]]




--

Message: 2
Date: Tue, 18 Jun 2019 07:51:09 -0700 (PDT)
From: Rich Shepard 
To: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] auto-correlation of nominal variables
Message-ID:

Content-Type: text/plain; charset="us-ascii"; Format="flowed"

On Sun, 16 Jun 2019, Emanuele Barca wrote:


I received a  dataset of point data, organized in the following way: a
couple of coordinates and a column of "crop classes codes", three 
columns.


I would like to compute something similar to the Moran index for each 
crop

class code.


Emanuele,

What is your interest in these data? Are you interested in the pattern 
of

crop classes (such as in epidemiology or designing a timber sale) or
something else?

If it is the pattern that is of interest I suggest you first test for
complete spatial randomness. Look at some of the references and R 
packages

for spatial point processes. The distribution of crop classes could be
random, regular, or clumped/clustered.

Peter Diggle's book, "Statistical Analysis of Spatial Point Patterns," 
and

"Spatial Point Patterns" by Adrian Baddeley, Ege Rubak, and Rolf Turner
would be excellent places to start.

Hope this helps,

Rich




--

Subject: Digest Footer

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


--

End of R-sig-Geo Digest, Vol 190, Issue 13
**


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


[R-sig-Geo] auto-correlation of nominal variables

2019-06-16 Thread Emanuele Barca

Dear friends,

I received a  dataset of point data, organized in the following way:

a couple of coordinates and a column of "crop classes codes", three 
columns.


I would like to compute something similar to the Moran index for each 
crop class code.


How can I carry out such task in R?

thanks in advance

emanuele

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