我可以对具有因子变量的多元线性回归运行自动选择程序吗?

时间:2019-05-24 20:25:53

标签: r regression linear-regression glm categorical-data

我的数据集既包含数值变量,也包含分类变量。我可以使用stepAIC功能执行自动选择过程吗?

full.model <- lm(Percentage ~ Total_testscore + Campus + Programme + 
                   Gender + SE_track + Hours_Math_SE, data = mydata)    
step.model <- stepAIC(full.model, direction = "both",trace = FALSE)
    summary(step.model)


> str(mydata)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   242 obs. of  49 variables:
 $ Campus                           : Factor w/ 2 levels "KU Leuven Campus Sint-Lucas Brussel",..: 2 2 2 2 2 2 2 2 2 1 ...
 $ Gender                           : Factor w/ 2 levels "male","female": 1 1 1 2 2 1 2 1 2 2 ...
 $ Generation_student               : Factor w/ 2 levels "J","N": 1 1 1 1 1 1 1 1 1 1 ...
 $ New_in_programme                 : Factor w/ 2 levels "J","N": 1 1 1 1 1 1 1 1 1 1 ...
 $ Programme                        : Factor w/ 4 levels "ArchBrus","ArchGent",..: 2 2 2 2 2 2 2 2 2 3 ...
 $ SE_track                         : Factor w/ 3 levels "ASO","KSO","TSO": 1 2 3 1 1 1 2 3 1 3 ...
 $ Secondary_education              : Factor w/ 72 levels "2e lj 3e gr Architecturale vorming KSO",..: 28 16 25 30 28 70 16 25 28 62 ...
 $ Hours_Math_SE                    : num  3 6 4 6 4 6 6 4 3 3 ...
 $ Total_testscore                  : num  13 11 12 11 9 13 12 12 14 8 ...
 $ CSE                              : num  33 67 100 67 17 50 83 100 100 50 ...
 $ Percentage                       : num  30.8 50 59.2 56.7 40 ...

0 个答案:

没有答案