MathGroup Archive 1997

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

Search the Archive

Re: Contexts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7268] Re: [mg7251] Contexts
  • From: David Withoff <withoff>
  • Date: Tue, 20 May 1997 02:59:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

> Dear Mathgroup,
> I have written a package wherein one function uses Regress[ ] from the
> LinearRegression Package.
> reg = Regress[ ... ]  returns a list of rules ( e.g. {RSquared -> 0.95,
> EstimatedVariance -> .0004, ...} ). Inside my code I want to access to
> the values of the parameters using
> 
> rs = RSquared/.reg
> 
> This works fine as long as that function is defined in Global` - as soon
> as I put it in a Package, it won't work, though I start the package with
> BeginPackage["mypackage`", "Statistics`LinearRegression`"].
> 
> I can define the complete names for some of the parameters - what's
> annoying work - like Statistics`Common`RegressionCommon`ParameterTable
> instead of just ParameterTable. Anyway, this does not work for all
> Parameters (I couldn't find a way to do it for ParameterCITable).
> 
> What' s the clue dealing with this?
> 
> Thanks in advance,
> Peter

There are several ways to do this sort of thing.  The method that you
suggest will work fine, as long as you don't mind the extra typing
needed to enter the context when you enter the names of these symbols.

Another method is to include the corresponding context in your
BeginPackage statement:

BeginPackage["mypackage`", "Statistics`LinearRegression`",
                           "Statistics`Common`RegressionCommon`"]

so that the Statistics`Common`RegressionCommon` will be in the
context search path while your package is being loaded.

Another method is to move the EndPackage[] statement to be before
all of your program statements, so that any symbols that are in
the context search path after loading the Statistics`LinearRegression`
package will also be available to your package.

Whatever method works for ParameterTable should also work for
ParameterCITable, since these symbols are defined in the same
context, right next to each other in the same package.

Dave Withoff
Wolfram Research


  • Prev by Date: Combining several pure functions into a single pure function
  • Next by Date: how to change tick label font?
  • Previous by thread: Re: Combining several pure functions into a single pure function
  • Next by thread: how to change tick label font?