Re: [R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-16 Thread Clemontina Alexander
Thank you, that is much simpler! On Thu, Dec 15, 2011 at 2:04 PM, Rui Barradas wrote: > Hello, > > I believe I can help, or at least, my code is simpler. > First, look at your first line: > > idd <- length(diag(1,tt))   # length of intercept matrix > # > not needed: diag(tt) would do the job bu

Re: [R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-15 Thread Rui Barradas
Hello, I believe I can help, or at least, my code is simpler. First, look at your first line: idd <- length(diag(1,tt)) # length of intercept matrix # not needed: diag(tt) would do the job but it's not needed, why call 2 functions, and one of them, 'diag', uses memory(*), if the result

Re: [R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-15 Thread Clemontina Alexander
I'm sorry, the indices of my X matrix are wrong. It should be: X = x11 0 0 x12 0 0 0 x11 00 x12 0 0 0 x110 0 x12 x21 0 0 x22 0 0 0 x21 0

[R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-15 Thread Clemontina Alexander
Dear R list, I have the following data: set.seed(1) n <- 5 # number of subjects tt <- 3 # number of repeated observation per subject numco <- 2 # number of covariates x <- matrix(round(rnorm(n*numco),2), ncol=numco) # the actual covariates x > x [,1] [,2] [1,] -0.63 -0.82 [2,]