Displaying 20 results from an estimated 6000 matches similar to: "Avoiding two loops"
2009 Jan 06
1
C dll compilation + S Poetry example
Dear all;
Working with the following code extracted from the document S Poetry
by Patrick Burns (from CRAN), I haven't been able to load the
resulting dll into R. The code is basically the calculation of the
quadratic form x'Qx:
static double quad_form(double *Q, double *x, long n)
{
long i, j, ij;
double ans = 0.0;
for(i=0; i < n; i++) {
for(j=0, ij = i * n; j < n; j++,
2008 May 02
1
Speedups with Ra and jit
The topic of Ra and jit has come up on this list recently
(see http://www.milbo.users.sonic.net/ra/index.html)
so I thought people might be interested in this little demo. For it I
used my machine, a 3-year old laptop with 2Gb memory running Windows
XP, and the good old convolution example, the same one as used on the
web page, (though the code on the web page has a slight glitch in it).
This
2005 Aug 27
2
Defining an ex-gaussian PDF
How does one define PDFs as yet undefined in R, such as the ex-
gaussian, the sum of two RVs, one exponential, one Gaussian? The PDF
would then be the convolution of an exponential PDF, dexp(), and a
normal, dnorm().
Kindly cc me in your reply to r-help.
Thanks,
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400
2011 Aug 26
1
matrix bands
Dear R developers,
I was looking for a function analogous to base::diag() for getting and
setting bands of a matrix. The closest I could find was Matrix::band(),
but this was not exactly what I wanted for two reasons. Firstly,
Matrix::band() returns a matrix rather than just the specified band.
Secondly, Matrix::band() cannot be used for setting the values for a
matrix band.
Setting or
2004 Nov 23
2
IFELSE across large array?
Dear all,
As our previous email did not get any response, we try again with a
reformulated question!
We are trying to do something which needs an efficient loop over a huge
array, possibly functions such as apply and related (tapply,
lapply...?), but can't really understand syntax and examples in
practice...i.e. cant' make it work.
to be more specific:
we are trying to apply a mask
2009 Oct 27
1
Rjava, RImageJ, and/or S4 question.
I am out of my league with this question. The following code starts the java imaging program ImageJ from within R, and displays an image (assuming ImageJ is installed on your computer).
library(RImageJ)
img <- IJ$openImage( file.choose() ) #pick an available .tif file
img$show() # make the image object visible
# An image is now displayed
# find out about the objects involved
>
2009 Oct 17
2
Recommendation on a probability textbook (conditional probability)
I need to refresh my memory on Probability Theory, especially on
conditional probability. In particular, I want to solve the following
two problems. Can somebody point me some good books on Probability
Theory? Thank you!
1. Z=X+Y, where X and Y are independent random variables and their
distributions are known.
Now, I want to compute E(X | Z = z).
2.Suppose that I have $I \times J$ random number
2003 Apr 02
2
lme parameterization question
Hi,
I am trying to parameterize the following mixed model (following Piepho
and Ogutu 2002), to test for a trend over time, using multiple sites:
y[ij]=mu+b[j]+a[i]+w[j]*(beta +t[i])+c[ij]
where:
y[ij]= a response variable at site i and year j
mu = fixed intercept
Beta=fixed slope
w[j]=constant representing the jth year (covariate)
b[j]=random effect of jth year, iid N(0,sigma2[b])
a[i]=random
2013 Mar 06
1
aov() and anova() making faulty F-tests
Dear useRs,
I've just encountered a serious problem involving the F-test being carried
out in aov() and anova(). In the provided example, aov() is not making the
correct F-test for an hypothesis involving the expected mean square (EMS) of
a factor divided by the EMS of another factor (i.e., instead of the error
EMS).
Here is the example:
Expected Mean Square
2001 Oct 09
1
PROC MIXED user trying to use (n)lme...
Dear R-users
Coming from a proc mixed (SAS) background I am trying to get into
the use of (n)lme.
In this connection, I have some (presumably stupid) questions
which I am sure someone out there can answer:
1) With proc mixed it is easy to get a hold on the estimated
variance parameters as they can be put out into a SAS data set.
How do I do the same with lme-objects? For example, I can see the
2002 Mar 29
1
help with lme function
Hi all,
I have some difficulties with the lme function and so this is my problem.
Supoose i have the following model
y_(ijk)=beta_j + e_i + epsilon_(ijk)
where beta_j are fixed effects, e_i is a random effect and
epsilon_(ijk) is the error.
If i want to estimate a such model, i execute
>lme(y~vec.J , random~1 |vec .I )
where y is the vector of my data, vec.J is a factor object
2006 Oct 25
1
cloud() works but wireframe() is blank
Per the message from Alexander Nervedi, 29 April 2006:
> I have to be making a riddiculously silly ommission.
> when I run the fillowing i get the cloud plot ok. But I cant figure
> out what I am missing out when I call wireframe.
> Any help would be appreciated.
> x<-runif(100)
> y<-rnorm(100)
> z<-runif(100)
> temp <-data.frame(x,y,z)
>
2011 Apr 27
6
Assignments inside lapply
Dear all I would like to ask you if an assignment can be done inside a lapply statement.
For example
I would like to covert a double nested for loop
for (i in c(1:dimx)){
for (j in c(1:dimy)){
Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f)
}
}
to something like that:
ij<-expand.grid(i=seq(1:dimx),j=(1:dimy))
unlist(lapply(1:nrow(ij),function(rowId) { return
2011 Sep 12
6
Rv: Re: Cosinor Analysis
--- El lun, 12/9/11, Cristalina <pa100cia77@yahoo.es> escribió:
De: Cristalina <pa100cia77@yahoo.es>
Asunto: Re: [R-es] Cosinor Analysis
Para: "Carlos Ortega" <coforfe@gmail.com>
Fecha: lunes, 12 de septiembre, 2011 08:43
Hola,
Carlos, muchas gracias.
El método empleado en http://tolstoy.newcastle.edu.au/R/e6/help/09/01/0626.html (el url que se referencia
2013 Nov 28
1
Multivariate dispersion & distances
Dear All,
I'm using betadisper {vegan} and I'm interested not only in the dispersion
within the group but also the distances between the groups. With betadisper
I get distances to group centroids but is it possible to get distances to
other groups centroids?
It might be possible to do it by hand by the formula given in the
description of the betadisper (below) but I'm a bit confused
2010 Jul 03
1
Inverting a scale(X)
G'day, All.
I have been trying to trackdown a problem in my R analysis script. I perform a scale() operation on a matrix then do further work.
Is there any way of inverting the scale() such that
sX <- scale(X)
Xprime <- inv.scale(x); # does inv.scale exist?
resulting in Xprime_{ij} == X_{ij} where Xprime_{ij} \in R
There must be some way of doing it but I'm such a newb
2000 Mar 28
1
the function lme in package nlme
Dear people,
A somewhat clueless question follows:
I just discovered that the lme function in contrib package nlme for R,
while similar to the lme function in Splus, does not use the cluster
function option. This difference does not appear to be documented in the
V&R `R Complements' file.
I have data which is divided into 6 groups
The lme model is of the form (simplified from the actual
2001 May 19
2
calculations on diagonals of a matrix
Given an nxm matrix A I want to compute the nxm matrix B whose ij-th
element is the sum of the elements of A lying on the diagonal that ends
with element ij, i.e.,
b_ij = a_ij + a_(i-1)(j-1) + a_(i-2)(j-2) + ...
In APL (which I no longer use), I would use the 'rotate' operator to derive
an array whose columns are diagonals of the given array and then cumulate
down columns. Is
2009 Jul 09
2
correct way to subset a vector
Hi,
#make example data
dat <- data.frame(matrix(rnorm(15),ncol=5))
colnames(dat) <- c("ab","cd","ef","gh","ij")
If I want to get a subset of the data for the middle 3 columns, and I
know the names of the start column and the end column, I can do this:
mysub <- subset(dat,select=c(cd:gh))
If I wanted to do this just on the column names,
2009 Nov 29
1
optim or nlminb for minimization, which to believe?
I have constructed the function mml2 (below) based on the likelihood function described in the minimal latex I have pasted below for anyone who wants to look at it. This function finds parameter estimates for a basic Rasch (IRT) model. Using the function without the gradient, using either nlminb or optim returns the correct parameter estimates and, in the case of optim, the correct standard