\HeaderA{linesmodel}{Computation of parametric variogram model}{linesmodel}
\keyword{file}{linesmodel}
\begin{Description}\relax
Computes the value of the parametric variogram model at given distances.
\end{Description}
\begin{Usage}
\begin{verbatim}
linesmodel(distance, variog.model="exponential", param)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{distance}] numeric vector of distances.
\item[\code{variog.model}] character string giving the name of the parametric variogram model. Implemented models are: \kbd{exponential}, \kbd{spherical}, \kbd{gauss}, \kbd{gencauchy} and \kbd{matern}.
\item[\code{param}] numeric vector containing the values of the variogram parameters. 

If the parametric model specified is \kbd{exponential}, \kbd{spherical} or 
\kbd{gauss}, \code{param} is a vector of length 3 containing, in order: 
the nugget effect (non negative number), the variance and the range (both 
positive numbers).

If the parametric model specified is \kbd{gencauchy}, \code{param} is a 
vector of length 5 whose entries are, in order: the nugget effect (non 
negative number), the variance, the range (both positive numbers), the 
smoothness parameter \kbd{a} (a number in \eqn{(0,2]}{}), and the long-range 
parameter \kbd{b} (a positive number).

If the parametric model specified is \kbd{matern}, \code{param} is a 
vector of length 4 whose entries are, in order: the nugget effect (a 
non-negative number), the variance, the range, and the smoothness 
parameter \kbd{a} (all three, positive numbers).
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The function calculates the value of the parametric variogram at given distances using the following equations:

- If the parametric model is \kbd{exponential}

\deqn{\gamma(d) = \rho+\sigma^{2} \cdot (1-exp(- \frac{d}{r}))}{}

where \eqn{\rho}{} is the nugget effect, \eqn{\sigma^2}{} is the variance, \eqn{r}{} is the range, and \eqn{d}{} is the distance.


- If the parametric model is \kbd{spherical}

\deqn{\gamma(d) = \rho+\sigma^{2} \cdot 
(\frac{3}{2}\cdot\frac{d}{r}-\frac{1}{2}\cdot \frac{d^3}{r^3})}{}

where \eqn{\rho}{} is the nugget effect, \eqn{\sigma^2}{} is the variance, \eqn{r}{} is the range, and \eqn{d}{} is the distance.


- If the parametric model is \kbd{gauss}

\deqn{\gamma(d) = \rho+\sigma^{2} \cdot (1-exp(- \frac{d^2}{r^2} ))}{}

where \eqn{\rho}{} is the nugget effect, \eqn{\sigma^2}{} is the variance, \eqn{r}{} is the range, and \eqn{d}{} is the distance.


- If the parametric model is \kbd{gencauchy}

\deqn{\gamma(d) = \rho+\sigma^{2} \cdot 
(1-(1+\frac{d^a}{r^a})^{- \frac{b}{a}})}{}

where \eqn{\rho}{} is the nugget effect, \eqn{\sigma^2}{} is the variance, 
\eqn{r}{} is the range, \eqn{d}{} is the distance, \eqn{a}{} is the smoothness 
parameter, and \eqn{b}{} is the long-range parameter.


- If the parametric model is \kbd{matern}

\deqn{\gamma(d) = \rho+\sigma^{2} \cdot (1-(\frac{2^{1-a}}{\Gamma(a)}\cdot 
\frac{d^a}{r^a} \cdot K_{a}(\frac{d}{r}))}{}

where \eqn{\rho}{} is the nugget effect, \eqn{\sigma^2}{} is the variance, 
\eqn{r}{} is the range, \eqn{d}{} is the distance, and \eqn{a}{} is the 
smoothness parameter.
\end{Details}
\begin{Value}
The function returns a numeric vector with the values of the parametric variogram model at the bin midpoints.
\end{Value}
\begin{Author}\relax
Gel, Y., Raftery, A. E., Gneiting, T., Berrocal, V. J. \email{veronica@stat.washington.edu}.
\end{Author}
\begin{References}\relax
Gel, Y., Raftery, A. E., Gneiting, T. (2004). Calibrated 
probabilistic mesoscale weather field forecasting: The Geostatistical 
Output Perturbation (GOP) method (with discussion). \emph{Journal of the 
American Statistical Association}, \bold{Vol. 99 (467)}, 575--583.

Cressie, N. A. C. (1993). \emph{Statistics for Spatial Data} (revised ed.). Wiley: New York.

Gneiting, T., Schlather, M. (2004). Stochastic models that separate 
fractal dimension and the Hurst effect. \emph{SIAM Review} \bold{46}, 
269--282.

Stein, M. L. (1999). \emph{Interpolation of Spatial Data - Some Theory for Kriging}. Springer-Verlag: New York.
\end{References}
\begin{Examples}
\begin{ExampleCode}
## Loading data
data(slp)
day <- slp$date.obs
id <- slp$id.stat
coord1 <- slp$lon.stat
coord2 <- slp$lat.stat
obs <- slp$obs
forecast <- slp$forecast

## Computing empirical variogram
variogram <- Emp.variog(day=day,obs=obs,forecast=forecast,id=id,coord1=coord1,
coord2=coord2,cut.points=NULL,max.dist=NULL,nbins=NULL)

## Estimating variogram parameters
## Without specifying initial values for the parameters
param.variog <- 
Variog.fit(emp.variog=variogram,variog.model="exponential",max.dist.fit=NULL,
init.val=NULL,fix.nugget=FALSE)

## Plotting the empirical variogram with the estimated parametric variogram superimposed
plot(variogram$bin.midpoints,variogram$empir.variog,xlab="Distance",ylab="Semi-variance")
lines(variogram$bin.midpoints,linesmodel(distance=variogram$bin.midpoints,variog.model="exponential",param=c(param.variog$nugget,
param.variog$variance,param.variog$range)))


\end{ExampleCode}
\end{Examples}

