对于循环:logit模型中一个变量的不同值的预测
我估计足球门票销售的需求功能(Logit:1 =售票/盖帽,0 =票务/块未出售)。
model_Gegner <- Ausverkauft_2 ~ Preis + Block + Gegner + Spieltagsklasse + Leistung_Heim +
Leistung_Auswärts + Temperatur + Unsicherheit + Wochentag+ Saison
Logit_Gegner <- glm(model_Gegner, data = train, family = "binomial")
在下一步中,我想看看俱乐部可能还会收取的最高价格来出售票。 为了找到这个问题,我设计了一个用于循环的:
Preis <- c(1:100)
Preis
#test object:
SpielRevenue <- subset(test, Datum == "2018-12-02" & Kategorie == "4" & Block == "15E")
#### for in loop
for(p in Preis ){
SpielRevenue$Preis <- p
print(predict(Logit_Gegner,SpielRevenue, type="response"))
}
而不是以不同的价格出售票的概率,而是得到以下内容:
440
0.6747067
440
0.6688503
440
0.6629412
440
0.6569808
440
0.6509704
440
0.6449117
440
0.6388061
440
0.6326553
440
0.6264611
440
0.620225
440
0.6139491
440
0.607635
440
0.6012848
440
0.5949002
440
0.5884835
由于我只将价格限制在100下,所以我不明白440的来源。有100倍的440,因此您可以为每个440分配不同的价格。但这将是一项巨大的计数工作。
我想获得以下结果:
1
0.6747067
2
0.6688503
3
0.6629412
4
0.6569808
5
0.6509704
6
0.6449117
7
0.6388061
8
0.6326553
9
0.6264611
10
0.620225
...
如果可能的话,我还想将结果保存在数据范围内。
贡献朝着: 但是,我还没有找到任何帮助我的贡献。如果有一个,我很抱歉重复。
谢谢你!
I have estimated a demand function for football ticket sales (logit: 1 = ticket/block was sold, 0= ticket/block was not sold).
model_Gegner <- Ausverkauft_2 ~ Preis + Block + Gegner + Spieltagsklasse + Leistung_Heim +
Leistung_Auswärts + Temperatur + Unsicherheit + Wochentag+ Saison
Logit_Gegner <- glm(model_Gegner, data = train, family = "binomial")
As a next step, I would like to see what would be the highest possible price the club could charge to still sell the ticket.
To find this out I have designed a for in loop:
Preis <- c(1:100)
Preis
#test object:
SpielRevenue <- subset(test, Datum == "2018-12-02" & Kategorie == "4" & Block == "15E")
#### for in loop
for(p in Preis ){
SpielRevenue$Preis <- p
print(predict(Logit_Gegner,SpielRevenue, type="response"))
}
Instead of the probabilities of selling a ticket at the different prices, I get the following:
440
0.6747067
440
0.6688503
440
0.6629412
440
0.6569808
440
0.6509704
440
0.6449117
440
0.6388061
440
0.6326553
440
0.6264611
440
0.620225
440
0.6139491
440
0.607635
440
0.6012848
440
0.5949002
440
0.5884835
Since I have only limited the prices to 100, I don't understand where the 440 comes from. There are 100x the 440 so you could assign the different prices to each 440. But this would be a big counting job.
I would like to have following result:
1
0.6747067
2
0.6688503
3
0.6629412
4
0.6569808
5
0.6509704
6
0.6449117
7
0.6388061
8
0.6326553
9
0.6264611
10
0.620225
...
I would also like to save the result in a dataframe if its possible.
The contribution goes in the direction of:
However, I haven't found any contribution that helps me with mine. If there is one, I am sorry for the duplication.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了我的问题的答案。如果其他人有同样的问题,我将在此处发布它,而不是删除我的问题:
440是行号。
为了逃脱这个数字,我在循环前创建了一个矩阵,并将索引作为第二步的价格。
看起来真的不好,但是有效:)
Have found an answer to my question. If others have the same problem, I'll post it here instead of deleting my question:
440 was the row number.
To escape the number, I created a matrix before the loop and took the index as the price in the second step.
Doesn't look really nice, but works :)