Cirad-ASTRE / mapMCDA

Produce an epidemiological risk map by weighting multiple risk factors
https://umr-astre.pages.mia.inra.fr/mapMCDA/
1 stars 2 forks source link

Alternative risk-scaling functions #21

Open famuvie opened 5 years ago

famuvie commented 5 years ago

Currently, the only scaling functions are linear, with the option to be reversed.

Please add radio buttons to choose various links for standardization (see code at the end of this post, as a suggestion only)

Feature requested by @vporphyre in #19

# function link_fun (à integrer dans risk_layer à la place de lin_fun) BETA VERSION (V.Porphyre) #### 
# arg invert à associer au bouton 'Inverser'
# x1 and x2 Threshold values

lin_fun <- function(r, type="linear", invert=FALSE, x1=0, x2=0, source=scale_source, target=scale_target){
    if (type=="linear"){
        slope <- diff(target)/diff(source)
        ans <- target[1] + slope * (r - source[1])
    } 

    if (type=="crisp"){ tmp <- r
        if (invert==FALSE) {
            tmp[tmp<x1] <- target[1]
            tmp[tmp>=x1] <- target[2]
        }
        if (invert==TRUE){
            tmp[tmp<x1] <- target[2]
            tmp[tmp>=x1] <- target[1]
        }
    ans <- tmp
    }

    if (type=="double"){ tmp <- r
        if(invert==FALSE){  
            tmp[tmp<x1] <- target[1]
            tmp[tmp>=x1 & tmp<x2] <- target[2]
            tmp[tmp>=x2] <- target[1]}
        if(invert==TRUE){
            tmp[tmp<x1] <- target[2]
            tmp[tmp>=x1 & tmp<x2] <- target[1]
            tmp[tmp>=x2] <- target[2]
        }
    ans <- tmp
    }

    # if (type=="fuzzy"){} # to be developped
    # if (type=="sigmoid"){
    #   #ans <- target[2]*(1/(1 + ((1/target[1])-1)*exp(-x1*r)))
    # }  # WRONG

            return(ans)
}
famuvie commented 5 years ago

This is important since the linear scaling is very limited and very often totally inappropriate.

However, I have some doubts about how to implement these alternatives. Particularly in the interface.

The typical user of the interface already struggles with assimilating the linear scaling. How will they react towards a selection of sigmoidal, exponential, or step functions with two additional parameters x1 and x2 to deal with?

One option would be to include the functionality in the package (for more advanced users), but not in the graphical interface (to keep things simple). Or we can include a hidden section in the interface labelled Advanced that can be expanded for setting these options.

What do you think?

vporphyre commented 5 years ago

during Annelise Tran's MCDA training, she does a strong focus on the functions that link individual risk factors with the final risk. the beginner is thus confronted to this major issue early in the process. I am confident that the users will appreciate to be able to define it themselves.

for the interface, I programmed during the Rshiny training session in Reunion an option box (under the map with raw data) with radio buttons (linear (as default), sigmoidal, exp or step), and additional input form to enter x1 and/or x2 parameters (visible when step is activated). I added also a check box to choose an inverse function or not. I try to send you a screenshot example asap.

as a ccl, to include these functonnalities in the R code is a priority. the "for advanced users" options in the interface could be an elegant solution in a second step

v

Le mer. 10 avr. 2019 à 16:14, Facundo Muñoz notifications@github.com a écrit :

This is important since the linear scaling is very limited and very often totally inappropriate.

However, I have some doubts about how to implement these alternatives. Particularly in the interface.

The typical user of the interface already struggles with assimilating the linear scaling. How will they react towards a selection of sigmoidal, exponential, or step functions with two additional parameters x1 and x2 to deal with?

One option would be to include the functionality in the package (for more advanced users), but not in the graphical interface (to keep things simple). Or we can include a hidden section in the interface labelled Advanced that can be expanded for setting these options.

What do you think?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Cirad-ASTRE/mapMCDA/issues/21#issuecomment-481665516, or mute the thread https://github.com/notifications/unsubscribe-auth/Au3qerGTMktRldZWzyzoZ2cQ_LxOS6Mhks5vfdW5gaJpZM4cmtMl .

-- Vincent PORPHYRE CIRAD Coordinateur du réseau QualiREG en Océan Indien http://www.qualireg.org


CIRAD - UMR 112 Systèmes d'élevage en milieux méditerranéens et tropicaux Tel. +262.2.62.49.92.55 (office) Fax. +262.2.62.49.92.95 Secr. +262.2.62.49.92.02 Mail. vincent.porphyre@cirad.fr Website. http://pigtrop.cirad.fr

CIRAD - Station Ligne-Paradis 7 chemin de l'IRAT, F-97410 Saint Pierre Réunion - FRANCE (DOM) Website UPR. http://www.cirad.fr/ur/systemes_elevage Perso page. http://agents.cirad.fr/index.php/Vincent+PORPHYRE

Trouver un projet ou un futur partenaire scientifique en Océan Indien sur www.agro-oi.org

Pensez à l'environnement : n'imprimez pas ce courriel ! Adopt the eco-attitude, Think Environment before printing

http://www.qualireg.org

famuvie commented 5 years ago

Noted. Thanks.