Skip to content

text book on experimental design

5 messages · ecatchpole, J. Wan, Achim Zeileis +2 more

#
Andy,

Thanks. Note that DeVeaux's book, at
www.williams.edu/Mathematics/rdeveaux/book/book.html, is marked "For use
only by students of Math 244 Spring 2001, Williams College" and "DRAFT: do
not distribute or copy".

Ted.

Dr E.A. Catchpole
School of Maths & Stats
University College, UNSW               Institute of Maths & Stats
Australian Defence Force Academy       University of Kent at Canterbury
Canberra, ACT 2600, Australia          Canterbury CT2 7NF, England
e-catchpole at adfa.edu.au                E.A.Catchpole at ukc.ac.uk
www.ma.adfa.edu.au/~eac
fax: +61 2 6268 8886
On Wed, 19 Sep 2001, Liaw, Andy wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Hi!

I have two questions:

1.  Is there an easy way/algorithm to obtain a series of permutated data
matrices which are obtained by permuting all the elements within each row?

Or is there a function that can permute all the elements for each row
instead of the whole matrix?

2.  Is there a function which helps find a matrix... projection operator
from p dimensional to p-1 dimensional subspace orthogonal to x, a real
number?


Thanks for your help!


**********************************************************


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"J. Wan" wrote:
sample() can do random permutations, so if you want a permutation of the
elements within each row of a matrix X, this 

t(apply(X,1,sample))

could do the job
Z
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
I don't really understand what dou you want...
The expression of the projection operator on subspace engendered by a 
matrix X is:
PX=X%*%(t(X)%*%Dn%*%X)-%*%t(X)%*%Dn
where Dn is a diagonal matrix of row weight and (t(X)%*%Dn%*%X)- is 
generalized inverse of (t(X)%*%Dn%*%X).
In multivariate regression analysis you use:
y=PX%*%y+error=a+bX1+cX2+...+error
But if you want a regression without term a (i.e. orthogonal to 
vector (1,1,...1), you must centered matrix X.

Is it what you want ?
#
"J. Wan" <jyw at u.washington.edu> writes:
A real number or a real vector?

Least squares calculations in R are done (for the most part) with QR
decompositions.  In these decompositions the matrix Q is an orthogonal
matrix that can be partitioned into an orthogonal basis for the column
span of X and an orthogonal basis for its complement.  In most
applications Q is not formed explicitly.  Instead operations such as
multiplication by Q or t(Q), projection onto the span of X, or
projection orthogonal to X are performed by special purpose functions
qr.qy, qr.qty, qr.fitted, and qr.resid.

If you want to project a vector v onto the subspace orthogonal to the
vector x use qr.resid(qr(x), v).  For example

 > vv <- rnorm(6)
 > x <- rep(1, 6)
 > vv
 [1]  0.001020799 -0.317638744  0.426937684  0.917568111 -1.350210885
 [6]  0.608166124
 > vproj <- qr.resid(qr(x), vv)
 > vproj
 [1] -0.04661972 -0.36527926  0.37929717  0.86992760 -1.39785140  0.56052561
 > vproj %*% x
               [,1]
 [1,] -1.804112e-16

If you want the projection matrix itself you would need to use qr.Q to
generate the matrix Q then manipulate that to form the projection
matrix.  For example

 > Q1 <- qr.Q(qr(x))
 > Q1
            [,1]
 [1,] -0.4082483
 [2,] -0.4082483
 [3,] -0.4082483
 [4,] -0.4082483
 [5,] -0.4082483
 [6,] -0.4082483
 > proj <- diag(6) - Q1 %*% t(Q1)
 > proj
            [,1]       [,2]       [,3]       [,4]       [,5]       [,6]
 [1,]  0.8333333 -0.1666667 -0.1666667 -0.1666667 -0.1666667 -0.1666667
 [2,] -0.1666667  0.8333333 -0.1666667 -0.1666667 -0.1666667 -0.1666667
 [3,] -0.1666667 -0.1666667  0.8333333 -0.1666667 -0.1666667 -0.1666667
 [4,] -0.1666667 -0.1666667 -0.1666667  0.8333333 -0.1666667 -0.1666667
 [5,] -0.1666667 -0.1666667 -0.1666667 -0.1666667  0.8333333 -0.1666667
 [6,] -0.1666667 -0.1666667 -0.1666667 -0.1666667 -0.1666667  0.8333333

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._