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
0 个评论
采纳的回答
Star Strider
2023-6-16
First, plot the data —
fiji = readmatrix('fiji.csv')
Col1 = fiji(:,1)
Col4 = fiji(:,4)
% 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 个评论
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!