R/fpScale.R

#####################################################################################
## Author: Daniel Sabanes Bove [daniel *.* sabanesbove *a*t* ifspm *.* uzh *.* ch]
## Project: Bayesian FPs
## 
## Time-stamp: <[fpScale.R] by DSB Fre 04/07/2008 11:27 (CEST) on daniel@puc.home>
##
## Description:
## Scale an FP term variable appropriately before model search using "fpScale".
##
## History:
## 04/07/2008   copy from thesis function collection.
#####################################################################################

`fpScale` <-
    function (x, scaling = TRUE)
{
    scale <- 1
    shift <- 0
    if (scaling) {
        if (min(x) <= 0) {
            z <- diff(sort(x))
            shift <- min(z[z > 0]) - min(x)
            shift <- ceiling(shift * 10)/10
        }
        range <- mean(x + shift)
        scale <- 10^(sign(log10(range)) * round(abs(log10(range))))
    }
    return(list(shift = shift, scale = scale))
}

Try the bfp package in your browser

Any scripts or data that you put into this service are public.

bfp documentation built on March 19, 2024, 3:07 a.m.