lscale_from_Matern: Find length scales by fitting a Matern

Description Usage Arguments Examples

View source: R/frequency_fns.R

Description

Takes a spatial or spatio-temporal data set and returns spatial and temporal length scales by finding the maximum likelihood on a pre-specified grid. If the data is spatio-temporal a separable covariance structure is assumed.

Usage

1
2
lscale_from_Matern(data, rho = 100, nu = 3/2, var = 1,
  theta = seq(-0.99, 0.99, 0.33))

Arguments

data

a data frame with fields x, y and an output variable z. The time coordinate t is optional.

rho

an array of spatial practical ranges to consider.

nu

an array of smoothness parameters to consider.

var

an array of marginal variances to consider

theta

an array of first-order auto-regressive parameters to consider in the model x_{t+1} = θ x_{t} + e_{t}.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var_true <- 1
kappa_true <- kappa_from_l(l=1700,nu=2)
X <- data.frame(x = 3000*runif(100), y = 3000*runif(100))
dd<- fields::rdist(X,X)
K <- Matern(r=dd,nu=2,var=var_true,kappa=kappa_true)
X$z <-  t(chol(K)) %*% rnorm(nrow(X))
var_marg <- var(X["z"])
var_search <- 10^(seq(log10(var_marg/100),log10(var_marg*100),length=100))
rho_search=seq(100,4000,200)
lk_fit <- lscale_from_Matern(X,rho=rho_search,var=var_search,nu=c(2))
print(lk_fit$spat_df)

shazhe/mvst0 documentation built on May 29, 2019, 9:20 p.m.