Re: [R] speed up in R apply

2011-01-06 Thread Young Cho
, Jan 5, 2011 at 3:09 PM, David Winsemius dwinsem...@comcast.netwrote: On Jan 5, 2011, at 2:40 PM, Douglas Bates wrote: On Wed, Jan 5, 2011 at 1:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Jan 5, 2011, at 10:03 AM, Young Cho wrote: Hi, I am doing some simulations and found

[R] speed up in R apply

2011-01-05 Thread Young Cho
Hi, I am doing some simulations and found a bottle neck in my R script. I made an example: a = matrix(rnorm(500),100,5) tt = Sys.time(); sum(a[,1]*a[,2]*a[,3]*a[,4]*a[,5]); Sys.time() - tt [1] -1291.026 Time difference of 0.2354031 secs tt = Sys.time(); sum(apply(a,1,prod));

[R] convert tabular time series into a matrix format

2009-07-01 Thread Young Cho
Hi, thanks everyone for any help in advance. I found myself dealing with a tabular time-series data formatted each row like [ time stamp, ID, values]. I made a small examples: X = data.frame(t=c(1,1,1,2,2,2,2,3,3,3,4,4,4,5,5),id =

[R] convert into numeric variable

2008-10-21 Thread Young Cho
Hi, I have an accounting data with % at the end and () for negative. E.g. if I read in with read.table, then R reads in as a factor: [11625] 4.61%( 4.11%) 29.85% ( 1.27%) 16.04% 21.31% 14.09% 39.71% [11633] 3.03%17.39% 80.13% 6648 Levels: ( 0.00%) ( 0.03%) ( 0.04%) ( 0.05%) (

[R] lars with weights - unshrunk coef do not match with lm with weights

2008-03-13 Thread Young Cho
I have been looking at 'lars' pkg and got puzzled by the behavior of function 'lars'. I want to do weighted lasso regression and can't get a match from lars output with lm output. Here is an example: y = rnorm(10) x = matrix(runif(50),nrow=10) X = data.frame(y,x) z = runif(10) X =

[R] lars with weights do not match with lm output

2008-03-13 Thread Young Cho
I got my posting bounced and sorry if I accidentally post twice. I have been looking at 'lars' pkg and got puzzled by the behavior of function 'lars'. I want to do weighted lasso regression and can't get a match from lars output with lm output. Here is an example: y = rnorm(10) x =

[R] intercept in lars fit

2007-11-23 Thread Young Cho
I am trying to extract coefficients from lars fit and can't find how to get intercept. E.g. y = rnorm(10) x = matrix(runif(50),nrow=10) X = data.frame(y,x) fit1 = lars(as.matrix(X[,2:6]),as.matrix(X[,1])) fit2 = lm(y~.,data=X) Then, if I do: