R/FullIndex.R

Defines functions full.index

Documented in full.index

#' Automatic index builder for regression coefficients
#'
#' @description In our time lagged regression problem, each covariate \eqn{x_i} is either present or absent for all lags,
#' this function makes it easy to only specify the general sparsity, and convert it for all 5 lags. Used for both generation of
#' response, and for the estimation purpose. Caution: so far only for total of 10 covariates!
#'
#' @param xs a vector. Index of non 0 covariates
#'
#' @return a list of components
#'
#' \item{xs}{The initial indices, also lag0 (at t-0)}
#' \item{in2}{Indices for lag1, t-1}
#' \item{in3}{Indices for lag2, t-2}
#' \item{in4}{Indices for lag3, t-3}
#' \item{in5}{Indices for lag4, t-4}
#'
#' @export
#'
#' @examples
#' xs.est <- c(4, 5, 6, 7, 8, 9, 10)
#' fullindex = full.index(xs.est)
#'


full.index <- function(xs){  # duplicate xs 5 times
  in2 <- c(xs, xs + 10)
  in3 <- c(in2, xs+20)
  in4 <- c(in3, xs+30)
  in5 <- c(in4, xs+40)

  return(list(lag0 = xs,
              lag1 = in2,
              lag2 = in3,
              lag3 = in4,
              lag4 = in5))
}


# for full.index.large(), go to the original Rproj
# here for simplicity, one function per file
yymmhaha/PackPaper1 documentation built on May 24, 2019, 8:55 a.m.