search for: weighted

Displaying 20 results from an estimated 6864 matches for "weighted".

2000 Jan 04
0
Stepwise logistic discrimination - II
I apologise for writing again about the problem with using stepAIC + multinom, but I think the reason why I had it in the first place is perhaps there may be a bug in either stepAIC or multinom. Just to repeat the problem, I have 126 variables and 99 cases. I don't know if the large number of variables could be the problem. Of couse the reason for doing a stepwise method is to reduce this
2002 Feb 06
4
Weighted median
Is there a weighted median function out there similar to weighted.mean() but for medians? If not, I'll try implement or port it myself. The need for a weighted median came from the following optimization problem: x* = arg_x min (a|x| + sum_{k=1}^n |x - b_k|) where a : is a *positive* real scalar x : i...
2011 Jan 17
2
Using summaryBy with weighted data
...rep(2,20), rep(3,20), rep(4,20), rep(5,20)) weights = runif(100, 0, 1) mydata = data.frame(response,group,weights) ## run summaryBy without weights: summaryBy(response~group, data = mydata, FUN = mean) ## attempt to run summaryBy with weights, throws error summaryBy(x~group, data = mydata, FUN = weighted.mean, w=weights ) ## throws the error: # Error in tapply(lh.data[, lh.var[vv]], rh.string.factor, function(x) { : # arguments must have same length My guess is that summaryBy is not giving weighted.mean() each group of weights, but instead is passing all of the weights in the data set each t...
2006 Aug 04
2
why does lm() not allow for negative weights?
...s? I suspect that there is a good reason for this. Yet, I can see reasonable cases when one wants to use negative case weights. Take lm() for example: ### n <- 20 Y <- rnorm(n) X <- cbind(rep(1,n),runif(n),rnorm(n)) Weights <- rnorm(n) # Includes Pos and Neg Weights Weights # Now do Weighted LS and get beta coeffs: b <- solve(t(X)%*%diag(Weights)%*%X) %*% t(X) %*% diag(Weights)%*%Y b # This seems like a valid model, but when I try lm(Y ~ X[,2:3],weights=Weights) # I get: "missing or negative weights not allowed" ### What is the rationale for not allowing negative weigh...
2007 May 31
3
Problem with Weighted Variance in Hmisc
The function wtd.var(x,w) in Hmisc calculates the weighted variance of x where w are the weights. It appears to me that wtd.var(x,w) = var(x) if all of the weights are equal, but this does not appear to be the case. Can someone point out to me where I am going wrong here? Thanks. Tom La Bone [[alternative HTML version deleted]]
2012 Oct 08
1
weighted cumulative distribution with ggplot2
Dear all, I am trying to draw a weighted cumulative distribution (as defined here http://rss.acs.unt.edu/Rdoc/library/spatstat/html/ewcdf.html) with ggplot2 however the syntax temp<-qplot(X,weight=weight,data=data,stat = "ecdf", geom = "step",colour=factor(year)) seems not to produce exactly the right figure (the...
2009 Nov 14
4
Weighted descriptives by levels of another variables
I've noticed that R has a number of very useful functions for obtaining descriptive statistics on groups of variables, including summary {stats}, describe {Hmisc}, and describe {psych}, but none that I have found is able to provided weighted descriptives of subsets of a data set (ex. descriptives for both males and females for age, where accurate results require use of sampling weights). Does anybody know of a function that does this? What I've looked at already: I have looked at describe.by {psych} which will give descripti...
2012 Jul 03
2
EM algorithm to find MLE of coeff in mixed effects model
I have a general question about coefficients estimation of the mixed model. I simulated a very basic model: Y|b=X*\beta+Z*b +\sigma^2* diag(ni); b follows N(0,\psi) #i.e. bivariate normal where b is the latent variable, Z and X are ni*2 design matrices, sigma is the error variance, Y are longitudinal data, i.e. there are ni
2008 Mar 10
3
Weighting data when running regressions
Dear R-Help, I'm new to R and struggling with weighting data when I run regression. I've tried to use search to solve my problem but haven't found anything helpful so far. I (successfully) import data from SPSS (15) and try to run a linear regression on a subset of my data file where WEIGHT is the name of my weighting variable (numeric), e.g.: library(foreign)
2006 Aug 30
5
working with summarized data
The data sets I am working with all have a weight variable--e.g., each row doesn't mean 1 observation. With that in mind, nearly all of the graphs and summary statistics are incorrect for my data, because they don't take into account the weight. **** For example "median" is incorrect, as the quantiles aren't calculated with weights: sum( weights[X < median(X)] )
2008 Jul 23
2
Weighted variance function?
There is a R function to calculate weighted mean : weighted.mean() under stats package. Is there any direct R function for calculating weighted variance as well? [[alternative HTML version deleted]]
2005 Apr 13
1
logistic regression weights problem
Hi All, I have a problem with weighted logistic regression. I have a number of SNPs and a case/control scenario, but not all genotypes are as "guaranteed" as others, so I am using weights to downsample the importance of individuals whose genotype has been heavily "inferred". My data is quite big, but with a dummy e...
2011 Jul 06
2
how to best present concentrated data points/ ggplot2
Hi all, I am trying to plot a weighted density plot for two different types and want to show the data points on the x axis. The code is as follows. The data points are very concentrated. Is there a better way to present it( should I set the alpha value or something else)? Thanks! YL library(ggplot2) x <- rnorm(10000) a <- rn...
2017 May 11
2
What's the weight means in the dump of edge info from USR2?
Thank you, that is very helpful. And actually I do have a few further questions regarding this: 1. This weight is not the one specified in Subnet, this should be something related to the host, where can I manually configure this? 2. The weight value is ONLY take round trip latency as the measurement, or including CPU power and other factors into consideration? 3. I don't know how this
2012 Jul 18
1
How does "rlm" in R decide its "w" weights for each IRLS iteration?
...l down-weighting for each case. init (optional) initial values for the coefficients OR a method to find initial values OR the result of a fit with a coef component. Known methods are "ls" (the default) for an initial least-squares fit using weights w*weights, and "lts" for an unweighted least-trimmed squares fit with 200 samples. b. The returned values: w the weights used in the IWLS process wresid a working residual, weighted for "inv.var" weights only. How to use these input arguments? Anybody please shed some light? Also, is my understanding below correct?...
2009 Jul 23
5
Random # generator accuracy
...ry to see the code for your 'brief test' before anyone could meaningfully comment on your results. But your results for a single test could have been a valid "random" result." I've re-created what I did below. The problem appears to be with the weighting process: the unweighted sample came out much closer to the actual than the weighted sample (>1% error) did. Comments? Jim > x [1] 1 2 3 4 5 6 7 8 9 10 11 12 > weights [1] 1 1 1 1 1 1 2 2 2 2 2 2 > a = mean(replicate(1000000,(sample(x, 3, prob = weights))));a # (1 million samples from x, of size...
2008 Jun 03
3
Rpart and case weights: working with functions
I can't get rpart accept case weights defined inside a function. It keeps using the copy defined in the "global" environment (if they exists) instead of the function-defined ones. Here is what I do: test.function <- function (formula, data) { weights <- rep(.1, 100) rpart(formula, data, weights) } test.function(x~y, data) And I get an error: > Error in
2007 May 08
5
Weighted least squares
Dear all, I'm struggling with weighted least squares, where something that I had assumed to be true appears not to be the case. Take the following data set as an example: df <- data.frame(x = runif(100, 0, 100)) df$y <- df$x + 1 + rnorm(100, sd=15) I had expected that: summary(lm(y ~ x, data=df, weights=rep(2, 100))) summary(l...
2017 May 10
2
What's the weight means in the dump of edge info from USR2?
Hi, tinc experts abc to def at x.x.x.x port 655 options d weight 540 How’s the 540 weight been calculated? What does it mean? How can I leverage this weight? The d of after options mean direct?
2010 Apr 16
2
Weights in binomial glm
I have some questions about the use of weights in binomial glm as I am not getting the results I would expect. In my case the weights I have can be seen as 'replicate weights'; one respondent i in my dataset corresponds to w[i] persons in the population. From the documentation of the glm method, I understand that the weights can indeed be used for this: "For a binomial GLM prior