Questions tagged [weighted-average]

The weighted average or weighted mean is similar to an arithmetic mean where instead of each of the data points contributing equally to the final average, some data points contribute more than others.

If all the weights are equal, then the weighted mean is the same as the arithmetic mean.

The mathematical expression for the weighted average is

enter image description here

Read more here

476 questions
1
vote
2 answers

expand.grid very big vectors exceeding memory limit

I have a problem with R. I have 6 vectors of data. Each vector will have weight. I need to calculate the quantile of each possible scenarios. For example : v1=c(1,2) v2=c(0,5) weights=c(1/3,2/3) I would normally use…
stlows
  • 21
  • 2
1
vote
0 answers

R: Weighting calculation getting invalid 'type' (character) of argument

I have the following data set: Date sector Forward TRT1Y USD CIQ MKVAL (time) (fctr) (dbl) (dbl) 1 1999-09-30 Consumer Discretionary 0.11622590 19856.182 2 1999-09-30 …
putty
  • 744
  • 1
  • 6
  • 14
1
vote
1 answer

Weights in Panel Data - Pandas

I have a pandas DataFrame that is indexed by monthly dates and contains 1's and 0's. For each date (row), I would like to sum the row and then divide each data point by that sum in order to determine weights over time (if the datapoint is zero it…
The User
  • 55
  • 3
  • 11
1
vote
1 answer

Weighted average rate in VBA

I am quite new to VBA so I am sorry if my question might seems very trivial. I would love to write a function in VBA which helps to estimate weighted average rate (for loan portfolio, for instance). I wrote the following VBA code: Function…
Jack
  • 167
  • 2
  • 12
1
vote
0 answers

Best way to calculate weighted average percent in a pandas dataframe for a heatmap?

I'm trying to make a heat map using a weighted average percentage. I was trying to do something similar to using a calculated field in a pivot table in excel, but wound up with two grouped data frames with the same index and columns. The grouping…
JD2015
  • 155
  • 1
  • 2
  • 12
1
vote
1 answer

Algorithm process is slow

Think about a platform where an user choose what factors he give more importance. For example 5 factors of criteria A, B, C, D, E Then each product review has a weighing for A1, B1, C1, D1, E1. So, if he gave more importance to A, then the weighing…
anvd
  • 3,997
  • 19
  • 65
  • 126
1
vote
1 answer

Aggregating by indeces and reweighting in R

I have a ton of Price data that is indexed by State, Date, and UPC (Product Code). I want to aggregate away UPC, and combine the Prices by taking a weighted average. I will try to explain it, but you may just want to read the code below. Each…
ejn
  • 415
  • 6
  • 16
1
vote
1 answer

what is the better way to calculate unique value based on weighted variables?

I have to create a priority queue for elements which have multiples variables with an associated weight, what is the better way calculate a unique value in order to get the order of each element in the queue? using a weighted average or using some…
1
vote
2 answers

Data frame/matrix row times vector/list element wise

I have a matrix that looks like this raw<- c(1,2,3,4,5,6,7,8,9) mat<- matrix(raw,ncol = 3, nrow = 3) to get me [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 Plus a vector or list vector<-c(1,2,3) What I need to…
ThatQuantDude
  • 759
  • 1
  • 9
  • 26
1
vote
0 answers

Implementing a popularity based priority graph

I want to implement a graph where nodes are items and outward edges are the popularity of the next item. (e.g. I've done this task, what are the most popular tasks performed after it?) My initial algorithm simply incremented a popularity…
AaronF
  • 2,841
  • 3
  • 22
  • 32
1
vote
1 answer

How to do Weighted Averaging of n conscutive values in an Array

I have a 900×1 vector of values (in MATLAB). Each 9 consecutive values should be averaged -without overlap- result in a 100×1 vector of values. The problem is that the averaging should be weighted based on a weighting vector of [1 2 1;2 4 2;1 2 1].…
bateni
  • 11
  • 3
1
vote
1 answer

Preparing data for surface3d in R. More fast code please

I am trying to get "surface3d plot" from 120,000 rows of csv data, but my code is too slow and the processing time will be over 12 hours. Which place should be changed? ( interp() process time also will be over 12 hours. If it is possible, I want to…
tre56h45
  • 23
  • 3
1
vote
1 answer

Algorithm for finding the optimal weights for prediction

Consider I have the following weights and quantitative parameters: w_1..w_n, p_1..p_n. 0 <= w <= 1. I also have a selection of cases of parameters and associated values. What algorithms exist for finding the optimal weights to minimize the errors of…
MortenGR
  • 803
  • 1
  • 8
  • 22
1
vote
1 answer

Algorithm to calculate a general score and each criteria independently

Imagine something like booking reviews, where we have for each review some scores by criteria and a general rating. For the sake of simplicity i will use letters, but imagine A like comfort, B localization, and so on. Available rating is (1-4) …
anvd
  • 3,997
  • 19
  • 65
  • 126
1
vote
1 answer

Error as.numeric: weighted average subset works full data set doesn't

I am an R neophyte but this one really has me stumped--I really hope more experienced people can help me out. I am estimating a simple weighted average. In my case I have counties numerically coded (FIPS), a soil carbon value, and the area covered…
gren
  • 21
  • 5