五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

R語言GLM廣義線性模型:邏輯回歸、泊松回歸擬合小鼠臨床試驗數(shù)據(jù)(劑量和反應(yīng))示例和

2022-07-17 11:21 作者:拓端tecdat  | 我要投稿

原文鏈接:http://tecdat.cn/?p=27464?

原文出處:拓端數(shù)據(jù)部落公眾號

?

在擬合 GLM(并檢查殘差)之后,可以使用 z 檢驗一一檢驗估計參數(shù)的顯著性,即將估計值與其標(biāo)準(zhǔn)誤差進(jìn)行比較。

GLM 模型擬合和分析示例

示例 1. 小鼠數(shù)據(jù)的 GLM 建模(劑量和反應(yīng))

a) 我們輸入數(shù)據(jù)并擬合邏輯回歸模型。

?

> summary(it1.lt)

?

1-pchisq(17.6,24)

?

模型:

可以與完整模型進(jìn)行比較。與偏差值 17.639 相關(guān)的 P 值 0.82(> 0.10)意味著沒有顯著證據(jù)拒絕擬合模型。

anova(fi.lgi)

?

?

1-pchisq(35.8-17.69, 25-24)

?

空模型不包含預(yù)測變量,在 25 個自由度 (df) 上的偏差為 35.89。當(dāng)協(xié)變量 x 添加到空模型時,偏差的變化是 35.890-17.639=18.25。與自由度為 25-24=1 的卡方分布相比,其 P 值為 1.93 × 10 -5 非常顯著。

因此模型不能通過刪除 x 來簡化。x 的系數(shù)的 t 檢驗也很重要(P 值 0.0065<0.01)。

截距呢?可以刪掉嗎?

  1. > plotx, itte(fi1log,typ"

  2. > pot(,y

圖 1:邏輯回歸的小鼠數(shù)據(jù)和擬合值。
b)我們擬合一個帶有概率鏈接的模型。

> summary()

?

配套模型:

同樣,這兩個參數(shù)都很重要(P 值<0.01)

> anova

?

> 1 - pchisq(35.89-17.49 25-24)

> lines(x, fitte

?添加 x 時偏差的變化是顯著的(P 值 =

)。
模型不能通過刪除 x 來簡化。

圖 2:小鼠數(shù)據(jù)和擬合值(虛線:概率鏈接)。
使用 probit 鏈接的模型略好于使用 logit 鏈接的模型,因為偏差更小。在兩個模型中,x 的系數(shù)都很顯著(P 值<0.01),這意味著效果隨著劑量的增加而增加。
?

示例 2. 臨床試驗數(shù)據(jù)(劑量和反應(yīng))的 GLM 建模。

a) 我們輸入數(shù)據(jù),然后擬合邏輯回歸模型
?

> summary(it2.it)

?


1-pchisq(13.63,6)

?

與偏差值 13.633 相關(guān)的 P 值為 0.034<0.05。5% 的水平拒絕擬合模型。
針對 x 繪制殘差揭示了一種依賴模式。


  1. > plot(x, reid(it2.it))


?

圖 3:僅帶有 x 的擬合模型的殘差圖。

plt(fitdft2lit reid(fi2lot))

?所以我們將 x2 添加到模型中。

> summary(ft2qlt)

?

> 1-pchisq(5.1, 5)

偏差從 13.633 減少到 5.107,不顯著(P 值=0.403>0.05)。
因此,我們不能通過偏差的證據(jù)來拒絕這個模型。


  1. plot(fitted(fit2logit), resid(.logit))

?

圖 4:帶有 x2 的擬合模型的殘差圖。

殘差現(xiàn)在看起來是隨機(jī)的。
擬合模型為

并且所有參數(shù)估計值都很顯著(5%)。對數(shù)幾率

以二次方式依賴于 x。
?

?示例 3. 艾滋病數(shù)據(jù),泊松

a) 我們輸入數(shù)據(jù)并使用默認(rèn)對數(shù)鏈接擬合泊松回歸模型。


  1. > smary(fit.lg)

?

> 1-pchisq

?

偏差 29.654 的 P 值為 0.005<0.01 ? 模型被拒絕。

plot(fit3esuals)

?

圖 5:擬合模型 3

的殘差圖 b) 針對年份指數(shù) x 的殘差圖顯示了依賴模式。所以我們添加

.
?

> summary(fi3.lg)

  1. > 1-pchisq

  2. [1] 0.1279

16.371 的偏差(P 值為 0.1279>0.10)并不顯著。擬合模型

不能以偏差為由拒絕。但殘差圖只顯示了比以前稍微隨機(jī)的模式。
?

圖 6:擬合模型 3 與 x2 的殘差圖

該模型可以通過使用非規(guī)范鏈接進(jìn)行改進(jìn)。

> summary(ft3st)

?

  1. > 1 - pchisq(16.9, 12)

  2. [1] 0.153

?擬合模型的殘差 y = (-0.27571 +0.49277x)2 + e 顯示出更加隨機(jī)的模式。12 df 上的偏差 16.905 略高于之前模型的 16.371(df=11),但仍然不顯著(P 值=0.1532>0.10)。AIC 較小,為 73.833<75.298。因此,具有平方根鏈接的模型是首選。

可以刪除常數(shù)項(“截距”)嗎?

還可以使用哪些其他鏈接功能?

自測題:

Twenty tobacco budworm moths of each sex were exposed to different doses of the insecticide trans-cypermethrin. The numbers of budworm moths killed during a 3-day exposure were as follows for each sex (male, female) and dose level in mg’s.


Type the data into R as follows. Press Enter at the end of each line including blank lines.

  1. num.killed <- scan()

  2. 1 4 9 13 18 20 0 2 6 10 12 16

  3. sex <- scan()

  4. 0 0 0 0 0 0 1 1 1 1 1 1

  5. dose <- scan()

  6. 1 2 4 8 16 32 1 2 4 8 16 32

Fit two models by doing the following.
?

  1. ldose <- log(dose)/log(2) #convert to base-2 log dose

  2. ldose #have a look

  3. y <- cbind(num.killed, 20-num.killed) #add number survived

  4. fit1 <- glm(y ~ ldose * sex, family=binomial(link=probit))

  5. fit2 <- glm(y ~ sex + ldose, family=binomial(link=probit))

You may also run the following lines and refer to the chi-square distribution table

  1. anova(fit1,test="Chisq")

  2. summary(fit2)

1. What model is fitted in fit1? Write it formally and define all the terms.?

2. How is the model in fit2 differ from that in fit1??

3. Does the model in fit1 fit the data adequately? Use deviance to answer this question.
4. Can the model in fit1 be simplified to the model in fit2? Use change in deviance to answer
this question.?
5. Can sex be removed from the model in fit2? Use change in deviance to answer this ques
tion.?
6. What are the maximum likelihood estimates of the parameters of the additive model? What
are their standard errors? Test the significance of each parameter using its estimate and
standard error.?
7. How does the probability of a kill change with log dose and sex of the budworm moth accord
ing to the additive model??

(a) Derive the survival function S(t) of a lifetime T ? E xp(?). Find ?logS(t) and comment on it.
(b) Calculate the Kaplan-Meier estimate for each group in the following.
Treatment Group:
6,6,6,6*,7,9*,10,10*,11*,13,16,17*,19*,20*,22,23,25*,32*,32*,34*,35
Control Group (no treatment):
1,1,2,2,3,4,5,5,8,8,8,8,11,11,12,15,17,22,23
Note that * indicates right censored data.
(c) Use the log rank test to compare the two groups of lifetimes.
?

最受歡迎的見解

1.R語言多元Logistic邏輯回歸 應(yīng)用案例

2.面板平滑轉(zhuǎn)移回歸(PSTR)分析案例實(shí)現(xiàn)

3.matlab中的偏最小二乘回歸(PLSR)和主成分回歸(PCR)

4.R語言泊松Poisson回歸模型分析案例

5.R語言混合效應(yīng)邏輯回歸Logistic模型分析肺癌

6.r語言中對LASSO回歸,Ridge嶺回歸和Elastic Net模型實(shí)現(xiàn)

7.R語言邏輯回歸、Naive Bayes貝葉斯、決策樹、隨機(jī)森林算法預(yù)測心臟病

8.python用線性回歸預(yù)測股票價格

9.R語言用邏輯回歸、決策樹和隨機(jī)森林對信貸數(shù)據(jù)集進(jìn)行分類預(yù)測


R語言GLM廣義線性模型:邏輯回歸、泊松回歸擬合小鼠臨床試驗數(shù)據(jù)(劑量和反應(yīng))示例和的評論 (共 條)

分享到微博請遵守國家法律
兴安县| 六安市| 来宾市| 青田县| 错那县| 巴楚县| 山西省| 罗源县| 乌恰县| 许昌县| 赫章县| 方正县| 永康市| 古浪县| 子长县| 孝感市| 炎陵县| 镇沅| 雅安市| 大田县| 惠安县| 郑州市| 万盛区| 大安市| 乌鲁木齐县| 高碑店市| 鄢陵县| 东山县| 响水县| 郎溪县| 定州市| 寻乌县| 昔阳县| 梁山县| 卫辉市| 静安区| 额尔古纳市| 襄樊市| 怀仁县| 白城市| 资讯 |