Trying to plot correlogram of time series data

33 Ansichten (letzte 30 Tage)
Nathaniel Porter
Nathaniel Porter am 19 Dez. 2021
Beantwortet: Star Strider am 19 Dez. 2021
%Plot of entire patient one time series
load ('glucose.mat')
glucose_mgdl = glucose * 18;
plot(date1+time,glucose_mgdl),
xlabel('Days'), ylabel('Glucose')
title('Glucose readings vs days/time')
M = mean(glucose_mgdl)
M = 183.4936
S = std(glucose_mgdl)
S = 87.6448
%now get the PDF
figure
[D PD] = allfitdist(glucose_mgdl,'PDF');
Unrecognized function or variable 'allfitdist'.
xlabel('Data (mgdL)');
%now get the CDF
figure
[D PD] = allfitdist(glucose_mgdl,'CDF');
xlabel('Data(mgdL)')
%Plot of correlogram
r = xcorr(date1+time,glucose_mgdl)

Akzeptierte Antwort

Star Strider
Star Strider am 19 Dez. 2021
Essentially all physiological variables are lognormally distributed. This is inutitively obvious because physiological variables can only take on positive values (so any distributions having infinite support are not applicable), and mathematically obvious by comparing the fit to a normal (or any other) and lognormal distribution, and can be supported mathematically with appropriate goodness-of-fit tests.
Calculating and plotting the autocorrelation is the best I can do with those data.
I also corrected the distribution —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/838690/glucose.csv', 'VariableNamingRule','preserve')
T1 = 1438×5 table
date time glucose type comments __________ ________ _______ __________ ________ 2014-10-01 19:14:00 10.3 {'cgm' } NaN 2014-10-01 19:19:00 9.9 {'cgm' } NaN 2014-10-01 19:23:00 9.4 {'manual'} NaN 2014-10-01 19:24:00 9.8 {'cgm' } NaN 2014-10-01 19:29:00 9.6 {'cgm' } NaN 2014-10-01 19:34:00 9.4 {'cgm' } NaN 2014-10-01 19:39:00 9.2 {'cgm' } NaN 2014-10-01 19:44:00 8.9 {'cgm' } NaN 2014-10-01 19:49:00 8.7 {'cgm' } NaN 2014-10-01 19:54:00 8.4 {'cgm' } NaN 2014-10-01 19:59:00 8.2 {'cgm' } NaN 2014-10-01 20:04:00 8 {'cgm' } NaN 2014-10-01 20:09:00 7.9 {'cgm' } NaN 2014-10-01 20:14:00 7.9 {'cgm' } NaN 2014-10-01 20:19:00 7.8 {'cgm' } NaN 2014-10-01 20:24:00 7.8 {'cgm' } NaN
d_t = T1.date+T1.time;
Glc = T1.glucose;
figure
plot(d_t, Glc)
grid
xlabel('Time')
ylabel('Plasma GLucose (m\itM\rm)')
title('Original Data')
Glcmx = Glc == max(Glc); % Detect Saturation ('Railed') Data
Glce = Glc(~Glcmx); % Eliminate Saturation ('Railed') Data
d_te = d_t(~Glcmx); % Eliminate Saturation ('Railed') Data
figure
plot(d_te, Glce, '.')
grid
xlabel('Time')
ylabel('Plasma GLucose (m\itM\rm)')
title('Data Without Saturated Values')
figure
histfit(Glce, ceil(numel(Glce)/10), 'lognormal')
grid
pd = fitdist(Glc, 'lognormal')
pd =
LognormalDistribution Lognormal distribution mu = 2.19456 [2.16697, 2.22215] sigma = 0.533301 [0.514498, 0.553542]
Glcmode = mode(Glce)
Glcmode = 2.2000
Glcmedian = median(Glce)
Glcmedian = 9.5000
[r,lags] = xcorr(Glce,'coeff');
figure
plot(lags, r, '.')
grid
xlabel('Lags')
ylabel('Croorelation Coefficient')
title('Autocorrelation')
.

Weitere Antworten (0)

Produkte


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by