Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCS code #19

Merged
merged 8 commits into from
Oct 26, 2022
Merged

MCS code #19

merged 8 commits into from
Oct 26, 2022

Conversation

mmartinoli87
Copy link
Contributor

Uploading MCS R code

@codecov-commenter
Copy link

Codecov Report

Merging #19 (6d74967) into main (3433555) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #19   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files          22       22           
  Lines        1086     1086           
=======================================
  Hits         1080     1080           
  Misses          6        6           

Copy link
Contributor

@AldoGl AldoGl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mmartinoli87 for your code. In order to move forward it would be helpful if you could add some comments, particularly -but not exclusively- explaining what the various functions do even in abstract terms, and perhaps also describing the meaning of the key variables (see e.g., the questions I made on the code in my review).

These comments would be very useful in the transition of the code from R to Python, because they would allow a Python programmer to easily interpret the code without being an expert in R. Moreover, we can then add your comments in the docstrings of the new Python code.

You could add your code comments directly within the "MCS.R" module. Alternatively you can write them here in the chat and I can update the file.

black_it/MCS.R Outdated
@@ -0,0 +1,105 @@
# Reading the data

mData <- read.csv("Data.csv")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the content of the mData matrix? Specifically, I see it has 4 columns but what do those columns represent exactly?

black_it/MCS.R Outdated
mData <- read.csv("Data.csv")
attach(mData)

fnComplete <- function(x,l=301) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this function do? A line of comment would be useful here

black_it/MCS.R Outdated

# Building the MCS

vZ <- 300+4.9*(1:301)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is vZ?

vZ <- 300+4.9*(1:301)

mDist <- NULL
for (i in 1:16) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this for loop do? and the following one? Just two likes of comments could be really helpful

library(data.table)
mD <- setDT(mDist)[,list(mean=mean(Dist),var=var(Dist)),by=c("COP")]

fnTest <- function(vMean,vVar,iN,dA=1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments here would also be useful

return(list(test=dTest,q=dQuan,p=dPVa,result=dResult))
}

fnElim <- function(vMean,vVar,vIndex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

return(list(mean=vMean[-iM],var=vVar[-iM],indices=vIndex[-iM],elim=vIndex[iM]))
}

fnMCS <- function(vMean,vVar,vIndex,dA,verbose=1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AldoGl, I committed a commented version of the MCS code

@AldoGl
Copy link
Contributor

AldoGl commented Oct 24, 2022

Thank you @mmartinoli87 for the new code, the comments are indeed very useful!

@muxator
Copy link

muxator commented Oct 26, 2022

Hi, @mmartinoli87: the two notifications you saw about this PR were just a test to verify that black-it repo is correctly configured to collaborate on pull requests from external contributors.

Everything went smoothly: you and @AldoGl can safely work together, no action needed on your part.

@AldoGl
Copy link
Contributor

AldoGl commented Oct 26, 2022

Thank you @muxator!

@AldoGl AldoGl merged commit 87fbbf0 into bancaditalia:main Oct 26, 2022
@AldoGl AldoGl mentioned this pull request Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants