similar to: Loss of numerical precision from conversion to list ?

Displaying 20 results from an estimated 700 matches similar to: "Loss of numerical precision from conversion to list ?"

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,
2010 Oct 13
1
(no subject)
Dear all, I have just sent an email with my problem, but I think no one can see the red part, beacuse it is black. So, i am writing again the codes: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N <- 200 I <- 5 taus <- c(0.480:0.520) h <-
2010 Oct 13
4
loop
Dear all, I am trying to run a loop in my codes, but the software returns an error: "subscript out of bounds" I dont understand exactly why this is happenning. My codes are the following: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N
2010 Oct 07
3
quantile regression
Dear all, I am a new user in r and I am facing some problems with the quantile regression specification. I have two matrix (mresultb and mresultx) with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix represents each simulation of a determined variable. I need to regress each column of mresultb on mresultx. My codes are the following:
2011 Nov 07
1
How do I return to the row values of a matrix after computing distances
## Package Needed library(fields) ## Assumptions set.seed(123) nsim<-5 p<-2 ## Generate Random Matrix G G <- matrix(runif(p*nsim),nsim,p) ## Set Empty Matraces dmax and dmin dmax<- matrix(data=NA,nrow=nsim,ncol=p) dmin<- matrix(data=NA,nrow=nsim,ncol=p) ## Loop to Fill dmax and dmin for(i in 1:nsim) { dmax[i]<- max(rdist(G[i,,drop=FALSE],G)) dmin[i]<-
2006 Sep 07
5
Conservative "ANOVA tables" in lmer
Dear lmer-ers, My thanks for all of you who are sharing your trials and tribulations publicly. I was hoping to elicit some feedback on my thoughts on denominator degrees of freedom for F ratios in mixed models. These thoughts and practices result from my reading of previous postings by Doug Bates and others. - I start by assuming that the appropriate denominator degrees lies between n
2011 Feb 17
1
How to speed up a for() loop
Dear all, Does anyone have any idea on how to speed up the for() loop below. Currently it takes approximately 2 minutes and 30 seconds. Because of the size of Nsim and N, simulating a multivariate normal (instead of simulating Nsim times a vector of N normal distributions) would require too much memory space. Many thanks for your kind help, Simona N=3000 PD=runif(N,0,1) cutoff.=qnorm(PD)
2007 Oct 11
3
reason for error in small function?
Running the function below, tested using the cardiff dataset from splancs generates the following error. What changes do I need to make to get the function to work? Thanks. --Dale > gen.rpoints(events, poly, 99) > rpoints Error: object "rpoints" not found # test spatial data library(splancs) data(cardiff) attach(cardiff) str(cardiff) events <- as.points(x,y) ###
2006 Mar 08
1
power and sample size for a GLM with Poisson response variable
Craig, Thanks for your follow-up note on using the asypow package. My problem was not only constructing the "constraints" vector but, for my particular situation (Poisson regression, two groups, sample sizes of (1081,3180), I get very different results using asypow package compared to my other (home grown) approaches. library(asypow) pois.mean<-c(0.0065,0.0003) info.pois <-
2007 Dec 04
1
Metropolis-Hastings within Gibbs coding error
Dear list, After running for a while, it crashes and gives the following error message: can anybody suggest how to deal with this? Error in if (ratio0[i] < log(runif(1))) { : missing value where TRUE/FALSE needed ################### original program ######## p2 <- function (Nsim=1000){ x<- c(0.301,0,-0.301,-0.602,-0.903,-1.208, -1.309,-1.807,-2.108,-2.71) # logdose
2009 Sep 02
1
problem in loop
Hi R-users, I have a problem for updating the estimates of correlation coefficient in simulation loop. I want to get the matrix of correlation coefficients (matrix, name: est) from geese by using loop(500 times) . I used following code to update, nsim<-500 est<-matrix(ncol=2, nrow=nsim) for(i in 1:nsim){ fit <- geese(x ~ trt, id=subject, data=data_gee, family=binomial,
2007 Oct 03
2
Speeding up simulation of mean nearest neighbor distances
I've written the function below to simulate the mean 1st through nth nearest neighbor distances for a random spatial pattern using the functions nndist() and runifpoint() from spatsat. It works, but runs relatively slowly - would appreciate suggestions on how to speed up this function. Thanks. --Dale library(spatstat) sim.nth.mdist <- function(nth,nsim) { D <- matrix(ncol=nth,
2012 Nov 23
1
Spatstat: Mark correlation function
I normally use the following code to create a figure displaying the mark correlation function for the point pattern process "A": M<-markcorr(A) plot(M) I have now started to use the following code to perform 1000 Monte Carlo simulations of Complete Spatial Randomness (CSR). It is a Monte Carlo test based on envelopes of the Mark correlation function obtained from simulated point
2010 Nov 08
1
try (nls stops unexpectedly because of chol2inv error
Hi, I am running simulations that does multiple comparisons to control. For each simulation, I need to model 7 nls functions. I loop over 7 to do the nls using try if try fails, I break out of that loop, and go to next simulation. I get warnings on nls failures, but the simulation continues to run, except when the internal call (internal to nls) of the chol2inv fails.
2009 Dec 09
1
Why cannot get the expected values in my function
Hi, In the following function, i hope to save my simulated data into the "result" dataset, but why the final "result" dataset seems not to be generated. #Function simdata<-function (nsim) { result<-matrix(NA,nrow=nsim,ncol=2) colnames(result)<-c("x","y") for (i in 1:nsim) { set.seed(i) result[i,]<- cbind(runif(1),runif(1)) }
2006 Apr 10
1
Generic code for simulating from a distribution.
Hello all, I have the code below to simulate samples of certain size from a particular distribution (here,beta distribution) and compute some statistics for the samples. betasim2<-function(nsim,n,alpha,beta) { sim<-matrix(rbeta(nsim*n,alpha,beta),ncol=n) xmean<-apply(sim,1,mean) xvar<-apply(sim,1,var) xmedian<-apply(sim,1,median)
2011 Apr 07
2
Two functions as parametrs of a function.
Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1<-unlist(par1) p2<-unlist(par2) force(p1) force(p2)
2011 Apr 06
1
Use of the dot.dot.dot option in functions.
Hi R users: I try this code, where "fun" is a parameter of a random generating function name, and I pretend to use "..." parameter to pass the parameters of different random generating functions. What am I doing wrong? f1<-function(nsim=20,n=10,fun=rnorm,...){ vp<-replicate(nsim,t.test(fun(n,...),fun(n,...))$p.value) return(vp) } This works! f1()
2006 Apr 27
1
? bug in 'sample' (PR#8813)
I have found that specifying different "sizes" in the sample command has a funny effect on the random sampling. The code below is a condensed version of a function I wrote to simulate a bootstrap method. For simplicity, I eliminated the internal bootstrap loop, but kept a statement to draw one bootstrap sample, because this is where the problem occurs. The output (mean(y)^2) should be
2015 Aug 04
2
Duda interpolación (package ' gstat ')
Hola, # Hacemos el KED. Ver función "krige()": KED.rad <- krige( formula=pluvPcp~layer, # covariable -> radar locations=lluvia.rad.pluv.spdf, newdata=radarGrid, # podría ser cualquier objeto Spatial model=v.fit, # modelo de semivariograma. maxdist=Inf