0
$\begingroup$

I have a FittedModel from NonlinearModelFit for which the determination of the FitCurvatureTable can be extremely slow. These curvature diagnostics are part of the output in a large dynamic interface, and I would prefer to not have to tell the user to use Alt. to interrupt the calculation. On the plus side, it seems that I can use a (seemingly) undocumented feature of FittedModel, EvaluationMonitor, to interrupt the calculation using the technique I employed in answering this question for interrupting a fit. However, if the user is willing to sit through the long calculation, I would like for them to be able to update the CurvatureConfidenceRegion portion of the table for a modified ConfidenceLevel without having to go back through the whole calculation.

I have implemented something similar for the MeanPredictionBands and SinglePredictionBands by storing the MeanPredictionErrors and SinglePredictionErrors and multiplying by:

Quantile[NormalDistribution[0, 1], (1 + confidenceLevel)/2]*{-1,1}

and then adding the fit values. However, I don't see how to do something similar for CurvatureConfidenceRegion, because I don't know how it is calculated relative to the ConfidenceLevel.

So, my question: if I have a CurvatureConfidenceRegion for a given value of ConfidenceLevel, is there a straightforward way to calculate that CurvatureConfidenceRegion for a different value of ConfidenceLevel?

$\endgroup$
3
  • 1
    $\begingroup$ I think you mean ConfidenceLevel as the NonlinearModelFit parameter. If the fitted model is nlm, why not use nlm["CurvatureConfidenceRegion"] ? The values of the other two parameters in FitCurvatureTable don't change with the changing of the ConfidenceLevel. (Your users sound pretty sophisticated if they need varying confidence levels for the CurvatureConfidenceRegion statistic.) $\endgroup$
    – JimB
    Sep 11, 2019 at 22:33
  • $\begingroup$ You are correct that I meant ConfidenceLevel. I will correct that in the OP. Yes, I can do just the calculation for CurvatureConfidenceRegion, which will save some time, but in my context even that calculation still can take minutes. So I am still interested in whether there is a scaling that can be used from one ConfidenceLevel to another. Re: the sophistication of my users, I am allowing them to change the ConfidenceLevel for the prediction bands and for the parameter estimate confidence range, and thought that I should be consistent and use the same ConfidenceLevel for everything. $\endgroup$ Sep 11, 2019 at 23:11
  • 1
    $\begingroup$ I don't know what statistic is being calculated but it appears that it only depends on the number of samples, number of parameters, and the confidence level. It is NOT dependent on the values of the data. That doesn't help you but it does suggest that there is a function used that can be calculated independently of the data and model fit. Maybe asking Wolfram, Inc. directly would supply the function used. $\endgroup$
    – JimB
    Sep 12, 2019 at 19:53

1 Answer 1

2
$\begingroup$

I think that the CurvatureConfidenceRegion statistic is just a function of the number of observations, number of parameters, and the confidence level. The actual data (both the predictor and response variables) and the model being fit seem to have nothing to do with it. Therefore one can create a simple model and get the value for the CurvatureConfidenceRegion for any confidence level.

ccr[n_, np_, cl_] := NonlinearModelFit[Transpose[{Range[n]/n, Range[n]/n}],
   Sum[a[i] z^i, {i, np}], Table[a[i], {i, np}], z, 
   ConfidenceLevel -> cl]["CurvatureConfidenceRegion"]

ccr[20, 3, 95/100]
(* 0.559299 *)

Obviously, there is some underlying function that Mathematica uses but this seems to be a quick and dirty workaround until that exact function is known. It would also be of interest for the documentation to state to what use that statistic is good for (and with a reference would be even better).

Addition:

As evidence that it doesn't matter about the data or the model here is a modification of the above function using random samples from a bivariate normal distribution with a slightly different model:

ccrRandom[n_, np_, cl_] := NonlinearModelFit[
   RandomVariate[BinormalDistribution[{0, 0}, {1, 2}, 0.8], n],
   Sum[a[i] z^(4 i), {i, np}], Table[a[i], {i, np}], z, 
   ConfidenceLevel -> cl]["CurvatureConfidenceRegion"]

Table[ccrRandom[20, 3, 95/100], {i, 10}]
(* {0.559299, 0.559299, 0.559299, 0.559299, 0.559299, 0.559299, 0.559299, 0.559299, 0.559299, 0.559299} *)

ccr[20, 3, 95/100]
(* 0.559299 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.