[R] faraway tutorial: cryptic command to newbie
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Sat Feb 22 18:28:02 CET 2003
On 22 Feb 2003, Christoph Lehmann wrote:
> I am just about working through Faraways excellent tutorial "practical
> regression and ANOVA using R"
I assume this is a reference to the PDF version available via CRAN. I am
afraid that is *not* a good discussion of how to do regression, especially
not using R. That page is seriously misleading: good ways to compute
regressions are QR decompositions with pivoting (which R uses) or an SVD.
Solving the normal equations is well known to square the condition number,
and is close to the worse possible way. (If you must use normal
equations, do at least centre the columns, and preferably do some
scaling.)
> on page 24 he makes the x matrix:
> x <- cbind(1,gala[,-c(1,2)])
>
> how can I understand this gala[,-c(1,2)])... I couldn't find an
> explanation of such "c-like" abbreviations anywhere.
Well, it is in all good books (as they say) including `An Introduction to
R'. (It's even on page 210 of that book!)
-c(1,2) is (try it)
> -c(1,2)
[1] -1 -2
so this drops columns 1 and 2. It then adds in front a column made up of
ones, which is usually a sign of someone not really understanding how
R's linear models work.
> another problem: I couldn't load the faraway library, using the
> library() command, even though I specified the path, .. do I need to put
> library files into a certain directory? I always got an error: Error in
> library(faraway) : There is no package called `faraway'
Did you *install* the *package*? Is it a valid R package which has passed
R CMD check?
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list