Displaying 1 result from an estimated 1 matches for "27s_distance".
2013 Mar 12
1
Cook's distance
Dear useRs,
I have some trouble with the calculation of Cook's distance in R.
The formula for Cook's distance can be found for example here:
http://en.wikipedia.org/wiki/Cook%27s_distance
I tried to apply it in R:
> y <- (1:400)^2
> x <- 1:100
> lm(y~x) -> linmod # just for the sake of a simple example
> linmod$residuals[1]^2/(2*mean(linmod$residuals^2))*(hatvalues(linmod)[1]/(1-hatvalues(linmod)[1])^2)
1
0.02503195
> cooks.distance(linmod)[1]...