MathGroup Archive 2007

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

Search the Archive

Interesting problem: Use of NonlinearRegress inside a package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84296] Interesting problem: Use of NonlinearRegress inside a package
  • From: "Hoa Bui" <hoabui05 at gmail.com>
  • Date: Tue, 18 Dec 2007 02:17:38 -0500 (EST)

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: LinearSolve[m, b] is not equivalent to LinearSolve[m][b]
  • Next by Date: Re: Table[Plot[]]doesn't work as it should in v6
  • Previous by thread: RE: LinearSolve[m, b] is not equivalent to LinearSolve[m][b]
  • Next by thread: Re: Interesting problem: Use of NonlinearRegress inside a package