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
0
votes
1 answer

Getting a weighted average in R when joining two tables

I'm just going to apologize in advance for anything confusing and/or dumb about this question. I am completely new to R but because of larger project restrictions, I am currently forced to use it for this task. Right now I have two tables that I…
0
votes
1 answer

Bootstrap of weighted means in R

I have a data frame with 27 samples divided in 3 strata. I want to replicate 500 times a weighted mean, where the mean is calculate among the random selection of 3 samples for stratum and the weight is the relative area of the strata. My idea was…
Matt_4
  • 147
  • 1
  • 12
0
votes
1 answer

R - Weighted mean over different lists of data frames

I have to calculate a weighted mean over two lists. The first list looks like this: april_return list[5] List of lenght 5 April2002 double[4] 0.05 0.01 0.02 0.1 April2003 double[19] 0.06 0.03 0.01…
Bit
  • 59
  • 5
0
votes
0 answers

Change 'N' within summary output

My summarySE output looks like this: summary <- summarySE(df, measurevar = "Cover", groupvars = c("Year","Loc")) Year Loc N Cover sd se ci 1 2010 1 104 0.10560533 0.2163059 0.02121054 0.04206610 2 2010 2 97…
0
votes
0 answers

Python calculate weighted average of multiple columns grouped by multiple columns

Let's say I have the following dataframe: State Type Denominator payment1 payment2 payment3 State1 A 40 1000 8000 1000 State1 A 50 5000 4000 5000 State1 B 70 6000 5000…
0
votes
2 answers

Weighted mean calculation in R with missing values

Does anyone know if it is possible to calculate a weighted mean in R when values are missing, and when values are missing, the weights for the existing values are scaled upward proportionately? To convey this clearly, I created a hypothetical…
milaske
  • 55
  • 2
  • 8
0
votes
1 answer

calculate weighted average for each day and id based on time intervals in PostgreSQL

I have a table in a PostgreSQL database that looks like this: stid | e5 | e10 | diesel | date -----+------+------+--------+------------------------ e850 | 1300 | 1400 | 1500 | 2016-05-02 05:30:01+02 e850 | 1400 | 1500 | 1700 | 2016-05-02…
Niklas
  • 80
  • 6
0
votes
1 answer

Weighted Means for columns in Pandas DataFrame including Nan

I am trying to get the weighted mean for each column (A-F) of a Pandas.Dataframe with "Value" as the weight. I can only find solutions for problems with categories, which is not what I need. The comparable solution for normal means would…
TChi
  • 383
  • 1
  • 6
  • 14
0
votes
1 answer

Calculate weighted average in R dataframe

"f","index","values","lo.80","lo.95","hi.80","hi.95" "auto.arima",2017-07-31 16:40:00,2.81613884762163,NA,NA,NA,NA "auto.arima",2017-07-31 16:40:10,2.83441637197378,NA,NA,NA,NA "auto.arima",2017-07-31…
Ashag
  • 837
  • 2
  • 15
  • 24
0
votes
3 answers

Reading delimited file columns as lists, returning rows instead

I have a large .txt file and I'd like to read each column as a list. The file has 9 columns of delimited floats, the first line (of a few thousand) is: 0.49406565E-323 0.29532530E+003 0.89244837E+001 0.20901651E-002 0.34989878E+001 …
rh1990
  • 880
  • 7
  • 17
  • 32
0
votes
1 answer

Getting Weighted Average within a category with multiple sub categories

Joe owns a worldwide DVD rental store. He has stores throughout the globe in different regions. Each month he likes to see if his equipment in his stores is up-to-date by finding the percentage of his inventory with a certain status of "Current,"…
user7753835
0
votes
2 answers

Calculated Weighted Average in SQL

I am trying to calculate the YTD value for every month. How could I achieve this in SQL Server? Green is how my data looks in the table.I am suppose to calculate the one in Yellow. Your help will be much appreciated. Year Month Monthly_Score…
Swethak
  • 3
  • 1
  • 2
0
votes
0 answers

How to get weighted average for CTR in MySQL?

Here is what my data looks like: I would like to see a roll up of the total impressions, total clicks and average ctr for a given query. E.g., Except this is just an average of the ctr column values; whereas I need a weighted average. I think this…
Drewdavid
  • 3,071
  • 7
  • 29
  • 53
0
votes
1 answer

Weighted mean through the By function

I'm struggling in adjusting a function I wrote, and it's giving me a headache, so thought I'd post it here. in the function I'm using the "by" function of R, which puts the dataframe in subsets and runs a function on it. Now I'm expanding the…
0
votes
1 answer

How to get weighted average where latest value is weighted twice as all previous?

I've used this before, but just can't remember it, and can't find it anywhere. It's a running average where the newest value has twice the weight of all the previous values (combined), so that as time passes the oldest values have less and less…
Doug Null
  • 7,989
  • 15
  • 69
  • 148