Re: problem with Needs[ ] command
- To: mathgroup at smc.vnet.net
- Subject: [mg13583] Re: problem with Needs[ ] command
- From: "Allan Hayes" <hay at haystack.demon.cc.uk>
- Date: Mon, 3 Aug 1998 03:53:44 -0400
- References: <6pu7vl$fmo$6@dragonfly.wolfram.com>
- Sender: owner-wri-mathgroup at wolfram.com
Jordan: The problem is that an input line is parsed before being evaluated. In this case Needs["Statistics`LinearRegression`"]; reg = Regress[data, {1, a}, a]; is taken as one inputline and Regress is created as Global`Regress before Needs is evaluated (which creates Statistics`LinearRegression`Regress and issues the warning message]; There seem to be be two ways out: 1) make sure that Needs["Statistics`LinearRegression`"] is one input line followed by another input line reg = Regress[data, {1, a}, a] For example data = {{12,1},{7,2},{8,3},{5,4},{3,5}}; Needs["Statistics`LinearRegression`"]; reg = Regress[data, {1, a}, a]; Chop[reg, 10^-3] For safety put the second and third lines in distinct cells. 2) us the long name, including context for Regress; thus ( I put all the inside A[..] to make it explicit that all is in one input line). A[data = {{12,1},{7,2},{8,3},{5,4},{3,5}}; Needs["Statistics`LinearRegression`"]; reg = Statistics`LinearRegression`Regress[data, {1, a}, a]; Chop[reg, 10^-3] ] Allan ------------------------------------------------------------- Allan Hayes Training and Consulting Leicester UK http://www.haystack.demon.co.uk hay at haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44(0)116 271 8642 Jordan Milev wrote in message <6pu7vl$fmo$6 at dragonfly.wolfram.com>... >Hello! Here's what I have: In a new notebook type in the following: > >data = {{12,1},{7,2},{8,3},{5,4},{3,5}}; >Needs["Statistics`LinearRegression`"]; reg = Regress[data, {1, a}, a]; >Chop[reg, 10^-3] > >Here's what I get: > >Regress::"shdw": > "Symbol \!\(\"Regress\"\) appears in multiple contexts \ >\!\({\"Statistics`LinearRegression`\", \"Global`\"}\); definitions in >context \ >\!\(\"Statistics`LinearRegression`\"\) may shadow or be shadowed by >other \ definitions." > >Regress[{{12,1},{7,2},{8,3},{5,4},{3,5}},{1,a},a] > >Why does Mathematica display the error? > >Jordan > > > >