Fitting two-dimensional dataHow to fit polynomial curve using Mathematica for multiple inputs?How to perform a multi-peak fitting?Obtaining the envelope of an oscillating function and perform fittingStill more problems with Fitting, please helpHow to find the best fit for given input data?Smoothing out data points in a ListDensityPlotHow to do deconvolution in spectrum with some peaks?Obtaining the interpolation function of a surfaceUsing tables to find values of functions from given dataFind elementary function that fits the dataMulti-peak fitting for peak position
How to foreshadow to avoid a 'deus ex machina'-construction
Efficiently finding furthest two nodes in a graph
Why does Earth need water in the Expanse?
Spider-Man and Fantastic 4 crossover comic with Double Identity Scene
How can Paypal know my card is being used in another account?
Was the Psych theme song written for the show?
Can you continue the movement of a Bonus Action Dash granted by Expeditious Retreat if your Concentration is broken mid-move?
How does Asimov's second law deal with contradictory orders from different people?
May a hotel provide accommodation for fewer people than booked?
Boots or trail runners with reference to blisters?
Are all French verb conjugation tenses and moods practical and efficient?
"Valet parking " or "parking valet"
Coworker mumbles to herself when working, how to ask her to stop?
Typesetting numbers above, below, left, and right of a symbol
Would people understand me speaking German all over Europe?
Can living where Earth magnetic ore is abundant provide any protection?
Using Python in a Bash Script
Applications of pure mathematics in operations research
How can you tell the version of Ubuntu on a system in a .sh (bash) script?
How to innovate in OR
Why are subdominants unstable?
Can machine learning learn a function like finding maximum from a list?
How would a lunar colony attack Earth?
How do discovery writers hibernate?
Fitting two-dimensional data
How to fit polynomial curve using Mathematica for multiple inputs?How to perform a multi-peak fitting?Obtaining the envelope of an oscillating function and perform fittingStill more problems with Fitting, please helpHow to find the best fit for given input data?Smoothing out data points in a ListDensityPlotHow to do deconvolution in spectrum with some peaks?Obtaining the interpolation function of a surfaceUsing tables to find values of functions from given dataFind elementary function that fits the dataMulti-peak fitting for peak position
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
For this question, I cannot use random sample data. So the actual data can be found here. The data file contains three columns, where the first two are the coordinates $(x,y)$, while the third is the value of a function $f$. Now we plot them, thus obtaining the shape of $f$
data = Import["L1.dat", "Table"];
or
data = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
Plot
L0 = ListPlot3D[data]
My question is the following: is there a way to interpolate the data and obtain an analytical fitting function $f(x,y)$? Taking into account that the distribution of $f$ is rather smooth, without peaks and holes, I suppose it should be rather easy to obtain its fitting function. Any ideas?
fitting interpolation data
$endgroup$
add a comment |
$begingroup$
For this question, I cannot use random sample data. So the actual data can be found here. The data file contains three columns, where the first two are the coordinates $(x,y)$, while the third is the value of a function $f$. Now we plot them, thus obtaining the shape of $f$
data = Import["L1.dat", "Table"];
or
data = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
Plot
L0 = ListPlot3D[data]
My question is the following: is there a way to interpolate the data and obtain an analytical fitting function $f(x,y)$? Taking into account that the distribution of $f$ is rather smooth, without peaks and holes, I suppose it should be rather easy to obtain its fitting function. Any ideas?
fitting interpolation data
$endgroup$
$begingroup$
have you triedInterpolation
? E.g.,iF = Interpolation[data];Plot3D[iF[x, y], x, 0, .5, y, 0, 1]
?
$endgroup$
– kglr
Jul 21 at 10:39
$begingroup$
@kglr I want to obtain an analytical equation of the form f = ax^2 + b*y^2 +....
$endgroup$
– Vaggelis_Z
Jul 21 at 10:42
$begingroup$
It's eitherInterpolation
or fit. What is it?
$endgroup$
– rhermans
Jul 21 at 10:54
$begingroup$
Thanks for accepting my answer, but I think you were too hasty doing that. While accepting is one of the things to do after your question is answered, we recommend that users should test answers before voting and wait 24 hours before accepting the best one. That allows people in all timezones to answer your question and an opportunity for other users to point alternatives, caveats or limitations of the available answers. I have edited my answer so you can accept the best one later.
$endgroup$
– rhermans
Jul 21 at 11:28
add a comment |
$begingroup$
For this question, I cannot use random sample data. So the actual data can be found here. The data file contains three columns, where the first two are the coordinates $(x,y)$, while the third is the value of a function $f$. Now we plot them, thus obtaining the shape of $f$
data = Import["L1.dat", "Table"];
or
data = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
Plot
L0 = ListPlot3D[data]
My question is the following: is there a way to interpolate the data and obtain an analytical fitting function $f(x,y)$? Taking into account that the distribution of $f$ is rather smooth, without peaks and holes, I suppose it should be rather easy to obtain its fitting function. Any ideas?
fitting interpolation data
$endgroup$
For this question, I cannot use random sample data. So the actual data can be found here. The data file contains three columns, where the first two are the coordinates $(x,y)$, while the third is the value of a function $f$. Now we plot them, thus obtaining the shape of $f$
data = Import["L1.dat", "Table"];
or
data = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
Plot
L0 = ListPlot3D[data]
My question is the following: is there a way to interpolate the data and obtain an analytical fitting function $f(x,y)$? Taking into account that the distribution of $f$ is rather smooth, without peaks and holes, I suppose it should be rather easy to obtain its fitting function. Any ideas?
fitting interpolation data
fitting interpolation data
edited Jul 21 at 10:53
rhermans
23.5k4 gold badges42 silver badges110 bronze badges
23.5k4 gold badges42 silver badges110 bronze badges
asked Jul 21 at 10:25
Vaggelis_ZVaggelis_Z
3,7662 gold badges24 silver badges58 bronze badges
3,7662 gold badges24 silver badges58 bronze badges
$begingroup$
have you triedInterpolation
? E.g.,iF = Interpolation[data];Plot3D[iF[x, y], x, 0, .5, y, 0, 1]
?
$endgroup$
– kglr
Jul 21 at 10:39
$begingroup$
@kglr I want to obtain an analytical equation of the form f = ax^2 + b*y^2 +....
$endgroup$
– Vaggelis_Z
Jul 21 at 10:42
$begingroup$
It's eitherInterpolation
or fit. What is it?
$endgroup$
– rhermans
Jul 21 at 10:54
$begingroup$
Thanks for accepting my answer, but I think you were too hasty doing that. While accepting is one of the things to do after your question is answered, we recommend that users should test answers before voting and wait 24 hours before accepting the best one. That allows people in all timezones to answer your question and an opportunity for other users to point alternatives, caveats or limitations of the available answers. I have edited my answer so you can accept the best one later.
$endgroup$
– rhermans
Jul 21 at 11:28
add a comment |
$begingroup$
have you triedInterpolation
? E.g.,iF = Interpolation[data];Plot3D[iF[x, y], x, 0, .5, y, 0, 1]
?
$endgroup$
– kglr
Jul 21 at 10:39
$begingroup$
@kglr I want to obtain an analytical equation of the form f = ax^2 + b*y^2 +....
$endgroup$
– Vaggelis_Z
Jul 21 at 10:42
$begingroup$
It's eitherInterpolation
or fit. What is it?
$endgroup$
– rhermans
Jul 21 at 10:54
$begingroup$
Thanks for accepting my answer, but I think you were too hasty doing that. While accepting is one of the things to do after your question is answered, we recommend that users should test answers before voting and wait 24 hours before accepting the best one. That allows people in all timezones to answer your question and an opportunity for other users to point alternatives, caveats or limitations of the available answers. I have edited my answer so you can accept the best one later.
$endgroup$
– rhermans
Jul 21 at 11:28
$begingroup$
have you tried
Interpolation
? E.g., iF = Interpolation[data];Plot3D[iF[x, y], x, 0, .5, y, 0, 1]
?$endgroup$
– kglr
Jul 21 at 10:39
$begingroup$
have you tried
Interpolation
? E.g., iF = Interpolation[data];Plot3D[iF[x, y], x, 0, .5, y, 0, 1]
?$endgroup$
– kglr
Jul 21 at 10:39
$begingroup$
@kglr I want to obtain an analytical equation of the form f = ax^2 + b*y^2 +....
$endgroup$
– Vaggelis_Z
Jul 21 at 10:42
$begingroup$
@kglr I want to obtain an analytical equation of the form f = ax^2 + b*y^2 +....
$endgroup$
– Vaggelis_Z
Jul 21 at 10:42
$begingroup$
It's either
Interpolation
or fit. What is it?$endgroup$
– rhermans
Jul 21 at 10:54
$begingroup$
It's either
Interpolation
or fit. What is it?$endgroup$
– rhermans
Jul 21 at 10:54
$begingroup$
Thanks for accepting my answer, but I think you were too hasty doing that. While accepting is one of the things to do after your question is answered, we recommend that users should test answers before voting and wait 24 hours before accepting the best one. That allows people in all timezones to answer your question and an opportunity for other users to point alternatives, caveats or limitations of the available answers. I have edited my answer so you can accept the best one later.
$endgroup$
– rhermans
Jul 21 at 11:28
$begingroup$
Thanks for accepting my answer, but I think you were too hasty doing that. While accepting is one of the things to do after your question is answered, we recommend that users should test answers before voting and wait 24 hours before accepting the best one. That allows people in all timezones to answer your question and an opportunity for other users to point alternatives, caveats or limitations of the available answers. I have edited my answer so you can accept the best one later.
$endgroup$
– rhermans
Jul 21 at 11:28
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Interpolation
intFunc = With[
order = 1,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
Interpolation[#1, #2, #3 & @@@ dat, InterpolationOrder -> order]
]
Plot3D[
intFunc[x, y]
, x, 0.001, 1/2
, y, 0, 1
, PlotStyle -> Green
]
Fit
fitModel = With[
order = 4,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
LinearModelFit[
dat
, Flatten@Outer[Times, Sequence @@ Transpose@Array[Power[x, y, # - 1] &, order + 1]]
, x, y
]
]
fitModel[x,y]
(* 0.839678 - 3.39587 x + 10.2762 x^2 - 23.2243 x^3 + 18.9954 x^4 -
0.870772 y - 1.85421 x y + 14.7251 x^2 y - 36.8365 x^3 y +
31.9079 x^4 y + 1.78944 y^2 + 5.55233 x y^2 - 43.8506 x^2 y^2 +
111.182 x^3 y^2 - 96.807 x^4 y^2 - 1.99269 y^3 - 5.49884 x y^3 +
46.2492 x^2 y^3 - 118.606 x^3 y^3 + 103.764 x^4 y^3 + 0.819593 y^4 +
1.98819 x y^4 - 17.6815 x^2 y^4 + 45.7184 x^3 y^4 - 40.1317 x^4 y^4 *)
Show[
Plot3D[
fitModel[x, y]
, x, 0, 1/2
, y, 0, 1
, PlotStyle -> Blue
]
, ListPlot3D[
dat
, PlotStyle -> Directive[Red, Opacity[0.5]]
]
]
$endgroup$
$begingroup$
@Vaggelis_Z I think you misunderstand the output ofLinearModelFit
. The fit is linear only on the coefficients. See my edit.
$endgroup$
– rhermans
Jul 21 at 10:59
add a comment |
$begingroup$
Adapting the approach from this answer:
vars = x, y;
maxdegree = 3;
cols = Join @@ (MonomialList[(Plus @@ vars)^#] /. _Integer x_ :> x & /@ Range[maxdegree]);
nparams = 5;
models = Prepend[#, 1] & /@ Subsets[cols, 1, nparams];
Length@models
381
fits = Table[Join[j, Length@j, LinearModelFit[l1dat, j, vars]["BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared"]], j, models]
topTenByAICc = SortBy[fits, #[[4]] &][[;; 10]];
Style[# /. x_Real :> Round[x, .00001]] &@
Grid["Model", "Length", "BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared", ## & @@ topTenByAICc, Dividers -> All]
bestmodel = topTenByAICc[[1, 3]];
Show[Plot3D[bestmodel, x, 0, .6, y, 0, .1, Mesh -> None],
ListPointPlot3D[l1dat, PlotStyle -> Opacity[.5, Red]]]
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f202477%2ffitting-two-dimensional-data%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Interpolation
intFunc = With[
order = 1,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
Interpolation[#1, #2, #3 & @@@ dat, InterpolationOrder -> order]
]
Plot3D[
intFunc[x, y]
, x, 0.001, 1/2
, y, 0, 1
, PlotStyle -> Green
]
Fit
fitModel = With[
order = 4,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
LinearModelFit[
dat
, Flatten@Outer[Times, Sequence @@ Transpose@Array[Power[x, y, # - 1] &, order + 1]]
, x, y
]
]
fitModel[x,y]
(* 0.839678 - 3.39587 x + 10.2762 x^2 - 23.2243 x^3 + 18.9954 x^4 -
0.870772 y - 1.85421 x y + 14.7251 x^2 y - 36.8365 x^3 y +
31.9079 x^4 y + 1.78944 y^2 + 5.55233 x y^2 - 43.8506 x^2 y^2 +
111.182 x^3 y^2 - 96.807 x^4 y^2 - 1.99269 y^3 - 5.49884 x y^3 +
46.2492 x^2 y^3 - 118.606 x^3 y^3 + 103.764 x^4 y^3 + 0.819593 y^4 +
1.98819 x y^4 - 17.6815 x^2 y^4 + 45.7184 x^3 y^4 - 40.1317 x^4 y^4 *)
Show[
Plot3D[
fitModel[x, y]
, x, 0, 1/2
, y, 0, 1
, PlotStyle -> Blue
]
, ListPlot3D[
dat
, PlotStyle -> Directive[Red, Opacity[0.5]]
]
]
$endgroup$
$begingroup$
@Vaggelis_Z I think you misunderstand the output ofLinearModelFit
. The fit is linear only on the coefficients. See my edit.
$endgroup$
– rhermans
Jul 21 at 10:59
add a comment |
$begingroup$
Interpolation
intFunc = With[
order = 1,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
Interpolation[#1, #2, #3 & @@@ dat, InterpolationOrder -> order]
]
Plot3D[
intFunc[x, y]
, x, 0.001, 1/2
, y, 0, 1
, PlotStyle -> Green
]
Fit
fitModel = With[
order = 4,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
LinearModelFit[
dat
, Flatten@Outer[Times, Sequence @@ Transpose@Array[Power[x, y, # - 1] &, order + 1]]
, x, y
]
]
fitModel[x,y]
(* 0.839678 - 3.39587 x + 10.2762 x^2 - 23.2243 x^3 + 18.9954 x^4 -
0.870772 y - 1.85421 x y + 14.7251 x^2 y - 36.8365 x^3 y +
31.9079 x^4 y + 1.78944 y^2 + 5.55233 x y^2 - 43.8506 x^2 y^2 +
111.182 x^3 y^2 - 96.807 x^4 y^2 - 1.99269 y^3 - 5.49884 x y^3 +
46.2492 x^2 y^3 - 118.606 x^3 y^3 + 103.764 x^4 y^3 + 0.819593 y^4 +
1.98819 x y^4 - 17.6815 x^2 y^4 + 45.7184 x^3 y^4 - 40.1317 x^4 y^4 *)
Show[
Plot3D[
fitModel[x, y]
, x, 0, 1/2
, y, 0, 1
, PlotStyle -> Blue
]
, ListPlot3D[
dat
, PlotStyle -> Directive[Red, Opacity[0.5]]
]
]
$endgroup$
$begingroup$
@Vaggelis_Z I think you misunderstand the output ofLinearModelFit
. The fit is linear only on the coefficients. See my edit.
$endgroup$
– rhermans
Jul 21 at 10:59
add a comment |
$begingroup$
Interpolation
intFunc = With[
order = 1,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
Interpolation[#1, #2, #3 & @@@ dat, InterpolationOrder -> order]
]
Plot3D[
intFunc[x, y]
, x, 0.001, 1/2
, y, 0, 1
, PlotStyle -> Green
]
Fit
fitModel = With[
order = 4,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
LinearModelFit[
dat
, Flatten@Outer[Times, Sequence @@ Transpose@Array[Power[x, y, # - 1] &, order + 1]]
, x, y
]
]
fitModel[x,y]
(* 0.839678 - 3.39587 x + 10.2762 x^2 - 23.2243 x^3 + 18.9954 x^4 -
0.870772 y - 1.85421 x y + 14.7251 x^2 y - 36.8365 x^3 y +
31.9079 x^4 y + 1.78944 y^2 + 5.55233 x y^2 - 43.8506 x^2 y^2 +
111.182 x^3 y^2 - 96.807 x^4 y^2 - 1.99269 y^3 - 5.49884 x y^3 +
46.2492 x^2 y^3 - 118.606 x^3 y^3 + 103.764 x^4 y^3 + 0.819593 y^4 +
1.98819 x y^4 - 17.6815 x^2 y^4 + 45.7184 x^3 y^4 - 40.1317 x^4 y^4 *)
Show[
Plot3D[
fitModel[x, y]
, x, 0, 1/2
, y, 0, 1
, PlotStyle -> Blue
]
, ListPlot3D[
dat
, PlotStyle -> Directive[Red, Opacity[0.5]]
]
]
$endgroup$
Interpolation
intFunc = With[
order = 1,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
Interpolation[#1, #2, #3 & @@@ dat, InterpolationOrder -> order]
]
Plot3D[
intFunc[x, y]
, x, 0.001, 1/2
, y, 0, 1
, PlotStyle -> Green
]
Fit
fitModel = With[
order = 4,
dat = Import["https://pastebin.com/raw/YMCFB4mK", "TSV"]
,
LinearModelFit[
dat
, Flatten@Outer[Times, Sequence @@ Transpose@Array[Power[x, y, # - 1] &, order + 1]]
, x, y
]
]
fitModel[x,y]
(* 0.839678 - 3.39587 x + 10.2762 x^2 - 23.2243 x^3 + 18.9954 x^4 -
0.870772 y - 1.85421 x y + 14.7251 x^2 y - 36.8365 x^3 y +
31.9079 x^4 y + 1.78944 y^2 + 5.55233 x y^2 - 43.8506 x^2 y^2 +
111.182 x^3 y^2 - 96.807 x^4 y^2 - 1.99269 y^3 - 5.49884 x y^3 +
46.2492 x^2 y^3 - 118.606 x^3 y^3 + 103.764 x^4 y^3 + 0.819593 y^4 +
1.98819 x y^4 - 17.6815 x^2 y^4 + 45.7184 x^3 y^4 - 40.1317 x^4 y^4 *)
Show[
Plot3D[
fitModel[x, y]
, x, 0, 1/2
, y, 0, 1
, PlotStyle -> Blue
]
, ListPlot3D[
dat
, PlotStyle -> Directive[Red, Opacity[0.5]]
]
]
edited Jul 21 at 11:25
answered Jul 21 at 10:52
rhermansrhermans
23.5k4 gold badges42 silver badges110 bronze badges
23.5k4 gold badges42 silver badges110 bronze badges
$begingroup$
@Vaggelis_Z I think you misunderstand the output ofLinearModelFit
. The fit is linear only on the coefficients. See my edit.
$endgroup$
– rhermans
Jul 21 at 10:59
add a comment |
$begingroup$
@Vaggelis_Z I think you misunderstand the output ofLinearModelFit
. The fit is linear only on the coefficients. See my edit.
$endgroup$
– rhermans
Jul 21 at 10:59
$begingroup$
@Vaggelis_Z I think you misunderstand the output of
LinearModelFit
. The fit is linear only on the coefficients. See my edit.$endgroup$
– rhermans
Jul 21 at 10:59
$begingroup$
@Vaggelis_Z I think you misunderstand the output of
LinearModelFit
. The fit is linear only on the coefficients. See my edit.$endgroup$
– rhermans
Jul 21 at 10:59
add a comment |
$begingroup$
Adapting the approach from this answer:
vars = x, y;
maxdegree = 3;
cols = Join @@ (MonomialList[(Plus @@ vars)^#] /. _Integer x_ :> x & /@ Range[maxdegree]);
nparams = 5;
models = Prepend[#, 1] & /@ Subsets[cols, 1, nparams];
Length@models
381
fits = Table[Join[j, Length@j, LinearModelFit[l1dat, j, vars]["BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared"]], j, models]
topTenByAICc = SortBy[fits, #[[4]] &][[;; 10]];
Style[# /. x_Real :> Round[x, .00001]] &@
Grid["Model", "Length", "BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared", ## & @@ topTenByAICc, Dividers -> All]
bestmodel = topTenByAICc[[1, 3]];
Show[Plot3D[bestmodel, x, 0, .6, y, 0, .1, Mesh -> None],
ListPointPlot3D[l1dat, PlotStyle -> Opacity[.5, Red]]]
$endgroup$
add a comment |
$begingroup$
Adapting the approach from this answer:
vars = x, y;
maxdegree = 3;
cols = Join @@ (MonomialList[(Plus @@ vars)^#] /. _Integer x_ :> x & /@ Range[maxdegree]);
nparams = 5;
models = Prepend[#, 1] & /@ Subsets[cols, 1, nparams];
Length@models
381
fits = Table[Join[j, Length@j, LinearModelFit[l1dat, j, vars]["BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared"]], j, models]
topTenByAICc = SortBy[fits, #[[4]] &][[;; 10]];
Style[# /. x_Real :> Round[x, .00001]] &@
Grid["Model", "Length", "BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared", ## & @@ topTenByAICc, Dividers -> All]
bestmodel = topTenByAICc[[1, 3]];
Show[Plot3D[bestmodel, x, 0, .6, y, 0, .1, Mesh -> None],
ListPointPlot3D[l1dat, PlotStyle -> Opacity[.5, Red]]]
$endgroup$
add a comment |
$begingroup$
Adapting the approach from this answer:
vars = x, y;
maxdegree = 3;
cols = Join @@ (MonomialList[(Plus @@ vars)^#] /. _Integer x_ :> x & /@ Range[maxdegree]);
nparams = 5;
models = Prepend[#, 1] & /@ Subsets[cols, 1, nparams];
Length@models
381
fits = Table[Join[j, Length@j, LinearModelFit[l1dat, j, vars]["BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared"]], j, models]
topTenByAICc = SortBy[fits, #[[4]] &][[;; 10]];
Style[# /. x_Real :> Round[x, .00001]] &@
Grid["Model", "Length", "BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared", ## & @@ topTenByAICc, Dividers -> All]
bestmodel = topTenByAICc[[1, 3]];
Show[Plot3D[bestmodel, x, 0, .6, y, 0, .1, Mesh -> None],
ListPointPlot3D[l1dat, PlotStyle -> Opacity[.5, Red]]]
$endgroup$
Adapting the approach from this answer:
vars = x, y;
maxdegree = 3;
cols = Join @@ (MonomialList[(Plus @@ vars)^#] /. _Integer x_ :> x & /@ Range[maxdegree]);
nparams = 5;
models = Prepend[#, 1] & /@ Subsets[cols, 1, nparams];
Length@models
381
fits = Table[Join[j, Length@j, LinearModelFit[l1dat, j, vars]["BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared"]], j, models]
topTenByAICc = SortBy[fits, #[[4]] &][[;; 10]];
Style[# /. x_Real :> Round[x, .00001]] &@
Grid["Model", "Length", "BestFit", "AICc", "BIC",
"AdjustedRSquared", "RSquared", ## & @@ topTenByAICc, Dividers -> All]
bestmodel = topTenByAICc[[1, 3]];
Show[Plot3D[bestmodel, x, 0, .6, y, 0, .1, Mesh -> None],
ListPointPlot3D[l1dat, PlotStyle -> Opacity[.5, Red]]]
edited Jul 21 at 11:16
answered Jul 21 at 11:10
kglrkglr
208k10 gold badges239 silver badges473 bronze badges
208k10 gold badges239 silver badges473 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f202477%2ffitting-two-dimensional-data%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
have you tried
Interpolation
? E.g.,iF = Interpolation[data];Plot3D[iF[x, y], x, 0, .5, y, 0, 1]
?$endgroup$
– kglr
Jul 21 at 10:39
$begingroup$
@kglr I want to obtain an analytical equation of the form f = ax^2 + b*y^2 +....
$endgroup$
– Vaggelis_Z
Jul 21 at 10:42
$begingroup$
It's either
Interpolation
or fit. What is it?$endgroup$
– rhermans
Jul 21 at 10:54
$begingroup$
Thanks for accepting my answer, but I think you were too hasty doing that. While accepting is one of the things to do after your question is answered, we recommend that users should test answers before voting and wait 24 hours before accepting the best one. That allows people in all timezones to answer your question and an opportunity for other users to point alternatives, caveats or limitations of the available answers. I have edited my answer so you can accept the best one later.
$endgroup$
– rhermans
Jul 21 at 11:28