I am quite new using Mathematica, I hope someone could give me some help.
I have a set of {x, y} data and I have a list of {deltaX, deltaY} standard deviation. I would like to fit my data taking into account these errors using LinearModelFit
. I read that it exists an option for LinearModelFit
, the Weights
option, that could help, but I do not understand clearly how it works.
Here are my sets:
data = {{1288.7, -2.72121*10^6}, {1282.57, -2.60185*10^6}, {1360.81, -2.8577*10^6}};
Error = {{67.8667, 22817.}, {143.199, 21887.}, {99.6321, 24340.2}};
To do the fit and to plot the results, I attempted the following:
fit = LinearModelFit[data, {1, z}, z, Weights -> 1/Error^2]
fit["BestFitParameters"]
fit["ParameterTable"]
fit["AdjustedRSquared"]
Show[
ListPlot[data, PlotRange -> {{0, 1500}, {-10*10^6, 10*10^6}}],
Plot[Normal[fit], {z, 0, 1500}, PlotStyle -> {Thin, Red}]
]
This did not work: apparently I do not use the Weights
option correctly.
Thank you for your help