Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Linear Regression and Hat Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44631] Re: Linear Regression and Hat Matrix
  • From: koopman at sfu.ca (Ray Koopman)
  • Date: Tue, 18 Nov 2003 06:42:04 -0500 (EST)
  • References: <bpa1m8$19f$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

kowald at molgen.mpg.de (Axel Kowald) wrote in message 
news:<bpa1m8$19f$1 at smc.vnet.net>...
> 
> I'm doing some linear regression and am a bit confused by Mathematicas
> output. I do:
> <<Statistics`LinearRegression`
> data = {{1, 0.1}, {2, 0.2}, {3, 0.3}, {4, 0.4}, {5, 0.5}, 
>         {6,0.6}, {7, 0.7}, {8, 0.8}, {9, 0.3}};
> Regress[data, {1, x}, x, RegressionReport -> {HatDiagonal}] 
> 
> and get the HatDiagonal:
> {HatDiagonal -> {0.377778, 
>     0.261111, 0.177778, 0.127778, 0.111111, 0.127778, 0.177778,
> 0.261111, 0.377778}}
> 
> That's fine. But if I try to construct the Hat Matrix by hand I get
> something completely different. The hat matrix is defined as: X(X^T
> X)^-1 X^T, so I do:
> 
> hat = data.Inverse[Transpose[data].data].Transpose[data]   
> 
> However, the diagonal elements of the resulting matrix are completely
> different.
> 
> {0.00490196, 0.0196078, 0.0441176, 0.0784314, 0.122549, 0.176471,
> 0.240196, 0.313725, 1.}
> 
> What am I doing wrong?
> 

X = Table[{1,x},{x,9}], not "data".


  • Prev by Date: RE: filled plot on part of x-interval
  • Next by Date: Re: use of SetDelayed functions in Plot and Solve
  • Previous by thread: Linear Regression and Hat Matrix
  • Next by thread: Re: Linear Regression and Hat Matrix