search for: nsamples

Displaying 20 results from an estimated 42 matches for "nsamples".

Did you mean: samples
2011 May 16
1
Matrix manipulation in for loop
Hi all, I have a problem with getting my code to do what I want! This is the code I have: create.means.one.size<-function(nsample,var,nboot){ mat.x<-matrix(0,nrow=nboot,ncol=nsample) for(i in 1:nboot){ mat.x[i,]<-sample(var,nsample,replace=T) } mean.mat<-rep(0,nboot) for(i in 1:nboot){ mean.mat[i]<-mean(mat.x[i,]) } sd.mean<-sd(mean.mat) return(mean.mat) } where
2008 Oct 22
2
Help with functions
Hi there, I have a the following function which takes a name(fname), total number of rows (Total), number of times to make a sample(nSample), number of records/rows to be included in each sample(nPatient). then it generates required samples and calculates the mean and standard deviation of the columns for each sample and finally in calculates the grand mean and standard deviation. The problem
2004 Oct 29
1
fitting linear mixed model for incomplete block design
Dear R developers and users: I have the following data, x is the response vaiable, nsample(individual) nested within trt, and subsample nested within nsample, I want to fit trt as fixed effect, and block, nsample(trt) as random effects using lme, is the following coding correct? dat$vgrp <- getGroups(dat, form = ~ 1|trt/nsample, level = 2) ge.lme1 <- lme(fixed=x~trt, data=dat,
2016 Apr 22
0
R2BayesX help
Hi, I wonder if anyone can help me with this issue. I am using R2BayesX. It seems that the model can maximally contain 20 interactions. When the number of interaction terms exceed 20, the code stops working. Here is a piece of toy code. rm(list=ls()) library(BayesX) library(R2BayesX) #data generating model f2<-function(x1,x2,x3,x4) { y<-2*sin(pi*x1)*1.5+exp(2*x2)/3+2 * sin(4 * pi * (x3
2012 Mar 16
2
Elegant Code
Hi, Can anyone help to write a more elegant version of my code? I am sure this can be put into a loop but I am having trouble creating the objects b1,b2,b3,...,etc. b1 <- rigamma(50,1,1) theta1 <- rgamma(50,0.5,(1/b1)) sim1 <- rpois(50,theta1) b2 <- rigamma(50,1,1) theta2 <- rgamma(50,0.5,(1/b2)) sim2 <- rpois(50,theta2) b3 <- rigamma(50,1,1) theta3 <-
2009 May 21
1
Need help on ploting Histograms
this is the command i made for a normal distribution, but when i try to plot the histograms, i dont know why the bars don't stick on the line... nsamples<-1000 sampsize<-15 Samples<-matrix(rnorm(nsamples*sampsize,0,1),nrow=nsamples) a<-apply(Samples,1,var) NC14<-a*14 x<-0:40 plot(x,dchisq(x,14),type='h') hist(NC14,freq=F,add=T) -- View this message in context: http://www.nabble.com/Need-help-on-ploting-Histograms-tp23652...
1997 Oct 28
1
R-beta: Assigning column names in a data frame
You may recall that I was recently constructing a function to bootstrap the coefficients in a linear regression model. In S-PLUS I was using the model.matrix function applied to the fitted model, then taking the QR decomposition of that. I discovered that it was in fact easier to accomplish the bootstrapping in R because the QR decomposition of the model matrix is stored with the fitted model.
1997 Oct 17
1
R-beta: more model.matrix
I am trying to show some techniques to my graduate regression class. The textbook mentioned using bootstrap samples of regression coefficients for assessing variability. I decided to show them reasonably effective ways of doing the resampling. The following is a function I wrote to create bootstrap samples of coefficients from a fitted linear regression model. bsCoefSample <- ##
2011 Feb 03
1
problem with parLapply from snow
...emoteErrors(val) : 2 nodes produced errors; first error: no applicable method for 'lapply' applied to an object of class "list" ". Where this is the problem line of code "yusum <- parLapply(cl, yu, sum)" The function is CallSnow <- function (Nnodes = 2, Nsamples = Nnodes) { require(Rmpi) require(snow) cat("Using snow package, asking for ", Nnodes, "nodes \n") cl <- makeCluster(Nnodes, type="MPI") on.exit(stopCluster(cl)) #print(do.call("rbind", clusterCall(cl, function(cl) Sys.info()["nodename"]...
2012 Nov 24
6
IMPORTANT!!!! PLEASE HELP ME
Hi, I want to generate 10000 samples from normal distribution with replacement case and every sample size is 50. What should I do ? -- View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676.html Sent from the R help mailing list archive at Nabble.com.
2007 Jan 22
0
Recursive-SVM (R-SVM)
I am trying to implement a simple r-svm example using the iris data (only two of the classes are taken and data is within the code). I am running into some errors. I am not an expert on svm's. If any one has used it, I would appreciate their help. I am appending the code below. Thanks../Murli ####################################################### ### R-code for R-SVM ### use leave-one-out
2009 May 13
2
Problems with randomly generating samples
Dear R users, Can anyone please tell me how to generate a large number of samples in R, given certain distribution and size. For example, if I want to generate 1000 samples of size n=100, with a N(0,1) distribution, how should I proceed? (Since I dont want to do "rnorm(100,0,1)" in R for 1000 times) Thanks for help Debbie
2007 Dec 19
0
leaps
...ning or may I run "regsubsets" on the original model bringing in all possible frequencies (88 in all as sums of sinuoids) ? Thank you so much. Kind regards, Maura ******************************************************************** T <- xx$timestamp[end] - xx$timestamp[start] nsamples <- end +1 - start nfr <- ceiling(nsamples/2) yy <- xx[start:end,"amplitude"] tt <- xx[start:end,"timestamp"] cosmat <- matrix(nrow=nsamples,ncol=nfr) coscol <- NULL sinmat <- matrix(nrow=nsamples,ncol=nfr) sincol <- NULL for(i in 1...
2008 Oct 23
3
Fuctions help!
Hi everyone, I have a question about functions. I have two functions: Sampling=function(fname,Total,nSample,nPatient){......return(list(Gmean,Gsd))} Power=function(alfa,m1,m2,s1,s2,n1,n2){....return(powe)} I want to use "Gmean" and "Gsd" which are the returned values from "Sampling" function, in "Power" function. i.e. when I call "power" I want
2001 Jul 24
0
bug in residuals.rpart?
...[[3]] [1] "residuals.rpart(tr, \"deviance\")" [[4]] [1] "residuals(tr, \"deviance\")" The problem is that tr$frame does not contain a field called 'yprob'. I created the dat matrix above as follows set.seed(123) Nvars <- 4; Nsamples <- 1000; N <- Nvars*Nsamples; dat <- matrix(sample(1:2, N, c(0.5,0.5), replace=TRUE), Nsamples, Nvars) #dat <- sample.bnet(bnet, 30) dat <- as.data.frame(dat) for (i in 1:Nvars) { dat[,i]<- factor(dat[,i], 1:2) } names(dat) <- c(paste("X", 1:3, sep=""), &...
2009 Feb 24
0
any help with pyogg and pyvorbis?
...hannels() vd = ogg.vorbis.VorbisInfo(channels = channels, rate = inwav.getframerate(), quality = 0.2).analysis_init() os = ogg.OggStreamState(5) map(os.packetin, vd.headerout()) og = os.flush() while og: og.writeout(fout) og = os.flush() nsamples = 1024 eos = 0 total = 0 while not eos: data = inwav.readframes(nsamples) total = total + nsamples if not data: vd.write(None) break vd.write_wav(data) #print 100.0 * total / inwav.getnframes() vb = vd.blockout() while vb: vb.analysis() v...
2001 Jul 20
1
frames and formulas
...3) CPD$tr <- tree(V4 ~ ., fam.vals) else stop(paste("too many parents for tree CPD", CPD$id)) end list(CPD = CPD, dev = deviance(CPD$tr), score = dev) } Thanks for your help! Kevin P.S. You can reproduce the above problem using the following script Nvars <- 4; Nsamples <- 10; N <- Nvars*Nsamples; dat <- matrix(sample(1:2, N, c(0.5,0.5), replace=TRUE), Nsamples, Nvars) #dat <- sample.bnet(bnet, 10) dat <- as.data.frame(dat) for (i in 1:Nvars) { dat[,i]<- factor(dat[,i], 1:2) } tr <- tree(V4 ~ ., dat) #deviance(tr) foo <- function(dummy)...
2010 Nov 15
5
Sampling problem
Hey, I am hoping someone can help me with a sampling question. I have a data frame of 8 variables (the first column is the subjects' id): SubID CSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 1 6 5 6 2 6 2 2 4 2 6 4 7 2 6 6 2 3 3 5 5 5 5 5 5
2012 Aug 01
3
repeating a function across a data frame
Hello everyone. Like others on this list, I'm new to R, and really not much of a programmer, so please excuse any obtuse questions! I'm trying to repeat a function across all possible combinations of vectors in a data frame. I'd hugely appreciate any advice! Here's what I'm doing: I have some data: 40 samples, ~460 000 different readings between 1 and 0 for each sample. I
2011 Jan 04
1
Resampling to find Confidence intervals
Hi, I'm doing some modelling (lm) for my 3rd year dissertation and I want to do some resampling, especially as I'm working with microbes, getting them to evolve resistance to antimicrobial compounds, and after each exposure I'm measuring the minimum concentration required to kill them (which I'm expecting to rise over time, or exposures), I have 5 lineages per cleaner, and