compute_weights {CARRoT} R Documentation

## Weights of predictors

### Description

Function which computes the weight of each predictor according to the rules of thumb and outputs it into corresponding array

### Usage

compute_weights(vari_col, vari)


### Arguments

 vari_col number of predictors vari set of predictors

### Details

Continuous or categorical numerical variable with more then 5 categories has weight 1, otherwise it has weight n-1 where n is the number of categories

### Value

Returns an array of weights of the size vari_col

### References

Peduzzi P, Concato J, Kemper E, Holford TR, Feinstein AR (1996). “A simulation study of the number of events per variable in logistic regression analysis.” Journal of Clinical Epidemiology, 49(12), 1373-1379. ISSN 0895-4356, doi:10.1016/S0895-4356(96)00236-3, http://dx.doi.org/10.1016/S0895-4356(96)00236-3.

Rhemtulla M, Brosseau-Liard PÉ, Savalei V (2012). “When can categorical variables be treated as continuous?: A comparison of robust continuous and categorical SEM estimation methods under suboptimal conditions.” Psychological Methods, 17(3), 354-373. doi:10.1037/a0029315.

### Examples

#creating data-set with for variables

a<-matrix(NA,nrow=100,ncol=4)

#binary variable

a[,1]=rbinom(100,1,0.3)

#continuous variable

a[,2]=runif(100,0,1)

#categorical numeric with les than 5 categories

a[,3]=t(rmultinom(100,1,c(0.2,0.3,0.5)))%*%c(1,2,3)

#categorical numeric with 5 categories

a[,4]=t(rmultinom(100,1,c(0.2,0.3,0.3,0.1,0.1)))%*%c(1,2,3,4,5)

#running the function

compute_weights(4,a)


[Package CARRoT version 3.0.1 Index]