search for: wmean

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

Did you mean: mean
2012 Nov 14
1
Winsorisation function
Dear all, someone can find what I doing wrong with the following function. It is for winsorisation mean. At my eyes it is ok, but for reason I sometimes it is changing the results when I change the k value. wmean <- function (x, na.rm = FALSE, k = 1) { if (any(i.na <- is.na(x))) { if (na.rm) x <- x[!i.na] else return(NA) } n <- length(x) if (!(k %in% (0:n))) stop("Invalid argument for 'k'.") x <-...
2001 Mar 22
2
Two-argument functions in tapply()
...e income) F is a factor (e.g. with 2 levels) and W is a case weight (data are from household sample but an individual was interviewed, weights are functions of number of persons in the house hold). I wanted to compute a means of X weighted by W within groups defined by F with the function below: wmean <- function(x,w) { wm <- sum( x*w/sum(w) ) wm } used within tapply() function, like: tapply(x,f,wmean,w=w) but I received some values with 2 warnings: Warning messages: 1: longer object length is not a multiple of shorter object length in: x * w 2: longer object lengt...
2005 Aug 26
1
Help in Compliling user -defined functions in Rpart
...quot;mean=",format(signif(yval,digits)), "MSE=",format(signif(dev/wt,digits)), sep='') }) } temp.eval<-function(y,wt,parms){ n<-length(y) r<-wt for (i in 1:n-1) {r[i+1]=(sum(wt[1:i])+0.5*wt[i+1])/n} #fractional rank r[1]<-0.5*wt[1]/n wmean<-sum(y*wt)/sum(wt) ci<-2*sum(wt*(y-wmean)*(r-0.5))/sum(wt*y) #concentration index for socio-economic inequality dev<-abs(ci)*(1-abs(ci)) #deviance following the gini impurity approach list(label=wmean,deviance=dev) } temp.split<-function(y,wt,parms,continous)...
2007 Feb 18
3
User defined split function in rpart
Dear R community, I am trying to write my own user defined split function for rpart. I read the example in the tests directory and I understand the general idea of the how to implement user defined splitting functions. However, I am having troubles with addressing the data frame used in calling rpart in my split functions. For example, in the evaluation function that is called once per node,
2006 Oct 10
2
find weighted group mean
HI, I am trying to figure out an efficient way to calculate group means and associate each entry with it. I made up an example: A = rep(rep(0:1,each=2),3) B = rep(rep(0:1,4),3) C = rep(rep(c(0,0,1,1),2),3) X =cbind(rnorm(24,0,1),runif(24,0,1),A,B,C) A B C [1,] -1.92926469 0.32213127 0 0 0 [2,] -0.83935617 0.77794096 0 1 0 [3,] -1.27799751
2012 Apr 02
6
como hacer grafico de medias con barra de desviacion estandar ??
estimados no he encontrado el modo de hacer en R el tipico grafico de medias con la desviacion estandar asociada ... me explico, tengo 2 variables numericas, para la variable independiente se elijen 3 niveles y en cada uno de ellos se mide 15 veces la variable respuesta, para este data.frame se quiere mostrar en un grafico en el eje X los 3 niveles escogidos y en el Y la vbla respuesta, pero no e