fitCorModel: Fitting a correlation model by least-squares

Description Usage Arguments Examples

Description

Returns the parameter of the correlation model

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fitCorModel(h, ...)

## S3 method for class 'numeric'
fitCorModel(h, x, type = "exp", w = NULL, nugget = 0,
  smooth = 1, hPred = NULL, startp = NULL, bound = NULL, ...)

## S3 method for class 'matrix'
fitCorModel(x, ...)

## S3 method for class 'formula'
fitCorModel(form, x, ...)

Arguments

h

Vector of distance

...

Other parameters pass to the funtion optim.

x

Vector of correlation coefficients or Nx2 matrix of the distance and correlation coefficients.

type

Correlation model. See corModel

w

Vector of weights.

nugget

The nugget parameter. If NULL the parameter is optimized.

smooth

The smooth parameter for three parameters model.

hPred

A vector of distance for prediction (optional)

startp

The starting point for optimization. May be used when the nugget effect is estimated.

form

Formula indication the correlation coefficient and the distance. For instance x~h

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
tt = 1:500
rr = corModel(c(200,.1), tt, type = 'exp') +
              rnorm(length(tt),0,.2)

df <- data.frame(rho = rr, dist = tt)

fitCorModel(tt, rr, type = 'sph')

sol <- fitCorModel(rho ~ dist, df, nugget = NULL,
                   type = 'exp', hPred = tt, startp = c(200,.1))

plot(tt,rr, ylab = 'rho', xlab = 'distance')
lines(sol$pred$dist, sol$pred$rho, col = 2, lwd = 2)

martindurocher/floodRFA documentation built on June 5, 2019, 8:44 p.m.