SCM

Forum: open-discussion

Monitor Forum | Start New Thread Start New Thread
Problem calculating CorrDim and SpEn [ Reply ]
By: Tomas FariƱa on 2023-06-27 09:04
[forum:49696]

ECG_9-ing_final.csv (4) downloads
I had an error when estimating correlation dimension and, then SpEn. I doesn't appear with every sample. I found that it has to be with NaNs but after checking all the previous code I can't get to run.
I recorded using 500 Hz.

Any help would be apreciated.

data("HRVData")
# HRVData structure storing the results of processing the
# heart beats: the beats have been filtered, interpolated, ...
data("HRVProcessedData")

hrv.data = CreateHRVData()
hrv.data = SetVerbose(hrv.data, TRUE )

hrv.data = LoadBeatAscii(hrv.data, "ECG_9-ing_final.csv")

hrv.data = BuildNIHR(hrv.data)

hrv.data = FilterNIHR(hrv.data)
hrv.data = FilterNIHR(hrv.data)
hrv.data = SetVerbose(hrv.data,TRUE)
hrv.data = EditNIHR(hrv.data)
PlotNIHR(hrv.data, main = "niHR Pac 9 admission day")


#Analisis dominio tiempo toda la muestra#
hrv.data=CreateTimeAnalysis(hrv.data,size =300)

#Analisis no lineal#
hrv.data=CreateNonLinearAnalysis(hrv.data)
hrv.data=NonlinearityTests(hrv.data)

asymmetryStatistic<-function(x){x.len=length(x)
mean(x[1:(x.len-1)]*x[2:(x.len)]^2-x[1:(x.len-1)]^2*x[2:(x.len)])}

hrv.data=SurrogateTest(hrv.data,
main=
"Surrogate data testing Pac 9 admission day",oneSided = F,significance = 0.01,K=5,useFunction = asymmetryStatistic,doPlot=T)


kTimeLag=CalculateTimeLag(hrv.data,technique="ami",lagMax=100,doPlot=T)

kEmbeddingDim=CalculateEmbeddingDim(hrv.data,numberPoints = 10000,timeLag = kTimeLag,maxEmbeddingDim = 20)

#Correlacion clasica#
hrv.data=CalculateCorrDim(hrv.data,indexNonLinearAnalysis = 1,minEmbeddingDim = kEmbeddingDim,maxEmbeddingDim = kEmbeddingDim+5,timeLag = kTimeLag,minRadius = 50,maxRadius = 100,pointsRadius = 100,theilerWindow = 20,doPlot = T)

corr.struct=hrv.data$NonLinearAnalysis[[1]]$correlation
corrSum=corr.struct$computations
radius=corrSum$radius
embeddingDims=corrSum$embedding.dims


#Entropia#
hrv.data=CreateNonLinearAnalysis(hrv.data)
hrv.data=CalculateCorrDim(hrv.data,indexNonLinearAnalysis = 2,minEmbeddingDim = kEmbeddingDim,maxEmbeddingDim = kEmbeddingDim+5,timeLag = kTimeLag,minRadius = 50,maxRadius = 100,pointsRadius = 100,theilerWindow = 20,doPlot = T)

#If it looks like a ladder, denoising#
hrv.data=NonLinearNoiseReduction(hrv.data, embeddingDim =kEmbeddingDim,radius=NULL)
hrv.data=CalculateCorrDim(hrv.data,indexNonLinearAnalysis = 2,minEmbeddingDim = kEmbeddingDim,maxEmbeddingDim = kEmbeddingDim+5,timeLag = kTimeLag,minRadius = 50,maxRadius = 100,pointsRadius = 100,theilerWindow = 20,doPlot = T)

##Revisar embeddings Dims##

EstimateCorrDim(hrv.data,indexNonLinearAnalysis = 2,
useEmbeddings = c(10:15),regressionRange = c(10:15))

THIS IS THE ERROR I GET:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases

Thanks to:
Vienna University of Economics and Business Powered By FusionForge