Professional Documents
Culture Documents
## stores the !itted values in the variable !it, ie the " hat (sub i) s, the results o! #lugging the ## original data $-values into the !itted line
> semi.st.res < - res%&'.()((* ## !orms semi-studenti+ed residuals - value o! residual stand error (&'.()((*) is !rom ## summary(reg) > #lot(ht,semi.st.res) ## scatter #lot o! ht (hori+ontal) by semi-studenti+ed residuals (vertical) !or each data #oint
## What follows is a description of what is needed for the Modified Le ene !est ## > median(ht) ## ,inds the median o! the values stored in ht ## constructs a vector with */ entries and a . in each one (ie it re#eats . */ times) ## re#laces the ith iht value with an 6 i! the ith ht value is above the ## median(ht) which is e8ual to (4.5
> !or (i in &0*/ ) 1i! (ht2i3 > (4.5) iht2i3 < - -6-7
> alt.class.data < - cbind( class.data, res, iht) ## alters the class.data set by adding a res column and an iht column > alt.class.data > library(car) ## dis#lays the alt.class.data set (altered class.data) with the new columns added ## brings in the library that includes the 9evene :est ;;;<== =>? @, >=$: A6B=;;;
## runs the Dodi!ied 9evene :est analy+ing the residuals ## (res) as a !unction o! the grou# indicator (iht) ## centering each grou# s residuals at their res#. median
## "nd of the the Modified Le ene !est # the output of the test is shown $elow ## 9evene s :est !or Eomogeneity o! Fariance (center C median) ?! , value Ar(>,) grou# & /.'G(H /.HGH( &) ## "nd of the the Modified Le ene !est output##
> hist(res)
## gives a histogram o! the residuals ## gives a boI#lot o! the residuals ## gives the J-J #lot o! the residuals versus what is eI#ected to be when under a normal distribution ## it is liKe a normal #robability #lot (i! it !orms a line then the residuals looK liKe they came !rom a ## normal distribution ## #er!orms the <ha#iro-LilK test which uses Eo 0 (#o#. is some normal dist.) versus ## Ea0 (#o#. is not a normal dist.) and reMects Eo when the test statistic L is small.
> sha#iro.test(res)
## Dean s8uare !or lacK o! !it - denominator is the (number o! distinct levels o! $) minus *
> !stat < - msl!%GH/.H) ## , test statistic - denominator is the D<A= > #val < - &./ Q #!(!stat, 4, &&) ## #roduces the #-value !or this , test. Pn this eIam#le, 4 is the d! o! D<9, and && is the ## d! o! D<A=.