Displaying 20 results from an estimated 7000 matches similar to: "Making tapply code more efficient"
2009 Jan 13
3
Comparing elements for equality
Suppose I have a dataframe as follows:
dat <- data.frame(id = c(1,1,2,2,2), var1 = c(10,10,20,20,25), var2 =
c('foo', 'foo', 'foo', 'foobar', 'foo'))
Now, if I were to subset by id, such as:
> subset(dat, id==1)
id var1 var2
1 1 10 foo
2 1 10 foo
I can see that the elements in var1 are exactly the same and the
elements in var2 are exactly
2010 Oct 04
1
Help with apply
Suppose I have the following data:
tmp <- data.frame(var1 = sample(c(0:10), 3, replace = TRUE), var2 = sample(c(0:10), 3, replace = TRUE), var3 = sample(c(0:10), 3, replace = TRUE))
I can run the following double loop and yield what I want in the end (rr1) as:
library(statmod)
Q <- 2
b <- runif(3)
qq <- gauss.quad.prob(Q, dist = 'normal', mu = 0, sigma=1)
rr1 <- matrix(0,
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
2008 Aug 15
2
Design-consistent variance estimate
Dear List:
I am working to understand some differences between the results of the
svymean() function in the survey package and from code I have written
myself. The results from svymean() also agree with results I get from
SAS proc surveymeans, so, this suggests I am misunderstanding something.
I am never comfortable with "I did what the software" does mentality, so
I am working to
2010 Nov 14
1
Integrate to 1? (gauss.quad)
Does anyone see why my code does not integrate to 1?
library(statmod)
mu <- 0
s <- 1
Q <- 5
qq <- gauss.quad(Q, kind='hermite')
sum((1/(s*sqrt(2*pi))) * exp(-((qq$nodes-mu)^2/(2*s^2))) * qq$weights)
### This does what's it is supposed to
myNorm <- function(theta) (1/(s*sqrt(2*pi))) * exp(-((theta-mu)^2/(2*s^2)))
integrate(myNorm, -Inf, Inf)
2010 Sep 29
1
nlminb and optim
I am using both nlminb and optim to get MLEs from a likelihood function I have developed. AFAIK, the model I has not been previously used in this way and so I am struggling a bit to unit test my code since I don't have another data set to compare this kind of estimation to.
The likelihood I have is (in tex below)
\begin{equation}
\label{eqn:marginal}
L(\beta) = \prod_{s=1}^N \int
2006 Jul 24
3
standardized random effects with ranef.lme()
Using ranef() (package nlme, version 3.1-75) with an 'lme' object I can
obtain random effects for intercept and slope of a certain level (say:
1) - this corresponds to (say level 1) "residuals" in MLWin. Maybe I'm
mistaken here, but the results are identical.
However, if I try to get the standardized random effects adding the
paramter "standard=T" to the
2005 Jan 19
2
Referencing objects within a loop
Dear List:
It appears that simulating data where all dataframes are stored as a
list will only work for relatively small analyses. Instead, it appears
that creating N individual dataframes, saving them, and loading them
when needed is the best way to save memory and make this a feasible
task.
As such, I now have a new(er) question with respect to dealing with
individual files within a loop. To
2011 May 01
2
bwplot in ascending order
Can anyone point me to examples with R code where bwplot in lattice is used to order the boxes in ascending order? I have found the following discussion and it partly works. But, I have a conditioning variable, so my example is more like
bwplot(var1 ~ var2|condition, dat)
Th example in the discussion below works only when there is not a conditioning variable as far as I can tell. I can tweak the
2012 Jan 17
2
Separate ablines in lattice panels
Searched archives and found some old email threads on the topic. But mot exactly what I think I need. Suppose I have a datafile such as tmp.
tmp <- data.frame(var1 = c(rnorm(1000), rnorm(1000, 1, 1)), var2 = gl(2, 1000))
I'd like a plot similar to the one below, but with an abline of v=0 in the lower panel and v=1 in the upper panel. Code below creates two lines in each panel, not quite
2023 Mar 09
1
rsync 3.2.7 hangs when --usermap is used and receiver is not a super-user
Hi.
On Wed, 08 Mar 2023 22:21:28 +0100 Tomasz Chmielewski via rsync wrote:
> After upgrading to rsync 3.2.7, the following command hangs forever
> (using "--usermap" causes the hang; without "--usermap" it doesn't
> hang):
> rsync -v -p -e --usermap user:user /etc/services user at remote:
This command is incorrect: the -e option needs a command.
Without
2006 Mar 03
3
Peculiar timing result
I have been timing a particular model fit using lmer on several
different computers and came up with a peculiar result - the model fit
is considerably slower on a dual-core Athlon 64 using Goto's
multithreaded BLAS than on a single-core processor.
Here is the timing on a single-core Athlon 64 3000+ running under
today's R-devel with version 0.995-5 of the Matrix package.
>
2011 May 17
1
scales argument in bwplot (lattice)
Suppose I have data such as the following
set.seed(12345)
tmp <- data.frame(var1 = rnorm(100), var2 = rnorm(100), var3=rnorm(100, 10, 30))
tmp1 <- data.frame(vars = with(tmp, c(var1, var2, var3)), type = gl(3, 100))
var3 is on a different scale, but I create the following plot, which looks terrible as a result
bwplot(~ vars|type, tmp1,
layout = c(1,3),
)
Of course, I can
2006 Jan 31
1
Mixed-effects models / heterogeneous covariances
Dear R-list,
maybe someone can help me with the following mixed-effects models
problem, as I am unable to figure it out with the 'nlme-bible'.
I would like to fit (in R, obviously) a so-called animal model (google
e. g. "Heritability and genetic constraints of life-history" by Pettay
et al.) to estimate the variance component that is due to genetic
effects. The covariances of
2017 Jun 06
3
celt_inner_prod() and dual_inner_prod() NEON intrinsics
Hi Linfeng,
On 05/06/17 03:31 PM, Linfeng Zhang wrote:
> Yes we'll have one more patch set related to xcorr in next week. Please
> don't wait if it's too late for 1.2 release.
Assuming there's no issue with the patches, next week isn't too late.
Also, I've started looking at your patches. So far there's one thing
that puzzles me a bit. In the OPUS_CHECK_ASM
2006 Jul 06
4
Re: psexec for Linux and svcctl.idl changes
> I am not a regular samba developer, but I wanted to have psexec
> equivalent, so I wrote it, it works but still need some development.
> I do not know if patches of such sizes (about 30k) are welcome on
> this list so I've put it on web page, with some description:
> http://eol.ovh.org/winexe/
> Comments welcome.
Hi, this is really great, you can get Windows command
2018 Mar 22
2
dovecot-uidlist is not up-to-date
Tried that. It rebuilds index based on dovecot-uidlist. But not the dovecot-uidlist based on actual mail data. :(
Fil
On March 21, 2018 11:58:21 PM EDT, "@lbutlr" <kremels at kreme.com> wrote:
>On 2018-03-21 (17:15 MDT), Dmitry Filonov
><filonovd at enders.tch.harvard.edu> wrote:
>> Now the question is if there's any way to tell dovecot to rebuild
2006 Jul 30
2
Question about data used to fit the mixed model
Hi everyone,
I would like to ask a question regarding to the data used to fit the mixed
model.
I wonder that, for the response variable data used to fit the mixed model
(either via "spm" or "lme"), we must have several observations per subject
(i.e. Yij, i = 1,..,M, j = 1,.., ni) or it can be just one observation per
subject (i.e. Yi, i = 1,...,M). Since we have to
2015 Jul 13
2
Crear datos aleatorios con restriciones
Hola,
Esta pregunta la hice en stackoverflow
<http://stackoverflow.com/questions/31137940/randomly-assign-teachers-to-classrooms-imposing-restrictions/31143808#31143808>pero
nadie pudo contestarla.
1. Quiero generar N escuelas, con G grados y C divisiones.
2. Quiero asignar cada uno de T maestros a 2 divisiones en un grado y
escuela
Si tengo C=4 divisiones, puedo lograr lo que quiero con
2015 Jul 13
2
Crear datos aleatorios con restriciones
Hola,
0. La falta de 'elegancia' hace que sea mas dificil hacer cambios al
codigo. Por ejemplo cambiar n.classrooms <- 4 a n.classrooms <- 20
1. Cuando tengo solo 4 puedo hacer esto:
schoolGrade$A <- Teachers$Teacher.ID[1:cuttoff1]
schoolGrade$B <- Teachers$Teacher.ID[1:cuttoff1]
schoolGrade$C <- Teachers$Teacher.ID[(cuttoff1+1):n.teachers]
schoolGrade$D <-