newdata指定需要预测的数据集,type指定预测的结果,logistic回归对应的type=c("lp", "fitted","fitted.ind", "mean", "x", "data.frame", "terms", "cterms", "ccterms", "adjto","adjto.data.frame", "model.frame")#val.prob函数用于验证二分类结局的预测概率,提供了Dxy、C、Brier、R2、D、U、...
在R中,可以使用model.matrix()函数或因子变量结合lm()或glm()函数来自动创建虚拟变量。 1. 虚拟变量的创建 将分类变量转换为虚拟变量,可以使用R语言中的model.matrix()函数。举个例子,如果我们有一个名为“Brand”的分类变量,该变量有三个类别“A”、“B”和“C”,我们会创建两个虚拟变量,比如“BrandB”和...
R软件中的elrm(exact-like inference in logistic regression models)包可以实现这一过程。 library(elrm) data(drugDat);包中自带的数据“drugDat” drug.elrm = elrm(formula=recovered/n~sex+treatment, interest=~sex+treatment, r=4,iter=40000, burnIn=1000, dataset=drugDat); 在这段代码中: formula ...
model1=lrm(low~age+lwt+race1+race2+smoke+ptl+ht+ui+ftv,data = data1,x=T,y=T) model1 Logistic Regression Model lrm(formula = low ~ age + lwt + race1 + race2 + smoke + ptl + ht + ui + ftv, data = data1, x = T, y = T) Model Likelihood Discrimination Rank Discrim. Ra...
rms包是回归模型策略(Regression Modeling Strategies)的函数集合,可以绘制列线图、校准曲线的绘制等。该包中各种模型有专用的构建函数,二分类logistic回归用lrm函数。不过rms包中未提供Hosmer-Lemeshow检验,多少有点遗憾。 #绘制列线图 library(rms);library(Hmis) ...
∂σ(z)∂z=σ(z)σ(−z)∂σ(z)∂z=σ(z)σ(−z) Logistic Function σ(x;θ)=11+e−θxσ(x;θ)=11+e−θx 首先我们考虑22分类问题, 所以f(x)f(x)的值域也是[−1,1][−1,1]。 P(y=1|x,θ)=σ(x)P(y=1|x,θ)=σ(x) ...
Logistic Regression Model lrm(formula = n23 ~ age + time + n4 + n5 + n7 + n8 + n9 + n10new + n13 + n14 + n15 + n16 + n18 + n19f1 + n20 + n21 + n22 + n32 + n39new + n40new, data = mydata, x = T, y = T) ...
>summary(model01)Call:glm(formula=Dative~ReciAnim+ReciAcc+ThemeAcc+ReciPron+ThemePron,family=binomial,data=data)Deviance Residuals:Min1Q Median3Q Max-2.1900-0.2509-0.1634-0.16342.5217Coefficients:Estimate Std. Error z value(Intercept)-1.05120.7692-1.367ReciAniminani1.17260.44112.659ReciAccunacc2.18130....
fit=lrm(n23~age+time+n4+n5+n7+n8+n9+n10new+n13+n14+n15+n16+n18+n19f1+n20+n21+n22+n32+n39new+n40new,data = mydata,x=T,y=T)Logistic Regression Modellrm(formula = n23 ~ age + time + n4 + n5 + n7 + n8 + n9 + n10new +n13 + n14 + n15 + n16 + n18 + n19f1 +...
Logistic regression predicting low crude OR(95%CI) adj. OR(95%CI) P(Wald's test) P(LR-test) lwt (cont. var.) 0.99 (0.97,1) 0.98 (0.97,1) 0.022 0.015 race: ref.=white 0.022 black 2.33 (0.94,5.77) 3.67 (1.3,10.35) 0.014 ...