Skip to content

Elegant way to express residual calculation in R?

3 messages · John McHenry, Gabor Grothendieck

#
Try this:

Xm <- as.matrix(X)
X.lm <- lm(c(Xm) ~ factor(col(Xm)) + factor(row(Xm)))
sum(resid(X.lm)^2)

or if the idea was to do it without using lm try replacing
your calculation of X.predicted with this:

X.predicted <-
  outer(operator.adjustment, machine.adjustment, "+") + mean(mean(X))
On 2/27/06, John McHenry <john_d_mchenry at yahoo.com> wrote:
#
Here is one further idea:

Xm <- as.matrix(X)
Xm. <- scale(Xm, scale = FALSE)
Xm.. <- t(scale(t(tmp), scale = FALSE))
sum(Xm..^2)
On 2/27/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: