cr.setup(rms)
cr.setup()所属R语言包:rms
Continuation Ratio Ordinal Logistic Setup
延续比有序Logistic设置
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Creates several new variables which help set up a dataset with an ordinal response variable y for use in fitting a forward continuation ratio (CR) model. The CR model can be fitted with binary logistic regression if each input observation is replicated the proper number of times according to the y value, a new binary y is computed that has at most one y=1 per subject, and if a cohort variable is used to define the current qualifying condition for a cohort of subjects, e.g., y≥q 2. cr.setup creates the needed auxilliary variables. See predab.resample and validate.lrm for information about validating CR models (e.g., using the bootstrap to sample with replacement from the original subjects instead of the records used in the fit, validating the model separately for user-specified values of cohort).
创建一些新的变量,帮助建立一个有序响应变量的数据集y继续向前比(CR)模型拟合。的CR可以配备二元逻辑回归模型,如果每个输入观察复制y值所述的适当数量的次数,计算一个新的二进制y,至多有一个y=1 为准,如果cohort变量是用来界定一个世代的科目,例如,y≥q 2条件。 cr.setup创建所需的若干辅助变量。见predab.resample和validate.lrm信息CR模型进行验证(例如,使用引导到样品的更换从原来的主题,而不是适合用于记录,验证模型,分别为用户指定的值cohort“)。
用法----------Usage----------
cr.setup(y)
参数----------Arguments----------
参数:y
a character, numeric, category, or factor vector containing values of the response variable. For category or factor variables, the levels of the variable are assumed to be listed in an ordinal way. </table>
一个字符,数字,category或factor向量的响应变量的值。对于category或factor变量,levels的变量被假定为一个有序的方式列出。 </ TABLE>
值----------Value----------
a list with components y, cohort, subs, reps. y is a new binary variable that is to be used in the binary logistic fit. cohort is a factor vector specifying which cohort condition currently applies. subs is a vector of subscripts that can be used to replicate other variables the same way y was replicated. reps specifies how many times each original observation was replicated. y, cohort, subs are all the same length and are longer than the original y vector. reps is the same length as the original y vector. The subs vector is suitable for passing to validate.lrm or calibrate, which pass this vector under the name cluster on to predab.resample so that bootstrapping can be done by sampling with replacement from the original subjects rather than from the individual records created by cr.setup.
组件的列表与y, cohort, subs, reps。 y是一个新的二进制变量是要用于在二进制MF适合。 cohort是factor矢量指定的队列状况目前适用。 subs是一个向量的下标,可以用来复制其他变量相同的方式y被复制。 reps指定复制多少次,每次观察。 y, cohort, subs都是相同的长度和长于原始y矢量。 reps是原始y矢量的长度相同。 subs向量是适合传递给validate.lrm或calibrate,通过这个向量的名称clusterpredab.resample所以该引导程序可以通过采样从原来的议题,而不是从个人记录的cr.setup更换。
(作者)----------Author(s)----------
Frank Harrell<br>
Department of Biostatistics<br>
Vanderbilt University<br>
f.harrell@vanderbilt.edu
参考文献----------References----------
categories of response. Stat in Med 10:1703–1710, 1991.
参见----------See Also----------
lrm, glm, predab.resample
lrm,glm,predab.resample
实例----------Examples----------
y <- c(NA, 10, 21, 32, 32)
cr.setup(y)
set.seed(171)
y <- sample(0:2, 100, rep=TRUE)
sex <- sample(c("f","m"),100,rep=TRUE)
sex <- factor(sex)
table(sex, y)
options(digits=5)
tapply(y==0, sex, mean)
tapply(y==1, sex, mean)
tapply(y==2, sex, mean)
cohort <- y>=1
tapply(y[cohort]==1, sex[cohort], mean)
u <- cr.setup(y)
Y <- u$y
cohort <- u$cohort
sex <- sex[u$subs]
lrm(Y ~ cohort + sex)
f <- lrm(Y ~ cohort*sex) # saturated model - has to fit all data cells[饱和模型 - 适用于所有数据单元]
f
#Prob(y=0|female):[PROB(y = 0的女):]
# plogis(-.50078)[plogis( - 0.50078)]
#Prob(y=0|male):[PROB(Y = 0 |男):]
# plogis(-.50078+.11301)[plogis( - 0.50078 + 0.11301)]
#Prob(y=1|y>=1, female):[PROB(Y = 1 | Y = 1,女):]
plogis(-.50078+.31845)
#Prob(y=1|y>=1, male):[PROB(Y = 1 | Y = 1,男):]
plogis(-.50078+.31845+.11301-.07379)
combinations <- expand.grid(cohort=levels(cohort), sex=levels(sex))
combinations
p <- predict(f, combinations, type="fitted")
p
p0 <- p[c(1,3)]
p1 <- p[c(2,4)]
p1.unconditional <- (1 - p0) *p1
p1.unconditional
p2.unconditional <- 1 - p0 - p1.unconditional
p2.unconditional
## Not run: [#不运行:]
dd <- datadist(inputdata) # do this on non-replicated data[这样做对非复制数据]
options(datadist='dd')
pain.severity <- inputdata$pain.severity
u <- cr.setup(pain.severity)
# inputdata frame has age, sex with pain.severity[inputdata帧的年龄,性别,pain.severity]
attach(inputdata[u$subs,]) # replicate age, sex[复制的年龄,性别]
# If age, sex already available, could do age <- age[u$subs] etc., or[如年龄,性别已经上市了,可以做的年龄 - 年龄[U $潜艇等,或]
# age <- rep(age, u$reps), etc.[年龄< - 代表(年龄,U代表美元),等等。]
y <- u$y
cohort <- u$cohort
dd <- datadist(dd, cohort) # add to dd[添加到DD]
f <- lrm(y ~ cohort + age*sex) # ordinary cont. ratio model[普通续。比模型]
g <- lrm(y ~ cohort*sex + age, x=TRUE,y=TRUE) # allow unequal slopes for[允许不平等的斜坡]
# sex across cutoffs[性跨临界值]
cal <- calibrate(g, cluster=u$subs, subset=cohort=='all')
# subs makes bootstrap sample the correct units, subset causes[潜艇引导样品正确的单位,子集的原因]
# Predicted Prob(pain.severity=0) to be checked for calibration[预测PROB(pain.severity = 0),以检查用于校准]
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|