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

Alternative risk-scaling functions #21

Open
famuvie opened this issue Apr 10, 2019 · 3 comments
Open

Alternative risk-scaling functions #21

famuvie opened this issue Apr 10, 2019 · 3 comments
Labels
enhancement New feature or request priority To be addressed as quickly as possible question Further information is requested
Milestone

Comments

@famuvie
Copy link
Member

famuvie commented Apr 10, 2019

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 famuvie added enhancement New feature or request priority To be addressed as quickly as possible labels Apr 10, 2019
@famuvie
Copy link
Member Author

famuvie commented Apr 10, 2019

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?

@famuvie famuvie added the question Further information is requested label Apr 10, 2019
@vporphyre
Copy link

vporphyre commented Apr 10, 2019 via email

@famuvie
Copy link
Member Author

famuvie commented Apr 10, 2019

Noted. Thanks.

@famuvie famuvie added this to the CRAN Release milestone Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority To be addressed as quickly as possible question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants