我对regsubsets做错了什么?

时间:2022-09-20 19:15:02

My assignment is:

我的任务是:

Use the regsubsets function in the leaps package to perform an exhaustive search

使用leaps包中的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. There you can find the relevant.

查看summary.regsubsets的组件。在那里你可以找到相关的。

Values of different optimality criteria for the best model selected at each size.

在每种尺寸下选择的最佳模型的不同最优性标准的值。

I have a data set cigs on which I call

我有一个数据集cigs我打电话

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的信息吗?

1 个解决方案

#1


1  

What you see is the just a printed summary of your regsubsets object. If you type in ?regsubsets you see that summary.regsubsets returns more components than those printed. To access for example the r^2 just type:

你看到的只是你的regsubsets对象的打印摘要。如果输入?regsubsets,您会看到summary.regsubsets返回的组件数量多于打印的组件数量。要访问例如r ^ 2,只需键入:

summary_of_q <- summary(q)
summary_of_q$rsq

#1


1  

What you see is the just a printed summary of your regsubsets object. If you type in ?regsubsets you see that summary.regsubsets returns more components than those printed. To access for example the r^2 just type:

你看到的只是你的regsubsets对象的打印摘要。如果输入?regsubsets,您会看到summary.regsubsets返回的组件数量多于打印的组件数量。要访问例如r ^ 2,只需键入:

summary_of_q <- summary(q)
summary_of_q$rsq