search for: nsim

Displaying 20 results from an estimated 109 matches for "nsim".

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 <- c(1:20/1000) alpha1 <- c(1:82) aeven1 <- alpha[2 * 1:41] aodd1 <- alpha[-2 * 1:41] alpha2 <- c(1:40) aeven2 <- alpha2[2 *...
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: set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresu...
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 <- 200 I <- 5 taus <- c(0.480:0.520) h <- c(1:20/1000) codd <- c(1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,7...
2007 Oct 11
3
reason for error in small function?
...o 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) ### non-working function #### gen.rpoints <- function(events, poly, nsim){ rpoints <- array(0, dim=c(nrow(events),2,nsim)) for (i in 1:nsim) { rpoints[, ,i] <- csr(poly, nrow(events)) } }
2016 Apr 25
0
use switch or function in connecting different cases.
This is my current work.Now i am trying to use a function to do the normal distribution simulation. rm(list=ls()) t <- u<- mann<- rep(0, 45) Nsimulation<-function(S1,S2,Sds,nSims) { set.seed(1) for (sim in 1:nSims) { matrix_t <-matrix(0,nrow=nSims,ncol=3) matrix_u<-matrix(0,nrow=nSims,ncol=3) matrix_mann <-matrix(0,nrow=nSims,ncol=3) #gen...
2006 Jul 20
1
Loss of numerical precision from conversion to list ?
...00000e+00 4.00000e+00 4.00000e+00 #[11] 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 #[21] 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 4.00000e+00 5.77316e-15 # ! Notice the last (27th) value very close to 0 nsim<-10 set.seed(10) #nsim x K array of ChiSq(1)-variates w.k.sq.mat<-matrix(rchisq(nsim*K,1),nrow=nsim) #nsim x 1 array of ChiSq(n-p-K)-variates w.sum2<-rchisq(nsim,n-p-K) ### vectorized computation of nsim=10 realizations ### of a part of the RLR-statistic under the Nu...
2016 Apr 25
2
R: use switch or function in connecting different cases.
...written 11 codes separately for all of the cases. But i have been told that it can all been done within one code. can anyone give me a brief idea on it. I just managed to write till here and it perhaps isnt correct .. #set up matrix for storing data from simulation matrix_t <-matrix(0,nrow=nSims,ncol=3) matrix_u<-matrix(0,nrow=nSims,ncol=3) matrix_mann <-matrix(0,nrow=nSims,ncol=3) sample_sizes<- matrix(c(10,10,10,25,25,25,25,50,25,100,50,25,50,100,100,25,100,100), nrow=2) p1<-p2<-p3<-vector() nSims<-10 alpha<-0.05 set.seed(1)...
2003 Oct 28
1
error message in simulation
...use R 1.8.0 and Windows XP professional. My computer has a Pentium 4 2.4 with 512 MB memory. Thanks in advance. best regards, Yu-Kang Tu Clinical Research Fellow Leeds Dental Institute University of Leeds ## change scores simulation close.screen(all=TRUE) split.screen(c(3,3)) nitns<-10000 nsims<-100 r<-0.1 param1<-c(1:nitns) param2<-c(1:nitns) param3<-c(1:nitns) param4<-c(1:nitns) param5<-c(1:nitns) param6<-c(1:nitns) param7<-c(1:nitns) param8<-c(1:nitns) param9<-c(1:nitns) param10<-c(1:nitns) param11<-c(1:nitns) param12<-c(1:nitns) param13<-c...
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]...
2016 Apr 06
0
R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]
...to matrix then use a loop for sample sizes sample_sizes<- matrix(c(10,10,10,25,25,25,25,50,25,100,50,25,50,100,100,25,100,100), nrow=2) #create vector to combine all std deviations sds<-c(4,6,8,10,12,14) # this number is needed below nsds<-length(sds) set.seed(8) #number of simulations nSims<-10000 #set significance level,alpha for the whole simulatio alpha<-0.05 #set empty vector of length no.of _calculations_ to store p-values # Note: you have 54 calculations, not 10000 ncalcs<-dim(sample_sizes)[2]*nsds t_equal <-c(rep(0,length=ncalcs)) t_unequal <-c(rep(0,length=nca...
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) rho.=0.1 Nsim=100000 simPD.vec=0*(1:Nsim) systemic = rnorm(Nsim,0...
2002 Feb 11
0
profile
...Nstar<-pmax ( 0,Nstar) Ystar<-ifelse(Nstar<1, (1 + gN*(1 - Nstar))* Nstar^(gN), 1) Ystar<-pmax ( 0, Ystar) Y.model <- Ystar*Ymax Y.model } # simulate experimental data for predictors nsim <- 300 Popn <- rnorm(nsim,PopStd,0.1*PopStd) Dmax <- rnorm(nsim,140.68,47.45) AWC <- rnorm(nsim,186.86,47.41) SumEp <- rnorm(nsim,318.54,32.53) PotYield3 <- rnorm(nsim,0.16180,0.01167) Nsoil <- rnorm(nsim,94.07,34.06) Bdfi...
2016 Apr 06
0
R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]
...es<- > matrix(c(10,10,10,25,25,25,25,50,25,100,50,25,50,100,100,25,100,100), > nrow=2) > > #create vector to combine all std deviations > sds<-c(4,6,8,10,12,14) > # this number is needed below > nsds<-length(sds) > set.seed(8) > > #number of simulations > nSims<-10000 > #set significance level,alpha for the whole simulatio > alpha<-0.05 > > #set empty vector of length no.of _calculations_ to store p-values > # Note: you have 54 calculations, not 10000 > ncalcs<-dim(sample_sizes)[2]*nsds > t_equal <-c(rep(0,length=ncalcs))...
2006 Mar 08
1
power and sample size for a GLM with Poisson response variable
...ches give much different power > estimates (96% vs. 55% or so). My problem may be better addressed > as binomial logistic regression, maybe then the simulation and the > asymptotic estimates my agree better. > > sim.pwr<-function(means=c(0.0065,0.0003),ptime=c(1081,3180),nsim=1000) > { # a two group poisson regression power computation # based > simulating lots of Poisson r.v.'s # input rates followed by a vector > of the corresponding person times # the most time consuming part is > the r.v. generation. > # power is determined by counting the how...
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 n<-c(19,20,19,21,19,20,16,19,40,81) # total subject in dose-response experiment y<-c(19,18,19,14,15,4,0,0,0,2) # success in each trials dta<-cbind(x,n,y) dta<-as.data.frame(dta) # creating data f...
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, corstr="exch", scale.fix=TRUE) ............. corr_gee<-summary(fit)$correlation[1] se_corrgee<-summary(fit)$correlation[2] est[i,]<-c(corr_gee, se_cor...
2012 Nov 23
1
Spatstat: Mark correlation function
...e 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 patterns, normally used for Ripley's K: ME<-envelope(A, markcorr, nsim = 1000) And I produce the figure below. My question is: Is this a justified use of nsim if the envelope is based on simulations of CSR? Or should I display the Mark correlation function without the envelopes? <http://r.789695.n4.nabble.com/file/n4650579/MARKCORR_FOR_R_FORUM.png> Thanks,...
2007 Oct 03
2
Speeding up simulation of mean nearest neighbor distances
...hrough 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, nrow=nsim) for (i in 1:nsim) { rpp <- runifpoint(22, win=owin(c(0,1),c(0,1)), giveup=1000) for (k in 1:nth) D[i,k] <- mean(nndist(rpp ,k=k)) } D } sim.nth.mdist(5,100)
2008 Apr 08
1
Weibull maximum likelihood estimates for censored data
...le(lLne,start = list(A = 0.02)) Lw <- lLnw(coef(fit1)) # Maximum log likelihood : Weibull Le <- lLne(coef(fit2)) # Maximum log likelihood : Exponential LR0 <- (Le/Lw) # Likelihood ratio with duration sample NSimM <- cbind(as.matrix(sort(rchisq(nsim,1,0))),runif(nsim,0,1)) # chi-square df1 simulations, uniform rvs Uniftest <- runif(1,0,1) firstrow <- cbind(LR0,Uniftest) # use sample LR as LR NSimM <- rbind(firstrow,NSimM) Test <- matrix(rep(0,2*(ns...
2006 Feb 06
3
power and sample size for a GLM with poisson response variable
Hi all, I would like to estimate power and necessary sample size for a GLM with a response variable that has a poisson distribution. Do you have any suggestions for how I can do this in R? Thank you for your help. Sincerely, Craig -- Craig A. Faulhaber Department of Forest, Range, and Wildlife Sciences Utah State University 5230 Old Main Hill Logan, UT 84322 (435)797-3892