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

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

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?

• 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

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} *)


Mean[(mt[[All, 2]] - 1.5 - mt[[All, 1]])^2]

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