inst/snippet/small-data05.R

x <- SmallData$x; y <- SmallData$y     
Sxx <- sum((x - mean(x))^2); Sxx
Sxy <- sum((x - mean(x)) * (y - mean(y))); Sxy
r <- 1 / 3 * sum((x - mean(x)) / sd(x) * (y - mean(y)) / sd(y)); r
slope <- r * sd(y) / sd(x); slope
intercept <- mean(y) - slope * mean(x); intercept
rpruim/fastR documentation built on Nov. 12, 2023, 12:26 p.m.