99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2019-01-13 閱讀量: 937
評價(jià)預(yù)測變量對結(jié)果概率的影響

對于我們大多數(shù)人來說,以概率的方式思考比使用優(yōu)勢比更直觀。使用predict()函數(shù),可

以觀察某個預(yù)測變量在各個水平時(shí)對結(jié)果概率的影響。首先創(chuàng)建一個包含你感興趣預(yù)測變量值的

虛擬數(shù)據(jù)集,然后對該數(shù)據(jù)集使用predict()函數(shù),以預(yù)測這些值的結(jié)果概率。

現(xiàn)在我們使用該方法評價(jià)婚姻評分對婚外情概率的影響。首先,創(chuàng)建一個虛擬數(shù)據(jù)集,設(shè)定

年齡、婚齡和宗教信仰為它們的均值,婚姻評分的范圍為1~5。

> testdata <- data.frame(rating=c(1, 2, 3, 4, 5), age=mean(Affairs$age),

yearsmarried=mean(Affairs$yearsmarried),

religiousness=mean(Affairs$religiousness))

> testdata

rating age yearsmarried religiousness

1 1 32.5 8.18 3.12

2 2 32.5 8.18 3.12

3 3 32.5 8.18 3.12

4 4 32.5 8.18 3.12

5 5 32.5 8.18 3.12

接下來,使用測試數(shù)據(jù)集預(yù)測相應(yīng)的概率:

> testdata$prob <- predict(fit.reduced, newdata=testdata, type="response")

testdata

rating age yearsmarried religiousness prob

1 1 32.5 8.18 3.12 0.530

2 2 32.5 8.18 3.12 0.416

3 3 32.5 8.18 3.12 0.310

4 4 32.5 8.18 3.12 0.220

5 5 32.5 8.18 3.12 0.151

從這些結(jié)果可以看到,當(dāng)婚姻評分從1(很不幸福)變?yōu)?(非常幸福)時(shí),婚外情概率從0.53

降低到了0.15(假定年齡、婚齡和宗教信仰不變)。下面我們再看看年齡的影響:

> testdata <- data.frame(rating=mean(Affairs$rating),

age=seq(17, 57, 10),

yearsmarried=mean(Affairs$yearsmarried),

religiousness=mean(Affairs$religiousness))

> testdata

rating age yearsmarried religiousness

1 3.93 17 8.18 3.12

2 3.93 27 8.18 3.12

3 3.93 37 8.18 3.12

4 3.93 47 8.18 3.12

5 3.93 57 8.18 3.12

> testdata$prob <- predict(fit.reduced, newdata=testdata, type="response")

> testdata

rating age yearsmarried religiousness prob

1 3.93 17 8.18 3.12 0.335

2 3.93 27 8.18 3.12 0.262

3 3.93 37 8.18 3.12 0.199

4 3.93 47 8.18 3.12 0.149

5 3.93 57 8.18 3.12 0.109

此處可以看到,當(dāng)其他變量不變,年齡從17增加到57時(shí),婚外情的概率將從0.34降低到0.11。

利用該方法,你可探究每一個預(yù)測變量對結(jié)果概率的影響。

0.0000
2
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子