
#Please source R code.R file first

DATASETS

```{r}
###Load data as d by T matrix.  Sample data (indpendent bivariate arma): 
Data <- t(matrix(c(arima.sim(list(ar=c(0.4,0.4)),n=100),arima.sim(list(ar=c(0.4,0.4)),n=100)),100,2))
# can comment out the above to give your own data generator
#Other sample data:
#n<-1000
#Data1<-rnorm(n+3,0,1)
#Data2<-Data1[4:(n+3)]
#Data1<-Data1[1:n]
#Data<-t(matrix(c(Data1,Data2),n,2))
```

USER-DEFINED PARAMETERS

```{r}

win <- c("ID",.25,.05)  #choose window "TR", "ID", "PR", or "QS" with any parameters that apply

w <- 0      #F evaluated at w, w in [-pi,pi]

cef <- CEFF(win)    #bandwidth = hat(q)/cef

const <- 2          #constant C_0 used in bandwidth algorithm, i.e., calculate HatS

KN <- 5             #max(5,floor(log10(dim(data)[2]))), which is used to calculate HatS

```

DO ESTIMATION

```{r}
Ghat <- CmpGamma(Data)
Rhat <- CmpRho(Ghat)
Shat <- CmpHatS(Rhat)
Fhat <- CmpHatF(Ghat,Shat,w)
FhatPlus <- CmpHatFPlus(Fhat)
Shat      # the estimated bandwidth matrix
Fhat      # the spectral estimator for the window chosen
FhatPlus  # this is the nonnegative definite spectral estimator
```









