make.dummy.fnc

Objetive

Make J-1 dummy variables with treatment type contrasts from a factor included by the user.

Although R does not require the creation of dummy variables to estimate models that contain categorical variables (as in the case of other statistical packages available), sometimes we need to create them and dispose of them as realvariables in the database.

crea.dummy.fnc

Function make.dummy.fnc requires the mandatory argument which.factor in which the user will indicate the name (in quotes or apostrophes) factor that you want to extract the J-1 dummy variables (takes values 0 and 1). By default the first level of the factor is used as a reference level. If you wish to another, you must include the reference argument with the level number you want as a reference for the J-1 dummy variables.

dat=OBrienKaiser

dat=make.dummy.fnc(dat, which.factor='treatment')

Is identical to:

dat=make.dummy.fnc(dat, which.factor='treatment', reference=1)

#------------------------------------------------------------------

# MAKE DUMMY VARIABLES #------------------------------------------------------------------

*** 2 dummy variables has been created from treatment factor

*** with the following names: treatment_A treatment_B

*** Level: control from: treatment factor is reference.

head(dat[,c(1,18:19)]) # Just colums number 1,18 y 19

treatment treatment_A treatment_B

1 control 0 0

2 control 0 0

3 control 0 0

4 control 0 0

5 control 0 0

6 A 1 0