clr {clr} | R Documentation |
Curve Linear Regression via dimension reduction
Description
Fits a curve linear regression (CLR) model to data, using dimension reduction based on singular value decomposition.
Usage
clr(Y, X, clust = NULL, qx_estimation = list(method = "pctvar", param =
0.999), ortho_Y = TRUE, qy_estimation = list(method = "pctvar", param
= 0.999), d_estimation = list(method = "cor", param = 0.5))
Arguments
Y |
An object of class |
X |
An object of class |
clust |
If needed, a list of row indices for each cluster, to obtain (approximately) homogeneous dependence structure inside each cluster. |
qx_estimation |
A list containing both values for 'method' (among 'ratio', 'ratioM', 'pctvar', 'fixed') and for 'param' (depending on the selected method), in order to choose how to estimate the dimension of X (in the sense that its Karhunen-Lo\'eve decomposition has qx terms only. |
ortho_Y |
If TRUE then Y is orthogonalized. |
qy_estimation |
Same as for qx_estimation, if ortho_Y is set to TRUE. |
d_estimation |
A list containing both values for 'method' (among 'ratio', 'pctvar', 'cor') and for 'param' (depending on the selected method), in order to choose how to estimate the correlation dimension. |
Value
An object of class clr
, which can be used to compute
predictions.
This clr
object is a list of lists: one list by cluster of data, each
list including:
residuals |
The matrix of the residuals of d_hat simple linear regressions. |
b_hat |
The vector of the estimated coefficient of the d_hat simple straight line regressions. |
eta |
The matrix of the projections of X. |
xi |
The matrix of the projections of Y. |
qx_hat |
The estimated dimension of X. |
qy_hat |
The estimated dimension of Y. |
d_hat |
The estimated correlation dimension. |
X_mean |
The mean of the regressor curves. |
X_sd |
The standard deviation of the regressor curves. |
Y_mean |
The mean of the response curves. |
ortho_Y |
The value which was selected for ortho_Y. |
GAMMA |
The standardized transformation for X. |
INV_DELTA |
The standardized transformation for Y to predict if ortho_Y was set to TRUE. |
phi |
The eigenvectors for Y to predict if ortho_Y was set to FALSE. |
idx |
The indices of the rows selected from X and Y for the current cluster. |
See Also
clr-package
, clrdata
and
predict.clr
.
Examples
library(clr)
data(gb_load)
data(clust_train)
clr_load <- clrdata(x = gb_load$ENGLAND_WALES_DEMAND,
order_by = gb_load$TIMESTAMP,
support_grid = 1:48)
## data cleaning: replace zeros with NA
clr_load[rowSums((clr_load == 0) * 1) > 0, ] <- NA
matplot(t(clr_load), ylab = 'Daily loads', type = 'l')
Y <- clr_load[2:nrow(clr_load), ]
X <- clr_load[1:(nrow(clr_load) - 1), ]
begin_pred <- which(substr(rownames(Y), 1, 4) == '2016')[1]
Y_train <- Y[1:(begin_pred - 1), ]
X_train <- X[1:(begin_pred - 1), ]
## Example without any cluster
model <- clr(Y = Y_train, X = X_train)
## Example with clusters
model <- clr(Y = Y_train, X = X_train, clust = clust_train)