Properties of an arbitrary (i.e., not fitted) statistical model

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2














Suppose that I have a data and a statistical model that is not the result of fitting, but has a different origin. For example, I have a list of measurements and a theoretical model whose predicting accuracy I want to assess.



Is there a simple way to obtain all the properties of a FittedModel object, but from my theoretical model?



For example, suppose that



mt=Table[i,1+i+RandomReal,i,5]


yields mt=1,2.56508,2,3.58291,3,4.8005,4,5.24265,5,6.38087



If I call



LinearModelFit[mt,x,x]


I get



FittedModel[1.72701 +0.929131 x]



And I can then get R$^2$ for the adjusted model:



%["RSquared"]


which gives $0.9851$.



But I know the theoretical model is $1.5+x$. Can I have the power of a FittedModel (residuals, ANOVA, RSquared, etc.) for my non-fitted model?










share|improve this question























  • If you look at FullForm[LinearModelFit[mt,x,x]] from your example above then the internal structure seems reasonably simple and understandable. What happens if you carefully build a FittedModel using that structure as an example, not by doing a fit but by substituting your theoretical model in that and then you query that constructed FittedModel for residuals, ANOVA, etc? Can you do this on test cases where you know what the calculations should show to verify that this is being done correctly?
    – Bill
    Dec 21 '18 at 22:04
















2














Suppose that I have a data and a statistical model that is not the result of fitting, but has a different origin. For example, I have a list of measurements and a theoretical model whose predicting accuracy I want to assess.



Is there a simple way to obtain all the properties of a FittedModel object, but from my theoretical model?



For example, suppose that



mt=Table[i,1+i+RandomReal,i,5]


yields mt=1,2.56508,2,3.58291,3,4.8005,4,5.24265,5,6.38087



If I call



LinearModelFit[mt,x,x]


I get



FittedModel[1.72701 +0.929131 x]



And I can then get R$^2$ for the adjusted model:



%["RSquared"]


which gives $0.9851$.



But I know the theoretical model is $1.5+x$. Can I have the power of a FittedModel (residuals, ANOVA, RSquared, etc.) for my non-fitted model?










share|improve this question























  • If you look at FullForm[LinearModelFit[mt,x,x]] from your example above then the internal structure seems reasonably simple and understandable. What happens if you carefully build a FittedModel using that structure as an example, not by doing a fit but by substituting your theoretical model in that and then you query that constructed FittedModel for residuals, ANOVA, etc? Can you do this on test cases where you know what the calculations should show to verify that this is being done correctly?
    – Bill
    Dec 21 '18 at 22:04














2












2








2


1





Suppose that I have a data and a statistical model that is not the result of fitting, but has a different origin. For example, I have a list of measurements and a theoretical model whose predicting accuracy I want to assess.



Is there a simple way to obtain all the properties of a FittedModel object, but from my theoretical model?



For example, suppose that



mt=Table[i,1+i+RandomReal,i,5]


yields mt=1,2.56508,2,3.58291,3,4.8005,4,5.24265,5,6.38087



If I call



LinearModelFit[mt,x,x]


I get



FittedModel[1.72701 +0.929131 x]



And I can then get R$^2$ for the adjusted model:



%["RSquared"]


which gives $0.9851$.



But I know the theoretical model is $1.5+x$. Can I have the power of a FittedModel (residuals, ANOVA, RSquared, etc.) for my non-fitted model?










share|improve this question















Suppose that I have a data and a statistical model that is not the result of fitting, but has a different origin. For example, I have a list of measurements and a theoretical model whose predicting accuracy I want to assess.



Is there a simple way to obtain all the properties of a FittedModel object, but from my theoretical model?



For example, suppose that



mt=Table[i,1+i+RandomReal,i,5]


yields mt=1,2.56508,2,3.58291,3,4.8005,4,5.24265,5,6.38087



If I call



LinearModelFit[mt,x,x]


I get



FittedModel[1.72701 +0.929131 x]



And I can then get R$^2$ for the adjusted model:



%["RSquared"]


which gives $0.9851$.



But I know the theoretical model is $1.5+x$. Can I have the power of a FittedModel (residuals, ANOVA, RSquared, etc.) for my non-fitted model?







probability-or-statistics fitting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 22 '18 at 17:00









Michael E2

145k11195464




145k11195464










asked Dec 21 '18 at 18:17









Rafael

18329




18329











  • If you look at FullForm[LinearModelFit[mt,x,x]] from your example above then the internal structure seems reasonably simple and understandable. What happens if you carefully build a FittedModel using that structure as an example, not by doing a fit but by substituting your theoretical model in that and then you query that constructed FittedModel for residuals, ANOVA, etc? Can you do this on test cases where you know what the calculations should show to verify that this is being done correctly?
    – Bill
    Dec 21 '18 at 22:04

















  • If you look at FullForm[LinearModelFit[mt,x,x]] from your example above then the internal structure seems reasonably simple and understandable. What happens if you carefully build a FittedModel using that structure as an example, not by doing a fit but by substituting your theoretical model in that and then you query that constructed FittedModel for residuals, ANOVA, etc? Can you do this on test cases where you know what the calculations should show to verify that this is being done correctly?
    – Bill
    Dec 21 '18 at 22:04
















If you look at FullForm[LinearModelFit[mt,x,x]] from your example above then the internal structure seems reasonably simple and understandable. What happens if you carefully build a FittedModel using that structure as an example, not by doing a fit but by substituting your theoretical model in that and then you query that constructed FittedModel for residuals, ANOVA, etc? Can you do this on test cases where you know what the calculations should show to verify that this is being done correctly?
– Bill
Dec 21 '18 at 22:04





If you look at FullForm[LinearModelFit[mt,x,x]] from your example above then the internal structure seems reasonably simple and understandable. What happens if you carefully build a FittedModel using that structure as an example, not by doing a fit but by substituting your theoretical model in that and then you query that constructed FittedModel for residuals, ANOVA, etc? Can you do this on test cases where you know what the calculations should show to verify that this is being done correctly?
– Bill
Dec 21 '18 at 22:04











1 Answer
1






active

oldest

votes


















8














You can use NonlinearModelFit but not all output options will either be appropriate and some will require "adjustment".



All of the fitting procedures want to estimate parameters (that's what they're made for) so NonlinearModelFit can be tricked by included a parameter that isn't in the model. Here I used a parameter named a:



SeedRandom[12345];
mt = Table[i, 1 + i + RandomReal, i, 5]
nlm = NonlinearModelFit[mt, 1.5 + x, a, x]


So the following work fine with no adjustment needed:



nlm["FitResiduals"]
(* -0.378754, -0.170078, 0.282753, -0.0698316, -0.276414 *)
nlm["PredictedResponse"]
(* 2.5, 3.5, 4.5, 5.5, 6.5 *)


The "EstimatedVariance" needs adjustment:



Mean[(mt[[All, 2]] - 1.5 - mt[[All, 1]])^2]
(* 0.0667223 *)
n = Length[mt];
nlm["EstimatedVariance"] (n - 1)/n
(* 0.0667223 *)





share|improve this answer




















  • Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
    – Rafael
    Dec 21 '18 at 19:55







  • 2




    Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
    – JimB
    Dec 21 '18 at 20:14










Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188290%2fproperties-of-an-arbitrary-i-e-not-fitted-statistical-model%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









8














You can use NonlinearModelFit but not all output options will either be appropriate and some will require "adjustment".



All of the fitting procedures want to estimate parameters (that's what they're made for) so NonlinearModelFit can be tricked by included a parameter that isn't in the model. Here I used a parameter named a:



SeedRandom[12345];
mt = Table[i, 1 + i + RandomReal, i, 5]
nlm = NonlinearModelFit[mt, 1.5 + x, a, x]


So the following work fine with no adjustment needed:



nlm["FitResiduals"]
(* -0.378754, -0.170078, 0.282753, -0.0698316, -0.276414 *)
nlm["PredictedResponse"]
(* 2.5, 3.5, 4.5, 5.5, 6.5 *)


The "EstimatedVariance" needs adjustment:



Mean[(mt[[All, 2]] - 1.5 - mt[[All, 1]])^2]
(* 0.0667223 *)
n = Length[mt];
nlm["EstimatedVariance"] (n - 1)/n
(* 0.0667223 *)





share|improve this answer




















  • Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
    – Rafael
    Dec 21 '18 at 19:55







  • 2




    Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
    – JimB
    Dec 21 '18 at 20:14















8














You can use NonlinearModelFit but not all output options will either be appropriate and some will require "adjustment".



All of the fitting procedures want to estimate parameters (that's what they're made for) so NonlinearModelFit can be tricked by included a parameter that isn't in the model. Here I used a parameter named a:



SeedRandom[12345];
mt = Table[i, 1 + i + RandomReal, i, 5]
nlm = NonlinearModelFit[mt, 1.5 + x, a, x]


So the following work fine with no adjustment needed:



nlm["FitResiduals"]
(* -0.378754, -0.170078, 0.282753, -0.0698316, -0.276414 *)
nlm["PredictedResponse"]
(* 2.5, 3.5, 4.5, 5.5, 6.5 *)


The "EstimatedVariance" needs adjustment:



Mean[(mt[[All, 2]] - 1.5 - mt[[All, 1]])^2]
(* 0.0667223 *)
n = Length[mt];
nlm["EstimatedVariance"] (n - 1)/n
(* 0.0667223 *)





share|improve this answer




















  • Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
    – Rafael
    Dec 21 '18 at 19:55







  • 2




    Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
    – JimB
    Dec 21 '18 at 20:14













8












8








8






You can use NonlinearModelFit but not all output options will either be appropriate and some will require "adjustment".



All of the fitting procedures want to estimate parameters (that's what they're made for) so NonlinearModelFit can be tricked by included a parameter that isn't in the model. Here I used a parameter named a:



SeedRandom[12345];
mt = Table[i, 1 + i + RandomReal, i, 5]
nlm = NonlinearModelFit[mt, 1.5 + x, a, x]


So the following work fine with no adjustment needed:



nlm["FitResiduals"]
(* -0.378754, -0.170078, 0.282753, -0.0698316, -0.276414 *)
nlm["PredictedResponse"]
(* 2.5, 3.5, 4.5, 5.5, 6.5 *)


The "EstimatedVariance" needs adjustment:



Mean[(mt[[All, 2]] - 1.5 - mt[[All, 1]])^2]
(* 0.0667223 *)
n = Length[mt];
nlm["EstimatedVariance"] (n - 1)/n
(* 0.0667223 *)





share|improve this answer












You can use NonlinearModelFit but not all output options will either be appropriate and some will require "adjustment".



All of the fitting procedures want to estimate parameters (that's what they're made for) so NonlinearModelFit can be tricked by included a parameter that isn't in the model. Here I used a parameter named a:



SeedRandom[12345];
mt = Table[i, 1 + i + RandomReal, i, 5]
nlm = NonlinearModelFit[mt, 1.5 + x, a, x]


So the following work fine with no adjustment needed:



nlm["FitResiduals"]
(* -0.378754, -0.170078, 0.282753, -0.0698316, -0.276414 *)
nlm["PredictedResponse"]
(* 2.5, 3.5, 4.5, 5.5, 6.5 *)


The "EstimatedVariance" needs adjustment:



Mean[(mt[[All, 2]] - 1.5 - mt[[All, 1]])^2]
(* 0.0667223 *)
n = Length[mt];
nlm["EstimatedVariance"] (n - 1)/n
(* 0.0667223 *)






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 21 '18 at 19:28









JimB

16.9k12662




16.9k12662











  • Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
    – Rafael
    Dec 21 '18 at 19:55







  • 2




    Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
    – JimB
    Dec 21 '18 at 20:14
















  • Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
    – Rafael
    Dec 21 '18 at 19:55







  • 2




    Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
    – JimB
    Dec 21 '18 at 20:14















Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
– Rafael
Dec 21 '18 at 19:55





Nice! You get some information on the dummy model/parameter a (in the ANOVA, ParameterTable, etc.), is it possible to get such information for my coefficients (i.e., 1.5 and 1)? Or is all that kind of information just meaningless for a non-fitted model?
– Rafael
Dec 21 '18 at 19:55





2




2




Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
– JimB
Dec 21 '18 at 20:14




Yes, I'd vote for meaningless. I'd also avoid any option that starts with "Parameter..." as the residual variance is the only parameter estimated.
– JimB
Dec 21 '18 at 20:14

















draft saved

draft discarded
















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188290%2fproperties-of-an-arbitrary-i-e-not-fitted-statistical-model%23new-answer', 'question_page');

);

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






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?