R中的变量选择

问题描述 投票:0回答:1

我正在设置一个模型,使用变量选择来查找重要变量。

 str(tweets2)
'data.frame':   6429 obs. of  13 variables:
 $ created_at            : Factor w/ 5918 levels "1/10/2019 17:40",..: 56 
53 52 51 50 49 48 47 46 45 ...
 $ screen_name           : Factor w/ 2 levels "HillaryClinton",..: 1 1 1 
 1 1 1 1 1 1 1 ...
 $ text                  : chr  "On top of human suffering and lasting 
damage to our national parks  the Trump shutdown cost the economy     
bil"| __truncated__ "Hurricane Maria decimated trees and ecosystems in 
Puerto Rico  Para La Naturaleza s nurseries have made a CGI c"| 
__truncated__ "Time to make the churros at Kreamy Ice Cream Shop in 
Puerto Rico   ClintonGlobal and  Foundation PR are working"| 
__truncated__ " chefjoseandres You are an inspiration  my friend " ...
$ source                : Factor w/ 6 levels "TweetDeck","Twitter for 
iPad",..: 6 6 6 6 6 6 6 6 3 3 ...
$ display_text_width    : int  192 235 238 34 222 214 140 259 140 140 ...
$ is_retweet            : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
$ favorite_count        : int  14324 10684 11423 1293 6641 12192 0 17618 
0 0 ...
$ retweet_count         : int  4168 2526 2089 113 951 2108 2094 4999 691 
915 ...
 $ retweet_favorite_count: int  NA NA NA NA NA NA 4214 NA 3474 3360 ...
 $ retweet_retweet_count : int  NA NA NA NA NA NA 2094 NA 691 915 ...
 $ retweet_screen_name   : Factor w/ 434 levels "ABCPolitics",..: NA NA 
NA NA NA NA 152 NA 227 44 ...
 $ retweet_name          : Factor w/ 433 levels "ABC News Politics",..: 
NA NA NA NA NA NA 159 NA 236 47 ...
$ retweet_statuses_count: int  NA NA NA NA NA NA 10784 NA 50482 10242 ...

vs = lm(screen_name ~.,data = tweets2) fitstart = lm(screen_name ~ 1,data = tweets2) step(fitstart,direction = "forward") fitstart = lm(screen_name ~ 1,data = tweets2)

步骤错误(fitstart,direction =“forward”):此模型的AIC为-infinity,因此'step'无法继续另外:警告消息:在Ops.factor(weighted.residuals(object),2)中:'^ “对因素没有意义

r variable-selection
1个回答
0
投票

您试图用2个级别预测二分因子。逐步选择是不合适的,您应该使用逻辑回归。即使在这种情况下,如果您使用bestglm例如,您需要将此变量转换为01

© www.soinside.com 2019 - 2024. All rights reserved.