[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 kno

[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
they are and work with > them. This is probably where most of your time is being spent. So if > you start with matrices and leave the dataframes out of the main loop > you will probably see an increase in performance. > > 2009/11/2 parkbomee : > > This is the Rprof(

Re: [R] avoiding loop

2009-11-02 Thread parkbomee
st" 9.64 1.7 9.64 1.7 "exp"7.12 1.2 7.12 1.2 "as.data.frame.integer" 5.98 1.0 8.10 1.4 > To: bbom...@hotmail.com > CC: jholt...@gmail.com; r-help@r-project.org > Subject

Re: [R] avoiding loop

2009-11-01 Thread parkbomee
time trying to > optimize the function than just running the current version even if it > is "slow" (slow is a relative term and does not hold much meaning > without some context round it). > > On Sat, Oct 31, 2009 at 11:36 PM, parkbomee wrote: > > > >

Re: [R] avoiding loop

2009-10-31 Thread parkbomee
ith(DF, { > >ind <- choice == 1 > >n <- tapply(value[ind], time[ind], sum) > >d <- tapply(value, time, sum) > >n / d > > }) > > > > > > I hope it helps. > > > > Best, > > Dimitris > > > > >

[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 a

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

2009-10-30 Thread parkbomee
hotmail.com > CC: 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 &g

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 data

[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 pre