FCBMA: Factor collapsing (FC) with Bayesian model averaging (BMA)...

Description Usage Arguments Value Note Examples

View source: R/FCBMA.R

Description

This function use FC-BMA method to refit linear or generalized linear models, method chosen from complete exhaustive search, Simulated Annealing (SA), Generic Algorithm (GA).

Usage

1
2
3
4
5
6
FCBMA(model, varia.list, method = "complete",
  transition.method = "ChangeOne", IncludeOrigin = FALSE,
  AddOnSearch = FALSE, group = NULL, apart = NULL,
  control.SA = list(init.Temp = 10000, stop.Temp = 1e-05, coolingRate =
  0.7, Mtrial = 20), control.GA = list(popnSize = 20, CrossOverRate =
  0.8, MutationRate = 0.1, elitism = 0.1, MaxGen = 200), verbose = TRUE)

Arguments

model

The model used for factor collapsing.

varia.list

Vector of variables to be collapsed.

method

Search method to use, choose from "complete", "SA", "GA".

transition.method

Transition method to change one graycode to its neighbouring graycode, choose from "ChangeOne", "GroupSplit". The default is "ChangeOne".

IncludeOrigin

Logical; When choose neighbouring graycode, should the input graycode be included or not.

AddOnSearch

Logical; used when method = "SA" or "GA". If TRUE, after stochastic search a short greedy search will be implemented to ensure the final result is indeed global optimum. The default is FALSE.

group

A (list of) vector indicating which elements must be grouped together, the default is NULL.

apart

A (list of) vector indicating which elements must not be grouped together, the default is NULL.

control.SA

A list of control parameters for SA.

init.Temp

Initial temperature, default value is 10000.

stop.Temp

Stoping temperature, default value is 1e-5.

coolingRate

Cooling rate, default value is 0.7.

Mtrial

Number of interations at each temperature level, default is 20.

control.GA

A list of control parameters for GA.

popnSize

Population size, detaulf is 20.

CrossOverRate

Crossover rate, default is 0.8.

MutationRate

Mutation rate, default is 0.1.

elitism

Elitism rate, default is 0.1.

MaxGen

Maximum generation allowed, default is 200.

verbose

Logical argument controlling whether progress will be printed while the search runs. Default is TRUE.

Value

A list with the elements

best.bic

The best value of BIC.

best.state

The best partitions for all stated variables.

all.bic

All the searched BIC values.

all.states

All the searched (combinations of) partitions, in graycode.

all.partitions

All the searched (combinations of) partitions

all.weights

All the BMA weights of searched partitions.

Table

A summary table of best few BICs, partitions, BMA weights.

Accept.BIC

Accepted BIC values along SA search; only when method="SA".

Accept.States

Accepted (combinations of) partitions along SA search; only when method="SA".

Best.BIC.trace

Trace of best BIC values along GA search; only when method="GA".

AddOn.BestBIC

The best BIC value found through the add-on greedy search, if AddOnSearch=TRUE.

AddOn.BestState

The best (combination of) partition found through the add-on greedy search, if AddOnSearch=TRUE.

AddOn.BIC.trace

The best BIC values found in each iteration through the add-on greedy search, if AddOnSearch=TRUE.

AddOn.State.trace

The best (combination of) partitions found in each iteration through the add-on greedy search, if AddOnSearch=TRUE.

Note

This version of stochastic search changes on the simulated annealing part. It changed the stochastic search method at each iteration, only one variable is picked and change to one of its neighbours the probability of being picked is based on the number of levels You also have the option of which method to select a neighbour of a graycode

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
data("sweden")
m1 <- glm(Claims ~ Kilometres+Zone+Bonus+Make, offset = log(Insured),
          data = sweden, family = "poisson")
summary(m1)

# complete search
m2 <- FCBMA(model = m1,
            varia.list = c("Kilometres"),
            method = "complete",
            verbose = FALSE)


# SA search
m3 <- FCBMA(model = m1,
            varia.list = c("Kilometres","Make"),
            method = "SA",
            transition.method = "ChangeOne",
            AddOnSearch = TRUE,
            control.SA = list(init.Temp = 1000,
                              coolingRate = 0.6,
                              stop.Temp = 1e-5,
                              Mtrial = 20),
            verbose = TRUE)
m3$best.state
m3$best.bic

# GA search
m4 <- FCBMA(model=m1,
            varia.list = c("Kilometres", "Make"),
            method = "GA",
            transition.method = "ChangeOne",
            AddOnSearch= TRUE,
            control.GA = list(popnSize=20,
                              CrossOverRate=0.8,
                              MutationRate=0.1,
                              elitism=0.1,
                              MaxGen=100),
            verbose = TRUE)
m4$best.state
m4$best.bic

senhu/FCBMA documentation built on Aug. 6, 2019, 4:56 p.m.