search for: rvec

Displaying 6 results from an estimated 6 matches for "rvec".

Did you mean: bvec
2006 Nov 24
2
low-variance warning in lmer
...simfun(reefeff=reefeff,...) ow <- options(warn=2) f1 <- try(lmer(y~treat+(1|reef),data=x)) w <- (class(f1)=="try-error" && length(grep("effectively zero",f1))>0) options(ow) f2 <- lmer(y~treat+(1|reef),data=x) c(getranvar(f2),as.numeric(w)) } rvec <- rep(c(0.01,0.05,0.1,0.15,0.2,0.3,0.5),each=100) X <- t(sapply(rvec,estfun)) colnames(X) <- c("reefvar","resvar","warn") rfrac <- X[,"reefvar"]/(X[,"reefvar"]+X[,"resvar"]) fracwarn <- tapply(X[,"warn"],rvec,mean...
2003 Jun 14
2
A sapply() funny.
The sapply function is refusing to return a result for what seem to me to be mysterious reasons. Here is a toy example: set.seed(111) X <- list(x=runif(20),y=runif(20)) rvec <- seq(0.01,0.15,length=42) foo <- function(x,X,cc) { mean((X$x)^x + (X$y)^cc) } bar <- function(x,a,b){a+b*x} try.b <- sapply(rvec,bar,a=1,b=2) # This runs without a problem and # gives a + b*rvec as expected. try.f <- sapply(rvec,foo...
2005 Apr 29
0
handling of zero and negative indices in src/main/subscript.c:mat2indsub() (PR#7824)
...he integer subscripts */ /* to be extracted when x is regarded as unravelled. */ /* Negative indices are not allowed. */ /* A zero anywhere in a row will cause a zero in the same */ /* position in the result. */ SEXP mat2indsub(SEXP dims, SEXP s) { int tdim, j, i, k, nrs = nrows(s); SEXP rvec; PROTECT(rvec = allocVector(INTSXP, nrs)); s = coerceVector(s, INTSXP); setIVector(INTEGER(rvec), nrs, 0); for (i = 0; i < nrs; i++) { tdim = 1; /* compute 0-based subscripts for a row (0 in the input */ /* gets -1 in the output here) */ for (j = 0; j < LENGT...
2005 May 06
0
(PR#7824) handling of zero and negative indices in
...racted when x is regarded as unravelled. */ > /* Negative indices are not allowed. */ > /* A zero anywhere in a row will cause a zero in the same */ > /* position in the result. */ > > SEXP mat2indsub(SEXP dims, SEXP s) > { > int tdim, j, i, k, nrs = nrows(s); > SEXP rvec; > > PROTECT(rvec = allocVector(INTSXP, nrs)); > s = coerceVector(s, INTSXP); > setIVector(INTEGER(rvec), nrs, 0); > > for (i = 0; i < nrs; i++) { > tdim = 1; > /* compute 0-based subscripts for a row (0 in the input */ > /* gets -1 in the out...
2008 Mar 21
1
(no subject)
Hi, I am fairly new to R, and am stuck. I want to write an R function with argument n that returns a vector of length n with n simulated observations from the double exponential distribution with density: ??g(y) = 1/2e^-y ? For the double exponential, I want to generate y~Exp(1) and then take ?y with probability 0.5 ? Does anyone know how I can do this in R? Thanks! Fran [[alternative
2011 Jul 02
1
Simulating inhomogeneous Poisson process without loop
Dear all I want to simulate a stochastic jump variance process where N is Bernoulli with intensity lambda0 + lambda1*Vt. lambda0 is constant and lambda1 can be interpreted as a regression coefficient on the current variance level Vt. J is a scaling factor How can I rewrite this avoiding the loop structure which is very time-consuming for long simulations? for (i in 1:N){ ... N <- rbinom(n=1,