R/flag.R

Defines functions flag

Documented in flag

#' Calculation of lagged covariates 
#' 
#' @param x The matrix of covariates.
#' @praam n The sample size
#' @param lag The maximum lag.
#' @return  y The first covariate of x  without a lag, the dependent covariate.
#' @return xl The lagged covariates with lags of order 1:lag starting with the first covariate.
#' @examples 
#' data(abcq)
#' abcql<-flag(abcq,240,1,16)
#' a<-f1st(abcql[[1]],abcql[[2]])
flag<-function(x,n,i,lag){
	k<-length(x)/n
	x<-matrix(x,nrow=n,ncol=k)
	tmp<-.Fortran(
		"lagg",
		as.double(x),
		as.integer(n),
		as.integer(k),
		as.integer(lag),
		double((n-lag)*k*lag),
		double(n-lag),
		as.integer(i)
		)
	y<-tmp[[6]]
	xl<-tmp[[5]]
	xl<-matrix(xl,nrow=n-lag,ncol=k*lag)
	list(y,xl)
}

Try the gausscov package in your browser

Any scripts or data that you put into this service are public.

gausscov documentation built on Oct. 12, 2023, 1:06 a.m.