View source: R/B_splines_est.R
solve_spline | R Documentation |
This is the objective function to find the weights for each basis function in the minimising spline, see Choi, Li & Wang (2013, p. 617).
The parameters must be nonnegative, so a penalty of 10^{12}
is given if any parameters are negative.
The weights are chosen as per Choi, Li & Wang (2013, p. 617).
solve_spline(par, splines_df, weights)
par |
A vector of initial parameters to used in the minimisation process. |
splines_df |
A data frame whose structure is defined in splines_df. |
weights |
A vector of weights, see the description. |
Let \mathbf{\beta} = (\beta_{0}, \dots, \beta_{m + p})^{\prime}
be a vector of model coefficients, \{f_{1}^{(p - 1)} , \dots , f_{m + p}^{(p - 1)} \}
be a set of completely monotone basis functions, and \widehat{C}(\cdot)
be an estimated covariance function.
As per Choi, Li & Wang (2013, p. 617), \mathbf{\beta}
can be estimated via weighted-least squares,
\
\hat{\mathbf{\beta}}_{WLS} = {\arg\min}_{\beta_{j} \ge 0} \sum_{i=1}^{L} w_{i} \left(\widehat{C}(h_{i}) - \sum_{j = 1}^{m + p} \beta_{j} f_{j}^{(p - 1)}(h_{i}^{2}) \right)^{2} ,
where \{h_{1} , \dots , h_{L} \}
is a set of lags and \{w_{1}, \dots , w_{L} \}
is a set of weights.
The set of weights is calculated in splines_est, and they are of the form w_{i} = (N - h_{i}) / ((1 - \widehat{C}(h_{i}))^{2}).
The value of the objective function at those parameters.
Choi, I., Li, B. & Wang, X. (2013). Nonparametric Estimation of Spatial and Space-Time Covariance Function. JABES 18, 611-630. https://doi.org/10.1007/s13253-013-0152-z
taus <- get_taus(3, 2)
x <- seq(0, 2, by=0.25)
maxLag <- 4
splines_df <- splines_df(x[1:maxLag], 3, 2, taus)
splines_df$estCov <- exp(-splines_df$lags^2) + 0.001
# pars are the inital parameters used in the minimisation process.
pars <- c(0.5, 0.5, 0.5, 0.5, 0.5)
weights <- c()
X <- rnorm(50)
for(i in 0:(maxLag - 1)) {
weights <- c(weights, (length(X) - i) / ( (1 - splines_df$estCov[i + 1])^2 ))
}
solve_spline(pars, splines_df, weights)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.