当前位置:网站首页>R language GLM generalized linear model: logistic regression, Poisson regression fitting mouse clinical trial data (dose and response) examples and self-test questions
R language GLM generalized linear model: logistic regression, Poisson regression fitting mouse clinical trial data (dose and response) examples and self-test questions
2022-06-28 19:34:00 【Extension Research Office】
Link to the original text :http://tecdat.cn/?p=27464
The source of the original text is : The official account of the tribal public
In fitting GLM( And check the residuals ) after , have access to z Test - test the significance of the estimated parameters , Compare the estimated value with its standard error .
GLM Examples of model fitting and analysis
Example 1. Mouse data GLM modeling ( Dose and response )
a) We input data and fit logistic regression models .
![]()


> summary(it1.lt) 
1-pchisq(17.6,24) ![]()
Model :
It can be compared with the complete model . And deviation value 17.639 dependent P value 0.82(> 0.10) This means that there is no significant evidence to reject the fitted model .
anova(fi.lgi) 

1-pchisq(35.8-17.69, 25-24) ![]()
The empty model does not contain predictive variables , stay 25 A degree of freedom (df) The deviation on is 35.89. When the covariate x When adding to an empty model , The variation of deviation is 35.890-17.639=18.25. And the degree of freedom is 25-24=1 Chi square distribution of , Its P The value is 1.93 × 10 -5 Very remarkable .
Therefore, the model cannot be deleted x To simplify the .x Of the coefficient of t Inspection is also important (P value 0.0065<0.01).
Intercept ? Can you delete it ?
> plotx, itte(fi1log,typ"
> pot(,y
chart 1: Logistic regression of mouse data and fitting values .
b) We fit a model with probabilistic links .

> summary() 
Supporting model :![]()
Again , Both of these parameters are important (P value <0.01)
> anova

> 1 - pchisq(35.89-17.49 25-24)![]()
> lines(x, fitte add to x The variation of time deviation is significant (P value =
).
The model cannot be deleted x To simplify the .

chart 2: Mouse data and fitting values ( Dotted line : Probabilistic Links ).
Use probit Linked models are slightly better than using logit Linked models , Because the deviation is smaller . In two models ,x The coefficients of are significant (P value <0.01), This means that the effect increases as the dose increases .
Example 2. Clinical trial data ( Dose and response ) Of GLM modeling .
a) We input data , Then fit the logistic regression model


> summary(it2.it) 

1-pchisq(13.63,6) ![]()
And deviation value 13.633 dependent P The value is 0.034<0.05.5% The level of rejection fits the model .
in the light of x Plotting residuals reveals a dependency pattern .
> plot(x, reid(it2.it))
chart 3: Only with x The residual diagram of the fitting model .
plt(fitdft2lit reid(fi2lot))So we're going to x2 Add to model .
> summary(ft2qlt) 

> 1-pchisq(5.1, 5)
![]()
Deviation from 13.633 Reduced to 5.107, Not significant (P value =0.403>0.05).
therefore , We cannot reject this model through evidence of bias .
plot(fitted(fit2logit), resid(.logit)) 
chart 4: with x2 The residual diagram of the fitting model .
The residuals now look random .
The fitting model is 
And all parameter estimates are significant (5%). Logarithmic probability
Depend on in a quadratic way x.
Example 3. AIDS data , Poisson
a) We input the data and use the default logarithmic link to fit the Poisson regression model .![]()
![]()
> smary(fit.lg) 
> 1-pchisq ![]()
deviation 29.654 Of P The value is 0.005<0.01 ⇒ Model rejected .
plot(fit3esuals) 
chart 5: Fitting model 3
Residual diagram of b) For year index x The residual graph of shows the dependency pattern . So we add
.
> summary(fi3.lg)
> 1-pchisq
[1] 0.127916.371 The deviation of (P The value is 0.1279>0.10) Not significant . Fitting model 
You can't refuse on the ground of deviation . But the residual plot shows only slightly more random patterns than before .

chart 6: Fitting model 3 And x2 Residual diagram of
The model can be improved by using non canonical links .
> summary(ft3st) 
> 1 - pchisq(16.9, 12)
[1] 0.153Residual error of fitting model y = (-0.27571 +0.49277x)2 + e Shows a more random pattern .12 df The deviation in 16.905 Slightly higher than the previous model 16.371(df=11), But still not significant (P value =0.1532>0.10).AIC smaller , by 73.833<75.298. therefore , Models with square root links are preferred .
Constant items can be deleted (“ intercept ”) Do you ?
What other linking functions are available ?

Self test questions :
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.
num.killed <- scan()
1 4 9 13 18 20 0 2 6 10 12 16
sex <- scan()
0 0 0 0 0 0 1 1 1 1 1 1
dose <- scan()
1 2 4 8 16 32 1 2 4 8 16 32Fit two models by doing the following.
ldose <- log(dose)/log(2) #convert to base-2 log dose
ldose #have a look
y <- cbind(num.killed, 20-num.killed) #add number survived
fit1 <- glm(y ~ ldose * sex, family=binomial(link=probit))
fit2 <- glm(y ~ sex + ldose, family=binomial(link=probit))You may also run the following lines and refer to the chi-square distribution table
anova(fit1,test="Chisq")
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.

The most popular insights
1.R Language diversity Logistic Logical regression The application case
2. Panel smooth transfer regression (PSTR) Analyze the case and realize
3.matlab Partial least squares regression in (PLSR) And principal component regression (PCR)
4.R Language Poisson Poisson Regression model analysis case
5.R Language mixing effect logistic regression Logistic Model analysis of lung cancer
6.r In language LASSO Return to ,Ridge Ridge return and Elastic Net Model implementation
边栏推荐
- Grafana biaxial graph with your hands
- Building tin with point cloud
- 春风动力携手华为打造智慧园区标杆,未来工厂创新迈上新台阶
- 让企业数字化砸锅和IT主管背锅的软件供应链安全风险指南
- 多测师肖sirapp中riginal error: Could not extract PIDs from ps output. PIDS: [], Procs: [“bad pid
- 展示用sql创建中间数据表的实际工作用例
- 数论 --- 欧拉函数、筛法求欧拉函数、欧拉定理、费马小定理详细证明
- Jenkins Pipeline 对Job参数的处理
- C language file operation
- NanoPC-T4(RK3399) game1 oled(I2C)显示时间天气温度
猜你喜欢

R语言GLM广义线性模型:逻辑回归、泊松回归拟合小鼠临床试验数据(剂量和反应)示例和自测题

电脑如何检查驱动程序是否正常

图神经网络入门 (GNN, GCN)

机器学习笔记 temperature+Softmax

Paper 3 vscode & texlive & sumatrapdf create a perfect tool for writing papers

Web3 that unleashes the value of the Internet

h5向日葵作业

math_ Proving common equivalent infinitesimal & Case & substitution

让企业数字化砸锅和IT主管背锅的软件供应链安全风险指南

使用点云构建不规则三角网TIN
随机推荐
math_证明常用等价无穷小&案例&代换
请问下flinkcdc用flinksql提交的话只能一个表提交一个任务吗?那有几千张表的时候还能这么
论文3 VScode&texlive&SumatraPDF打造完美书写论文工具
数字经济专家高泽龙:映客更名映宇宙,元宇宙会成为映客下一个增长引擎吗?
G biaxial graph SQL script
How to learn JS through w3school / how to use the JS reference manual of w3school
C language file operation
echart:横向柱状图的类目文字位置调整
Find out the users who log in for 7 consecutive days and 30 consecutive days
判断字符串是否为空
Question brushing analysis tool
Hands on Teaching of servlet use (1)
Windows 64位下载安装My SQL
try except 添加辅助新列
我是刚购买的adb mysql服务,我每做一个操作,比如建表,都会弹出这个问题,请问这是什么问题?
Are there any regular and safe foreign exchange dealers in China?
基于趋势和季节性的时间序列预测
100人成绩的平均
数据基础设施升级窗口下,AI 新引擎的技术方法论
Ffmpeg learning summary