MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Interesting problem: Use of NonlinearRegress inside a package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84316] Re: [mg84296] Interesting problem: Use of NonlinearRegress inside a package
  • From: "Hoa Bui" <hoabui05 at gmail.com>
  • Date: Wed, 19 Dec 2007 04:09:18 -0500 (EST)
  • References: <200712180717.CAA28189@smc.vnet.net>

Ok, nevermind. I figured it out.
The options of NonlinearRegress are actually defined in
`Statistics`Common`RegressionCommon`, so I actually needed

BeginPackage["Test`",
{"Statistics`NonlinearFit`","Statistics`Common`RegressionCommon`"}];

and now it's working properly.

Thanks, everyone!



On Dec 18, 2007 1:17 AM, Hoa Bui <hoabui05 at gmail.com> wrote:

> Hello,
> I created the following package:
>
> Off[General::spell]; Off[General::spell1];
> BeginPackage["Test`", {"Statistics`NonlinearFit`"}];
> f::usage = "test NonlinearRegress inside a package";
> Begin["`Private`"];
> f[data_] := Module[{model, a, b, x, fit},
>      Print["The context of NonlinearRegress is ",
> Context[NonlinearRegress]];
> Print["The context of BestFit is ", Context[Bestfit]];
>
>      model = a*x + b;
>      fit = NonlinearRegress[data, model, {x}, {a, b}, RegressionReport
> ->{BestFit, ParameterTable, FitResiduals}];
>      Return[fit];
>      ];
> End[];
> EndPackage[];
>
> In[8]:=?f
> test NonlinearRegress inside a package
> In[9]:=data={{0.8493`,2.015`},{2.3355`,2.267`},{4.8832`,2.589`},{7.2187`,
> 2.812`}};
> In[10]:=f[data]
>
>
> The problem is that, inside the Module f I wanted to see the BestFit,
> ParameterTable and FitResiduals, but since these are known only to
> Test`Private`, what Out[10] does is it treats the NonlinearRegress as if
> the
> option RegressionReport was not specified!
> I know that this problem is related to the Context of the symbols/names,
> but
> don't know how to get around it (I'd really like to keep the Module inside
> the Private section of the package). Perhaps someone could help me?
>
> Thanks a lot,
> Hoa
>
>
>



  • Prev by Date: Button Question
  • Next by Date: Re: Timing and Pi
  • Previous by thread: Interesting problem: Use of NonlinearRegress inside a package
  • Next by thread: Mathematica SIG (Washington D.C. and Northern Virginia)