similar to: R computing speed

Displaying 20 results from an estimated 9000 matches similar to: "R computing speed"

2011 Feb 04
2
Avoiding two loops
Hello, I have a R code for doing convolution of two functions: convolveSlow <- function(x, y) { nx <- length(x); ny <- length(y) xy <- numeric(nx + ny - 1) for(i in seq(length = nx)) { xi <- x[[i]] for(j in seq(length = ny)) { ij <- i+j-1 xy[[ij]] <- xy[[ij]] + xi * y[[j]] } } xy } How do I reduce the 2
2007 Feb 17
1
Constraint maximum (likelihood) using nlm
Hi, I'm trying to find the maximum (likelihood) of a function. Therefore, I'm trying to minimize the negative likelihood function: # params: vector containing values of mu and sigma # params[1] - mu, params[2]- sigma # dat: matrix of data pairs y_i and s_i # dat[,1] - column of y_i , dat[,2] column of s_i negll <- function(params,dat,constant=0) { for(i in 1:length(dat[,1])) {
2005 Sep 29
1
Error using a data frame as the "start" parameter in mle()
Dear R-Users, I am trying to use mle() to optimize two (or more) parameters, but I want to specify those parmeters in a data frame rather than having to spell them out separately in the "start" variable of mle(). My call is > mle(negll, start=list(aps=init), fixed=list(measphot=newphot, formod=formod, Nbands=Nbands), method="BFGS") where negll is a function I have
2011 Aug 17
2
An example of very slow computation
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but "a bit" turned out to be a factor of >1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our code, or enlighten us on why one approach is so much slower than the other. The problem
2012 Feb 09
2
Lattice 3d coordinate transformation
Hello List! I asked this before (with no solution), but maybe this time... I'm trying to project a surface to the XY under a 3d cloud using lattice. I can project contour lines following the code for fig 13.7 in Deepayan Sarkar's "Lattice, Multivariate Data Visualization with R", but it fails when I try to "color them in" using panel.levelplot. ?utilities.3d says there
2008 May 12
1
hessian in constrained optimization (constrOptim)
Dear helpers, I am using the function "constrOptim" to estimate a model with ML with an inequality constraint using the option method='Nelder-Mead'. When I specify the option: hessian = TRUE I obtain the response: Error in f(theta, ...) : unused argument(s) (hessian = TRUE) I guess the function "constrOptim" does not allow this argument which, on the other hand, is
2010 Jan 07
1
faster GLS code
Dear helpers, I wrote a code which estimates a multi-equation model with generalized least squares (GLS). I can use GLS because I know the covariance matrix of the residuals a priori. However, it is a bit slow and I wonder if anybody would be able to point out a way to make it faster (it is part of a bigger code and needs to run several times). Any suggestion would be greatly appreciated. Carlo
2005 May 03
1
maximization help :
Given a vector : pvec=(p1,p2,.... p J) with sum(pvec)=1, all the elements are non-negative, that is, they are probabilities a matrix A ( N* J ), with the elements alpha(ij) are 0 or 1 I want to MAXIMIZE THE RESULT RESULT= product( i=1, to N [ sum ( alpha(ij)* pj , j =1,to J ) ] ) thus, I need to get pvec. how should I do ? for example
2012 Jan 17
2
bayesian mixed logit
Dear all, I am writing an R code to fit a Bayesian mixed logit (BML) via MCMC / MH algorithms following Train (2009, ch. 12). Unfortunately, after many draws the covariance matrix of the correlated random parameters tend to become a matrix with almost perfect correlation, so I think there is a bug in the code I wrote but I do not seem to be able to find it.. dull I know. Has anybody written a
2012 Jan 15
0
patching ?merge to allow the user to keep the order of one of the two data.frame objects merged
Hello dear R-devel list members. Following an old (2002) thread from R-help (and having myself needing to solve the same question): https://stat.ethz.ch/pipermail/r-help/2002-October/026249.html I patched the {base} function "merge.data.frame" to have it work with a new parameter called "keep_order", and I hope you might consider including this patch (or some variation of it)
2007 Jul 29
1
behavior of L-BFGS-B with trivial function triggers bug in stats4::mle
With the exception of "L-BFGS-B", all of the other optim() methods return the value of the function when they are given a trivial function (i.e., one with no variable arguments) to optimize. I don't think this is a "bug" in L-BFGS-B (more like a response to an undefined condition), but it leads to a bug in stats4::mle -- a spurious error saying that a better fit has been
2009 Mar 03
1
SPSS data import: problems & work arounds for GSS surveys
I'm using R 2.8.1 on Ubuntu 8.10. I'm writing partly to ask what's wrong, partly to tell other users who search that there is a work around. The General Social Survey is a long standing series of surveys provided by NORC (National Opinion Research Center). I have downloaded some years of the survey data in SPSS format (here's the site:
2013 May 16
2
R looping help
Hey I'm not really sure what I should put on here, but I am having trouble with my R code. I am trying to get the p-values, R^2s etc for a number of different groups of variables that are all in one dataset. This is the code: #Stand counter st<-1 #Collections stands<-numeric(67) slopes<-numeric(67) intercepts<-numeric(67) mses<-numeric(67) rsquares<-numeric(67)
2010 Oct 03
1
Johnson Distribution Fit
Hi, I am trying to fit a Johnson SB distribution using fitdist function in fitdistrplus Library. I have defined the Johnson SB distribution from ( http://www.ntrand.com/johnson-sb-distribution/) . But it gives me the follwing errors. Any help would be appreciated #xi = xi #lambda =l #delta =d #gamma = g djohn = function(x,xi,l,d,g) (d/(l*sqrt(2*pi)*((x-xi)/l)*(1-((x-xi)/l))))*exp[-0.5*(g +
2008 Oct 23
1
distribution fitting
Dear R-help readers, I am writing to you in order to ask you a few questions about distribution fitting in R. I am trying to find out whether the set of event interarrival times that I am currently analyzing is distributed with a Gamma or General Pareto distribution. The event arrival granularity is in minutes and interarrival times are in seconds, so the values I have are 0, 60, 120, 180, and
2011 Dec 02
1
1.6x speedup for requal() function (in R/src/main/unique.c)
Hi, FWIW: /* Taken from R/src/main/unique.c */ static int requal(SEXP x, int i, SEXP y, int j) { if (i < 0 || j < 0) return 0; if (!ISNAN(REAL(x)[i]) && !ISNAN(REAL(y)[j])) return (REAL(x)[i] == REAL(y)[j]); else if (R_IsNA(REAL(x)[i]) && R_IsNA(REAL(y)[j])) return 1; else if (R_IsNaN(REAL(x)[i]) && R_IsNaN(REAL(y)[j])) return 1;
2009 Aug 24
2
[] for R
I am assuming the variable out is the output parameter. However, I don't understand what is out[1+xi*xx>0]? Can someone explain this to me? Thanks in advance, Chen dGEV <- function(x, xi, mu = 0, sigma = 1, logvalue=FALSE) { xx <- (x-mu)/sigma #use the new dGumbel which passes mu and sigma: #if (xi==0) out <- dGumbel(xx,logvalue=TRUE)-log(sigma) if (xi==0) {
2007 Apr 25
2
Having trouble with FreeNX, Need help to make it work perfectly
Hi thanks for the reply i am really grateful if you can tell me how to make FreeNX work like charm. I am really stuck with it, and after reinstalling the server is definitely pissing off my boss. Please help me thanks. =========================== Please let me review how my FreeNX was screwed up. After i fresh install my CentOS 5, I 'yum install freenx' and so if i am not wrong I
2024 Feb 29
1
[EXT] Initializing vector and matrices
Hello Eik: Thanks. I do not need to sample. Essentially, I have a do loop which produces 24 vectors of length of some length (say k=300) and 24 matrices of 300x300. Then, I simply need to? take the averages of these 24 vectors and matrices: x=(x1+x2+...+x24)/k y=(y1+y2+...+y24)/k I am just looking for ways to do this in a do loop, which requires initialization (to 0's) of x and y. My
2010 Apr 27
1
TikzDevice and texi2dvi
Dear All, I am starting to use the tikzDevice package, but I am experiencing some (minor problems). If I try to run the script at the end of the email, I get the following error Error in tools::texi2dvi("normal.tex", pdf = T) : Running 'texi2dvi' on 'normal.tex' failed. Messages: sh: /usr/bin/texi2dvi: not found How do I install the missing texi2dvi? I found some