Fix weighted.mean(w =) argument's denominator#2
Open
zekiakyol wants to merge 1 commit intoSTAT-ATA-ASU:gh-pagesfrom
Open
Fix weighted.mean(w =) argument's denominator#2zekiakyol wants to merge 1 commit intoSTAT-ATA-ASU:gh-pagesfrom
weighted.mean(w =) argument's denominator#2zekiakyol wants to merge 1 commit intoSTAT-ATA-ASU:gh-pagesfrom
Conversation
Thank your for the great post!
Even though R automatically re-weights if sum of the weights are not equal to 1, following fix makes is mathematically correct in my opinion:
Since `folds` object is a vector, `sum(folds)` is sum of numerically 1s, 2s, 3s, 4s, 5s which is greater than total sample size 1000.
```
> sum(folds)
[1] 2956
> table(folds)/sum(folds)
folds
1 2 3 4 5
0.07104195 0.07171854 0.06326116 0.06562923 0.06664411
```
I think the correct denominator and weight is
```
> sum(xtabs(~folds))
[1] 1000
> table(folds)/sum(xtabs(~folds))
folds
1 2 3 4 5
0.210 0.212 0.187 0.194 0.197
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank your for your great post! It immensely helps to grasp the topic.
Even though R automatically re-weights if sum of the weights are not equal to 1, following fix makes is mathematically correct in my opinion:
Since
foldsobject is a vector,sum(folds)is numeric sum of 1s, 2s, 3s, 4s, 5s which is greater than total sample size 1000.I think the correct denominator and weight is: