[R] fast matrix-vector multiplication

2009-12-14 Thread parkbomee
Hi all, Is there a way to do a matrix multiplication in a faster way? I am making a product of a matrix (composed of a lot of dummy variables) and a vector, and is there any way to make it faster? The simple X %*% y takes too long a time. I know using sparse matrix would help, but don't

[R] multi-dimensional array with different number of dimensions?

2009-12-12 Thread parkbomee
Hi, Is it possible to assign to an array with different dimensions? That is to say, supposing a three dimensional array, the third dimension of the array has matrices of different sizes? array , , 1 [1] [2] [3] [1] 111 , , 2 [1] [2] [3] [1] 111 [2] 11

Re: [R] avoiding loop

2009-11-03 Thread parkbomee
of the main loop you will probably see an increase in performance. 2009/11/2 parkbomee bbom...@hotmail.com: This is the Rprof() report by self time. Is it also possible that these routines, which take long self.time, are causing the optim() to be slow? $by.self

Re: [R] avoiding loop

2009-11-02 Thread parkbomee
...@gmail.com; r-help@r-project.org Subject: Re: [R] avoiding loop From: mtmor...@fhcrc.org Date: Sun, 1 Nov 2009 22:14:09 -0800 parkbomee bbom...@hotmail.com writes: Thank you all. What Chuck has suggested might not be applicable since the number of different times is around 40,000

Re: [R] avoiding loop

2009-11-01 Thread parkbomee
it). On Sat, Oct 31, 2009 at 11:36 PM, parkbomee bbom...@hotmail.com wrote: Thank you both. However, using tapply() instead of a loop does not seem to improve my code much. I am using this inside of an optimization function, and it still takes more than it needs... CC: bbom

[R] avoiding loop

2009-10-31 Thread parkbomee
Hi all, I am trying to figure out a way to improve my code's efficiency by avoiding the use of loop. I want to calculate a conditional mean(?) given time. For example, from the data below, I want to calculate sum((value|choice==1)/sum(value)) across time. Is there a way to do it without using

Re: [R] avoiding loop

2009-10-31 Thread parkbomee
}) I hope it helps. Best, Dimitris parkbomee wrote: Hi all, I am trying to figure out a way to improve my code's efficiency by avoiding the use of loop. I want to calculate a conditional mean(?) given time. For example, from the data below, I want to calculate sum

Re: [R] Efficient way to code using optim()

2009-10-30 Thread parkbomee
Hi all, I am trying to estimate a simple logit model. By using MLE, I am maximizing the log likelihood, with optim(). The thing is, each observation has different set of choice options, so I need a loop inside the objective function, which I think slows down the optimization process. The

Re: [R] Efficient way to code using optim()

2009-10-30 Thread parkbomee
: r-help@r-project.org Subject: Re: [R] Efficient way to code using optim() From: gpet...@uark.edu Unless this is a homework problem, you would be much better off using glm(). Giovanni Date: Fri, 30 Oct 2009 12:23:45 -0700 From: parkbomee bbom...@hotmail.com Sender: r-help-boun

[R] fixed effects regression

2009-02-06 Thread parkbomee
Hi everyone, I am running this fixed effects model in R. The thing is, my own code and the canned routine keep returning different estimates for the fixed effects factors and intercept. (The other variables' estimates and R^2 are the same!!! weird!!) I attach my own code, just in case. I am