RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
## RFoptions(seed=NA) to make them all random again
StartExample()
RFoptions(modus_operandi="sloppy")
#########################################################
## simulate some data first ##
points <- 100
x <- runif(points, 0, 3)
y <- runif(points, 0, 3) ## random points in square [0, 3]^2
model <- RMgencauchy(alpha=1, beta=2)
d <- RFsimulate(model, x=x, y=y, grid=FALSE, n=100) #1000
#########################################################
## estimation; 'NA' means: "to be estimated" ##
estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=2) +
RMtrend(mean=NA)
RFfit(estmodel, data=d)
#########################################################
## coupling alpha and beta ##
estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=NA) +
RMtrend(NA)
RFfit(estmodel, data=d, transform = NA) ## just for information
trafo <- function(a) c(a[1], rep(a[2], 2))
fit <- RFfit(estmodel, data=d,
transform = list(c(TRUE, TRUE, FALSE), trafo))
print(fit)
print(fit, full=TRUE)
\dontrun{
#########################################################
## Estimation with fixed sill (variance + nugget ##
## equals a given constant) ##
estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=NA) +
RMnugget(var=NA) + RMtrend(mean=NA)
RFfit(estmodel, data=d, fit.sill=1, fit.optim_var_elimination="try")
#########################################################
## estimation in a anisotropic framework ##
x <- y <- (1:3)/4
model <- RMexp(Aniso=matrix(nc=2, c(4,2,-2,1)), var=1.5)
d <- RFsimulate(model, x=x, y=y, n=n)
estmodel <- RMexp(Aniso=matrix(nc=2, c(NA,NA,-2,1)), var=NA) +
RMtrend(mean=NA)
RFfit(estmodel, data=d, fit.nphi=20)
#########################################################
## AN EXAMPLE HOW TO USE OF PARAMETER 'transform' ##
## estimation of coupled parameters (first column of ##
## the matrix 'Aniso' has identical entries) ##
# source("RandomFields/tests/source.R")
RFfit(estmodel, data=d, transform=list()) # shows positions of NAs
f <- function(param) param[c(1,2,2)]
RFfit(estmodel, data=d, transform=list(c(TRUE, TRUE, FALSE), f))
}
RFoptions(modus_operandi="normal")
FinalizeExample()
Run the code above in your browser using DataLab