I am having trouble understanding how to perform cross validation (xvalid) in RGeostats. I would like to get some guidance on setting up the procedure and then doing the following:
1. plot a histogram of the estimated and standard error values
2. Cross plot the error variance against the estimated values
2. map the error variance (standard deviation)
I have looked at the vignettes and I am getting a sense of what to do... I'm stumbling at the following steps:
Plotting the locations of a particular variable per the vignette:
YOUR CODE:
#Modifying the variable role
It is now time to introduce the role that each field must play: this is defined using its locator. For example, we can check that the fields 2 and 3 are respectively the first and second coordinates: the locators are x1 and x2. Similarly if we consider Zn as the variable of interest, we set its locator to z1. The variable Pb is kept unclassified with its locator equal to NA. Setting this locator is performed using the following command:
```{r }
data.db = db.locate(data.db,"Zn","z",1)
```
MY CODE:
```{r }
data.db_wt2 <- db.locate(data.db_wt,"P_PHI","z",1)
```
What I don't understand is how to designate my x and y locator variables. In my data set they are fields 4 and 5, not 1 and 2 as they are in yours....
THEN, WHEN I PLOT:
```{r}
plot(data.db_wt2,pch = 21,bg = "red",col = "black",
title = "PHI Samples location")
```
I GET AN ERROR (looks like it cannot find X or Y coordinates???)
Error: Error: Coordinates (1) incompatible with Space dimension (0)
5.
base::stop(..., call. = FALSE)
4.
stop0("Error: Coordinates (", pos.x, ") incompatible with Space dimension (", ndim, ")")
3.
db.plot(x, ...)
2.
plot(data.db_wt2, pch = 21, bg = "red", col = "black", title = "Zn Samples location")
1.
plot(data.db_wt2, pch = 21, bg = "red", col = "black", title = "Zn Samples location")
MY DATA BASE CHARACTERISTICS ARE:
=========================
Data Base Summary
-----------------
File is organized as a set of isolated points
Space dimension = 0
Number of fields = 11
Maximum Number of attributes = 11
Total number of samples = 262
Variables
---------
Field = 1 - Name = rank - Locator = rank
Field = 2 - Name = F_Top - Locator = NA
Field = 3 - Name = N_Well - Locator = NA
Field = 4 - Name = C_X_ft - Locator = NA
Field = 5 - Name = C_Y_ft - Locator = NA
Field = 6 - Name = L_3_FACIES - Locator = NA
Field = 7 - Name = P_Delta_t - Locator = NA
Field = 8 - Name = P_KH_md - Locator = NA
Field = 9 - Name = P_PHI - Locator = NA
Field = 10 - Name = P_Thickness - Locator = NA
Field = 11 - Name = P_Top_ft - Locator = NA
MOVING ON....
CREATING A UNIQUE NEIGHBORHOOD:
I can create the unique neighborhood and the moving neighborhood as below:
```{r }
WT_2D_unique.neigh <- neigh.create(ndim = 2, type = 0)
```
```{r}
WT_2D_unique.neigh
```
is.na() applied to non-(list or vector) of type 'S4'
Neighborhood characteristics
============================
Unique neighborhood option
Space dimension = 2
CREATING A MOVING NEIGHBORHOOD
```{r}
WT_2D_moving.neigh =
neigh.create(ndim = 0,nmaxi = 40000,radius = 5000,
flag.sector = TRUE,nsect = 8 ,nsmax = 2)
```
But then get stuck here:
``{r}
data.db_wt3 <- xvalid(data.db_wt2,data.model.omni,
WT_2D_moving.neigh)
```
Error message:
is.na() applied to non-(list or vector) of type 'S4'
The function is interrupted
I think this may be BECAUSE that I created my vriograms in S3, in a data frame not s4 in a db... so I will try that next...
Any other suggestions would be helpful!!