0

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

 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)

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

4

1 回答 1

0

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

于 2019-04-09T03:58:23.073 回答