search for: nsamp

Displaying 13 results from an estimated 13 matches for "nsamp".

Did you mean: samp
2003 Jun 18
1
Ltsreg and nsamp="exact"
I'm trying to use least trimmed squares using ltsreg with nsamp="exact". When I use the following: rg <- ltsreg(x,y,nsamp="exact") I get: Error in lqs.default(x, y, nsamp = "exact", method = "lts") : NAs in foreign function call (arg 10) In addition: Warning message: NAs introduced by coercion Incidentally,...
2011 Dec 06
2
Why can't I figure this out? :S
...le <- c(floor((n + k + 1)/2), floor((n + k)/2)) quantile <- rep(quantile, length.out = 2) if(is.null(psamp)) psamp <- quantile[1] ## LTS results with robust residuals NameC_lts <- lqs(gpanew~female+female:lastinit+agenew+canadian+mom_ed+yearstudy, quantile = quantile[1], psamp = psamp, nsamp = nsamp) rr <- residuals(NameC_lts)/NameC_lts$scale[2] rr_nok <- abs(rr) > critval[1] ## robust leverage via MCD (or MVE) X <- model.matrix(NameC)[,-1] cv <- cov.rob(X, method = method, quantile = quantile[2], nsamp = dist_nsamp) rd <- sqrt(mahalanobis(X, cv$center, cv$cov)) rd_no...
2003 Feb 10
2
problems using lqs()
...24.868, 29.895, 24.200, 23.215, 21.862, 22.274, 23.830, 25.144, 22.430, 21.785, 22.380, 23.927, 33.443, 24.859, 22.686, 21.789, 22.041, 21.033, 21.005, 25.865, 26.290, 22.932, 21.313, 20.769, 21.393) and I would like to fit the following model: mod1 <- lqs(y ~ x1 + x2, method="lms", nsamp="exact") mod1$coefficients (Intercept) x1 x2 35.5293489 0.4422742 -1.2944534 mod1$bestone [1] 12 17 27 Now, instead of using the formula, I want to provide the design matrix and the response, then: X <- cbind(1, x1, x2) mod2 <- lqs.default(X, y, intercept=F,...
2009 Jan 17
2
Confidence Interval
...an for each sample. For each sample mean Xbark the 0.95-confidence interval for the mean mew=0 is given by... Ik= ( Xbark plus or minus 1.96/10) Find the number of intervals such that 0 does not belong to Ik. How many of them do you expect to see? Well so far I have come up with... N<-100; Nsamp<-100 A<-matrix(rnorm(N*Nsamp,0,1),ncol=Nsamp) means<-apply(A,2,mean) However I have no idea what I am doing and no idea if that even makes sense. Any help would be greatly appreciated as I have no experience of statistical software whatsoever. Thanks in Advance. Rachel -- View this me...
2006 Apr 27
1
? bug in 'sample' (PR#8813)
...ut thereafter the results aren't the same. If I run this code in Splus, the results are the same. Also, if I set the size argument to be the same (or eliminate this line altogether), I get reproducible results.=20=20 =20 I'm using R 2.2.0 =20 Thanks, -Lori =20 test.fun<-function(nsamp, mu,q, seed, nsim=3D2){ set.seed(seed)=20=20=20=20 mnsq<-rep(NA,nsim) for (i in 1:nsim){ y<-rnorm(nsamp,mean=3Dmu) yboot<-sample(y, size=3Dq, replace=3DT) mnsq[i]<-(mean(y)^2) } return(mnsq) } =20 test.fun(50,0,30,12345) test.fun(50,0,10,12345) =20 Lori E. Dodd, Ph.D. Nat...
2004 May 14
1
help with memory greedy storage
...f factors. Basically this repates the factors 16 times ### (for each row in the matrix). This results in a data frame with 84*16 ### rows as many columns as there are factors + 2 (probe factor + value ### to be modeled later) probeDf <- function(emat, facts) { df <- NULL n <- 1 nsamp <- ncol(emat) for ( i in 1:nrow(emat) ) { values <- c(t(emat[i,])) df.new <- data.frame(Value = values, facts, probe = rep(n, nsamp)) n <- n + 1 if ( !is.null(df) ) { df <- rbind(df, df.new) } else { df <- df.new...
2009 Nov 12
2
A combinatorial optimization problem: finding the best permutation of a complex vector
...runif(n) + 1i * runif(n) dist <- function(x, y) sqrt(sum(Mod(x - y)^2)) perms <- permutations(n) dim(perms) # [1] 40320 8 tmp <- apply(perms, 1, function(ord) dist(x, y[ord])) z <- y[perms[which.min(tmp), ]] # exact solution dist(x, z) # an aproximate random-sampling approach nsamp <- 10000 perms <- t(replicate(nsamp, sample(1:n, size=n, replace=FALSE))) tmp <- apply(perms, 1, function(ord) dist(x, y[ord])) z.app <- y[perms[which.min(tmp), ]] # approximate solution dist(x, z.app) Thanks for any help. Best, Ravi. _____________________________________________...
2007 Feb 07
3
Sample Poisson Distribution
Hi, I'm completely new to R, I am all at sea with the interface and the confusing help files, so would appreciate some help to do a simple task. Need to present the mean and variance of 100 different samples of poisson distributions (N=1000, with fixed lambda) in a file in two columnns, and then produce histograms. So far I have figured out: > N <- 1000 > x <- rpois(N, 3.1) ,
2003 Aug 26
2
Simple simulation in R
Hello all I have a feeling this is very simple......but I am not sure how to do it My boss has two variables, one is an average of 4 numbers, the other is an average of 3 of those numbers i.e var1 = (X1 + X2 + X3 + X4)/4 var2 = (X1 + X2 + X3)/3 all of the X variables are supposed to be measuring similar constructs not surprisingly, these are highly correlated (r = .98), the question is how
2008 Apr 13
2
Arrays and functions
Hi, I' am doing a stats project using R to work out the size of a t-test and wilcoxon test depending on the distribution and sample size. I just can't get it to work - I want to put my results from the function size() into an array.At the moment I keep getting the error message:Error in res[distribution, test, samplesize] <- results : subscript out of boundsCan anyone tell me where
2003 Jun 17
2
outlier
Hi, I want to calculate the R-squared between two variables. Can you advice me how to identify and remove the outliers before performing R-squared calculation? Thanks, Kan --------------------------------- SBC Yahoo! DSL - Now only $29.95 per month! [[alternate HTML version deleted]]
2011 Feb 03
0
R: mpirun .C and R
...ry(doMPI) cl <- startMPIcluster(count=2) #this will be changed later registerDoMPI(cl) #the input parameters! ... #some vecs and matrices for the C program ... #load the C code dyn.load("/export/home/example/Runs/eg.so") Est_Results<-foreach(data_iter = 1:nsamp, .combine="cbind", .inorder=TRUE ) %dopar% { outs=.C("prog1", all of the args ) do more things return( some things) } dyn.unload("/export/home/example/Runs/eg.so") closeCluster(cl) save.image("/export/home/e...
2005 Oct 06
0
a question about LMS and what constitutes outliers
...riginal Rousseeuw et al. program points out that observations 1,2,3,4 and 21 are outliers. This conslusion is arrived at by testing whether the residual is greater than 2.5 * standard error Netx I ran lqs as: m <- lqs(stackloss[,-4], stackloss[,4], method='lms', control=list (psamp=4, nsamp='exact', adjust=TRUE)) (I ran it exhaustively since that was how I ran the original program from Rousseeuw) The coefficients obtained from lqs() are more or less identical to that obtained by the original program. However the scale estimates do not match. I assume that this would be becua...