From 4ad38fd49e1b508f45bd1f446bb36cca76873a47 Mon Sep 17 00:00:00 2001 From: Suraj Yerramilli Date: Tue, 23 Feb 2016 15:07:50 +0530 Subject: computing noise power spectrum --- R/nonparam.R | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'R/nonparam.R') diff --git a/R/nonparam.R b/R/nonparam.R index 18451f4..0a7e194 100644 --- a/R/nonparam.R +++ b/R/nonparam.R @@ -168,18 +168,22 @@ step <- function(model){ #' data(frf) #' frf <- spa(data) #' +#' @import sapa #' @export spa <- function(data,npad=255){ - require(sapa) temp <- cbind(data$output,data$input) # Non-parametric Estimation of Spectral Densities - # WOSA and Hanning window - gamma <- SDF(temp,method="wosa",sampling.interval = deltat(data), - npad=npad) + gamma <- sapa::SDF(temp,method="wosa",sampling.interval = + deltat(data),npad=npad) freq <- attributes(gamma)$frequency*2*pi - out <- idfrd(response = Conj(gamma[,2])/Mod(gamma[,3]),freq=freq, - Ts= deltat(data)) + resp <- Conj(gamma[,2])/Mod(gamma[,3]) + + # power-spectrum + spec <- gamma[,2] - resp*gamma[,3] + + out <- idfrd(resp,freq,deltat(data),spec) return(out) } -- cgit