Re: Package Problems
- To: mathgroup at smc.vnet.net
- Subject: [mg34434] Re: Package Problems
- From: lzhao at ihw.com.cn (Instanton)
- Date: Sun, 19 May 2002 04:15:13 -0400 (EDT)
- References: <ac2moh$3pj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
understood by Mathematica as a private function of your package rather
than the one defined in the standard package LinearRegression. As I
looked into the Help file for LinearRegression package, I fould the
standard way of calling BestFitParameters is
RegressionReport -> BestFitParameters
rather than
RegressionReport -> {BestFitParameters}
So, probably it may be the extra { } around "BestFitParameters" in
your code that caused the problem. Since I have no idea what kind of
input data you are using, I cannot check this out explicitly.
Instanton
au198295 at hotmail.com (Aaron) wrote in message news:<ac2moh$3pj$1 at smc.vnet.net>...
> I have been having trouble getting functions to work in Packages that
> I have created. I have had this problem on a number of occasions,
> some of which I have fixed (usually I have no idea why it worked when
> I fixed it, but I don't complain). I have included an excerpt from a
> package below with a particularly troublesome function that I haven't
> been able to fix. The package loads fine, but when I call the
> function I get the following error:
> ________________________________________________________________________
> data2=MSCorrect[data];
>
> MyPackages`gliba`Private`BestFitParameters
>
> Part::partd: Part specification
> MyPackages`gliba`Private`BestFitParameters[[1]] is longer than depth
> of object.
>
> Part::partd: Part specification
> MyPackages`gliba`Private`BestFitParameters[[2]]
> is longer than depth of object.
> _______________________________________________________________________
>
>
> I put the packages in the Applications directory in a folder called
> MyPackages. The function takes a rectangular matrix of real values.
> If I copy the function into a notebook and compile it there it works
> fine.
>
> Thanks In Advance For Any Help,
> Aaron
>
>
> Here is the excerpt from the package. It contains alot more functions
> than this, most of which work fine. I get the same error when I use
> this reduced package.
>
> _______________________________________________________________________
> BeginPackage["`gliba`"]
>
> GLiba::usage =
> "GLib is a package that serves as a chemometric toolbox for analysis
> of real data sets."
>
> MSCorrect::usage =
> "newspec = MSCorrect[tnspec]. The scatter corrected spectra
> (newspec) are returned from the input spectra (tnspec)."
>
>
> Begin["`Private`"]
>
> Needs["Statistics`DataManipulation`"]
> Needs["Statistics`DescriptiveStatistics`"]
> Needs["Statistics`LinearRegression`"]
>
> MSCorrect[tnspec_List]:=
> Module[{norows,nocols,temp,i,coeff,x,output,outspec},
> {norows, nocols} = Dimensions[tnspec];
> temp = Table[0, {2}, {nocols}];
> outspec = Table[0, {norows}, {nocols}];
> temp[[1]] = Mean[tnspec];
> For[i = 1, i < norows + 1, ++i,
> temp[[2]] = tnspec[[i]];
> output = Regress[Transpose[temp], {x},{x},
> RegressionReport->{BestFitParameters}];
> coeff = BestFitParameters /. output;
> Print[coeff];
> outspec[[i]] = (tnspec[[i]] - coeff[[1]])/coeff[[2]];
> ];
> Return[outspec]
> ];
>
>
> End[ ]
>
> EndPackage[ ]