Drift correction for geochemical data

4 次查看(过去 30 天)
I'm working on a code to automate data processing. Towards the end of my code, I need to determine if isotope data has drifted throughout the course of the analysis. Data are attached.
The first column of the data – fiji(:,1) – shows the line number of the analysis (each measurement is a new line)
The fourth column of the data – fiji(:,4) – shows the geochemical value for each measurement
What I need help with is a succinct way to determine if the slope of the drift is significantly different from zero. If the slope is not different from zero, then we don't need to worry about drift. If it is different from zero, I'll look at the R^2 value to determine if I want to proceed from a drift correction (already included in the code_.
Any insight about coding up if the slope is different from zero would be very appreciated. My first instinct was to use ANOVA, but I'm not sure how to apply it to this dataset.
Thanks!!
fiji = readtable("fiji.csv");
fiji = table2array(fiji);
%Calculate drift correction
drift_d18O = fitlm(fiji(:,1), fiji(:,4));
drift_d18O_slope = drift_d18O.Coefficients{2,1};
drift_d18O_intercept = drift_d18O.Coefficients{1,1};
%%If drift slope is significantly different from zero, then check R^2 below
%%If drift not significantly different from zero, stop analysis here & skip
%%to end
if (drift_d18O.Rsquared.Adjusted > 0.7)
disp('R squared indicates there IS significant d18O drift')
else
disp('R squared indicates there IS NOT significant d18O drift')
end
%Plot the drift correction
figure(1)
scatter(fiji(:,1), fiji(:,4));
%drift functions
function d = drift_d18O_func(x, d18O_slope, d18O_intercept)
d = x.*d18O_slope+d18O_intercept;
end

采纳的回答

Star Strider
Star Strider 2023-6-16
First, plot the data —
fiji = readmatrix('fiji.csv')
fiji = 12×8
1.0e+04 * 0.0040 0.0007 0.0004 -0.0005 -0.0026 1.6368 0.0000 0.0001 0.0041 0.0007 0.0005 -0.0005 -0.0026 1.6379 0.0000 0.0001 0.0042 0.0007 0.0006 -0.0005 -0.0026 1.6377 0.0000 0.0001 0.0178 0.0007 0.0004 -0.0005 -0.0025 1.6268 0.0000 0.0001 0.0179 0.0007 0.0005 -0.0005 -0.0025 1.6169 0.0000 0.0001 0.0180 0.0007 0.0006 -0.0005 -0.0025 1.6244 0.0000 0.0001 0.0316 0.0007 0.0004 -0.0005 -0.0025 1.6219 0.0000 0.0001 0.0317 0.0007 0.0005 -0.0005 -0.0025 1.6212 0.0000 0.0001 0.0318 0.0007 0.0006 -0.0005 -0.0025 1.6093 0.0000 0.0001 0.0454 0.0007 0.0004 -0.0005 -0.0024 1.6252 0.0000 0.0001
Col1 = fiji(:,1)
Col1 = 12×1
40 41 42 178 179 180 316 317 318 454
Col4 = fiji(:,4)
Col4 = 12×1
-5.0754 -5.0321 -5.0472 -5.0311 -5.0261 -5.1097 -4.9596 -5.1198 -5.0885 -5.1389
% d4d1 = gradient(fiji(:,4)) ./ gradient(fiji(:,1));
figure
plot(fiji(:,1), fiji(:,4), '.-')
xlabel('Col #1')
ylabel('Col #4')
grid
What do you want to get from these data?
I doubt that a linear fit will provide any useful information.
.
  4 个评论
Emily
Emily 2023-6-16
Thank you! I may be misunderstanding but I think it should be the reverse? If the p value < 0.05 then the drift IS significant because the slope is significant?
Star Strider
Star Strider 2023-6-16
My pleasure!
If the p-statistic is less than 0.05, the slope is significantly different from zero, so the inequality test should be reversed in that test. (I didn’t read the code carefully enough.)

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by