cont_selec: contracts explanatory variables, conducts model selection and...

Description Usage Arguments Details Value Author(s) Examples

View source: R/contselec-package8.R

Description

This function contracts explanatory variables and conduct best subset model selection, permutation test and stepwise model selection.

Usage

1
2
3
4
cont_selec(data00, pos_x = NULL, pos_y = NULL, target = 1,
  edge_cor = 0.52, edge_explain = 0.65, edge_param_number = 3,
  repeatn = 100, family = "glmm_poisson", check_spa_cor = F,
  use_pforeach = TRUE, perm = TRUE, nrep = 10000)

Arguments

data00

data.frame : an explained variable and explanatory variables. The explained variable is specified by "target".

pos_x

array of numeric : x-coordinates of spatial position for each sampled data in "data00".

pos_y

array of numeric : y-coordinates of spatial position for each sampled data in "data00".

target

integer or character : spefifies explained variables by its column id (integer) or column name (character).

edge_cor

real number : threshold for grouping; variables of correlation no less than this threshold are grouped together.

edge_explain

real number : threshold for the variance ratio to be explained, based on which the number of principal components "np" to represent the contracted group is determined.

edge_param_number

real number: this parameter constrains the number of explanatory variables in the subset model selection and stepwise model selection, so that [sample size]/[number of free parameter] >= "edge_param_number".

repeatn

integer : the number of model evaluations proccessed as a single job for each CPU core (This parameter is meaningful only when "use_pforeach" is TRUE).

family

character : error distribution. Possible choices are "glmm_poisson", "poisson","gaussian".

check_spa_cor

TRUE/FALSE : if TRUE, the best model with residuals significantly correlated with c(pos_x, pos_y) are removed repeatedly until the correlation becomes non-significant.

use_pforeach

TRUE/FALSE : if TRUE, pforeach is used instead of foreach in best subset selection and permutation tests (when "perm" is TRUE).

perm

TRUE/FALSE : if TRUE, permutation tests for explained variables are conducted.

nrep

integer : number of resampling in the permutation test.

Details

Spatial correlation of residuals of each fitted model can also be examimed.

Value

list(target=target, result=result, data0=data0, data1=data1, group=group, family=family, bestmodels=res_sb$bestmodels, bestmodel_stepwise=res_ss$bestmodel, bestmodel=res_sb$bestmodel, pos_x=pos_x, pos_y=pos_y)

Author(s)

Hiroshi C. Ito

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(Cars93, package = "MASS");
data=Cars93;
data=data[complete.cases(data),];
data=data[,sapply(data[1,],is.numeric)];

res=cont_selec(data,target="Horsepower",edge_cor=0.9,edge_explain=0.6,
               edge_param_number=3,family="gaussian",use_pforeach=FALSE);

plot_each_effect(res)
plot_combined_effect(res,sign_effect=-1)
plot_combined_effect(res,sign_effect=1)

print(res);
summary(res);

yorickuser/contselec documentation built on July 25, 2021, 8:14 a.m.