简体   繁体   English

regsubsets我在做什么错?

[英]What am I doing wrong with regsubsets?

My assignment is: 我的任务是:

Use the regsubsets function in the leaps package to perform an exhaustive search 使用跨越包中的regsubsets函数执行详尽搜索

For best subsets regression models. 对于最佳子集回归模型。 Then compare the adjusted r^2 selected for each 然后比较为每个选择的调整后的r^2

Subset size. 子集大小。 Which model is best according to this criterion? 根据此标准,哪种模型最好? You will have to 你不得不

Look at components of summary.regsubsets. 查看summary.regsubsets的组件。 There you can find the relevant. 在那里您可以找到相关内容。

Values of different optimality criteria for the best model selected at each size. 在每种尺寸下选择的最佳模型的不同最优标准的值。

I have a data set cigs on which I call 我有一个要调用的数据集Cig

q=regsubsets(Sales~Age+HS+Income+Black+Female+Price, data=cigs, method="exhaustive")

All of those are correct variables 所有这些都是正确的变量

summary(q)

returns 回报

Subset selection object
Call: regsubsets.formula(Sales ~ Age + HS + Income + Black + Female + 
    Price, data = cigs, method = "exhaustive")
6 Variables  (and intercept)
       Forced in Forced out
Age        FALSE      FALSE
HS         FALSE      FALSE
Income     FALSE      FALSE
Black      FALSE      FALSE
Female     FALSE      FALSE
Price      FALSE      FALSE
1 subsets of each size up to 6
Selection Algorithm: exhaustive
         Age HS  Income Black Female Price
1  ( 1 ) " " " " "*"    " "   " "    " "  
2  ( 1 ) " " " " "*"    " "   " "    "*"  
3  ( 1 ) "*" " " "*"    " "   " "    "*"  
4  ( 1 ) "*" " " "*"    "*"   " "    "*"  
5  ( 1 ) "*" " " "*"    "*"   "*"    "*"  
6  ( 1 ) "*" "*" "*"    "*"   "*"    "*"

Any idea why this does not give me any information about r^2 ? 知道为什么它不给我有关r^2任何信息吗?

What you see is the just a printed summary of your regsubsets object. 您所看到的只是regsubsets对象的打印摘要。 If you type in ?regsubsets you see that summary.regsubsets returns more components than those printed. 如果键入?regsubsets则会看到summary.regsubsets返回的组件比打印的组件更多。 To access for example the r^2 just type: 要访问例如r^2只需键入:

summary_of_q <- summary(q)
summary_of_q$rsq

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM