• To: mathgroup at yoda.physics.unc.edu (Mathematica mailing list)
• From: nachbar at merck.com
• Date: Mon, 26 Jul 1993 08:41:23 -0500 (EDT)

```i'm sending this again because it apparently got lost:

hi,

Regression in Statistics`LinearRegression` returns the results of a fit as a list of
replacement rules. one of the items can be CovarianceMatrix. i wanted to use this matrix
to compute the standard error of fitted values, so i used the following:

In[1]:= <<Statistics`LinearRegression`

In[2]:= data=Table[{x,3.4+1.7x-5.6x^2+Random[Real,{-1,1}] .3},{x,-5,5}] ;

In[10]:= fit=Regress[data,{1,x,x^2},{x},OutputList->{CovarianceMatrix}] ;

In[11]:= covar = CovarianceMatrix /. fit ;

In[12]:= s=EstimatedVariance /. fit ;

when i tried to use covar, i got what looked like unevaluated results:

In[13]:= sefit={1,x,x^2}.covar.{1,x,x^2} s

2
Out[13]= 0.0289323 {1, x, x } . 0.207459     0.           -0.011655  .

0.           0.00909091   0.

-0.011655    0.           0.0011655

2
>     {1, x, x }

it turns out that the matrix is returned as MatrixForm:

Out[14]= MatrixForm

i got rid of the Head with:

In[15]:= {covar}=Apply[List,covar] ;

and got the results i wanted:

In[17]:= sefit={1,x,x^2}.covar.{1,x,x^2} s // Expand

2       3                 4
Out[17]= 0.00600227 + 0. x - 0.000411392 x  + 0. x  + 0.0000337206 x

my question: is there a "better" way to remove the MatrixForm wrapper? i would
like something that would work in the general case of removing any special

bob

--
Dr. Robert B. Nachbar | Merck Research Laboratories | 908/594-7795
nachbar at merck.com     | R50S-100                    | 908/594-4224 FAX
| PO Box 2000                 |
| Rahway, NJ 07065            |

```

• Prev by Date: Re: NIntegrate vs. N[Integrate]
• Next by Date: RotateLabel
• Previous by thread: Integers in Mma
• Next by thread: Use of InterpolatingFunction in boundary value problems.