找回密码
 注册
查看: 4110|回复: 0

R语言 rms包 nomogram()函数中文帮助文档(中英文对照)

  [复制链接]
发表于 2012-9-27 19:12:19 | 显示全部楼层 |阅读模式
nomogram(rms)
nomogram()所属R语言包:rms

                                        Draw a Nomogram Representing a Regression Fit
                                         代表一个回归拟合绘制的诺模图

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Draws a partial nomogram that can be used to manually obtain predicted values from a regression model that was fitted with rms. The nomogram does not have lines representing sums, but it has a reference line for reading scoring points (default range 0–100).  Once the reader manually totals the points, the predicted values can be read at the bottom. Non-monotonic transformations of continuous variables are handled (scales wrap around), as are transformations which have flat sections (tick marks are labeled with ranges).  If interactions are in the model, one variable is picked as the “axis variable”, and separate axes are constructed for each level of the interacting factors (preference is given automatically to using any discrete factors to construct separate axes) and levels of factors which are indirectly related to interacting factors (see DETAILS).  Thus the nomogram is designed so that only one axis is actually read for each variable, since the variable combinations are disjoint.  For categorical interacting factors, the default is to construct axes for all levels. The user may specify coordinates of each predictor to label on its axis, or use default values. If a factor interacts with other factors, settings for one or more of the interacting factors may be specified separately (this is mandatory for continuous variables).  Optional confidence intervals will be drawn for individual scores as well as for the linear predictor. If more than one confidence level is chosen, multiple levels may be displayed using different colors or gray scales.  Functions of the linear predictors may be added to the nomogram.
绘制部分的诺模图,可用于手动得到的预测值从回归模型,配有rms。诺模图不具有的线代表的款项,但它有一个用于读出得分(默认范围0-100)的基准线。一旦读者手动总额之分,可以读取底部的预测值。非单调变换的连续变量的处理(尺度环绕),有平面部分的转换(标有刻度线范围)。如果相互作用的模型中,一个变量选为“轴变量”,构建独立的轴为每个级别的互动因素(自动优先考虑使用任何离散的因素,建立独立的轴)和层次的因素这是间接的关系相互作用的因素(见详情)。因此的诺模图的设计,使得只有一个轴实际上是为每个变量读取,自变量的组合是不相交的。对于分类相互作用的因素,默认是各级建设的轴。用户可以指定每个预测变量的标记在它的轴,或使用默认值的坐标。如果一个因素与其他因素相互作用,可以分别指定相互作用的因素中的一个或多个设置(这是强制性的,对于连续变量)。可选的置信区间将被绘制为个人得分,以及为线性预测。如果一个以上的被选择的置信水平,可以使用不同的颜色或灰度级显示,多层次。线性预测的功能可能被添加到的诺模图。

print.nomogram prints axis information stored in an object returned by nomogram.  This is useful in producing tables of point assignments by levels of predictors.  It also prints how many linear predictor units there are per point and the number of points per unit change in the linear predictor.
print.nomogram的nomogram返回的对象存储在输出轴信息。这是非常有用的生产点分配表的预测水平。它还打印点和每单位变化的线性预测中的点的数目是按每有多少线性预测单元。

legend.nomabbrev draws legends describing abbreviations used for labeling tick marks for levels of categorical predictors.
legend.nomabbrev吸引了传说中描述的缩写,用于标记刻度线的分类预测的水平。


用法----------Usage----------


nomogram(fit, ..., adj.to, lp=TRUE, lp.at=NULL,
         fun=NULL, fun.at=NULL, fun.lp.at=NULL, funlabel="redicted Value",
         interact=NULL, intercept=1,  conf.int=FALSE,
         conf.lp=c("representative", "all", "none"),
         est.all=TRUE, abbrev=FALSE, minlength=4, maxscale=100, nint=10,
         vnames=c("labels","names"),
         varname.label=TRUE, varname.label.sep="=",
         omit=NULL, verbose=FALSE)

## S3 method for class 'nomogram'
print(x, dec=0, ...)

## S3 method for class 'nomogram'
plot(x, lplabel="Linear Predictor", fun.side,
col.conf=c(1,if(under.unix).3 else 12),
conf.space=c(.08,.2), label.every=1, force.label=FALSE,
xfrac=.35, cex.axis=.85, cex.var=1, col.grid=NULL,
varname.label=TRUE, varname.label.sep="=", ia.space=.7,
tck=NA, tcl=-0.25, lmgp=.4, naxes,
points.label='Points', total.points.label='Total Points',
total.sep.page=FALSE, total.fun, cap.labels=FALSE, ...)

legend.nomabbrev(object, which, x, y, ncol=3, ...)



参数----------Arguments----------

参数:fit
a regression model fit that was created with rms, and (usually) with options(datadist = "object.name") in effect.   
一个回归模型拟合创建rms,和(通常)options(datadist = "object.name")的影响。


参数:...
settings of variables to use in constructing axes.  If datadist was in effect, the default is to use pretty(total range, nint) for continuous variables, and the class levels for discrete ones.  For legend.nomabbrev, ... specifies optional parameters to pass  to legend.  Common ones are bty = "n" to suppress drawing the box.  You may want to specify a non-proportionally spaced font (e.g., courier) number if abbreviations are more than one letter long. This will make the abbreviation definitions line up (e.g., specify font = 2, the default for courier).  Ignored for print and plot.  
的变量的设置使用在构建轴。如果datadist实际上,默认的是使用pretty(total range, nint)为连续变量和离散的级别的。对于legend.nomabbrev,...指定可选的参数传递给legend。常见的有bty = "n"抑制绘制框。您可能要指定一个非比例间距字体(如快递)号码,如果有一个以上的字母缩写长。这将使的缩写定义行(例如,指定font = 2,默认快递)。为print和plot忽略。


参数:adj.to
If you didn't define datadist for all predictors, you will have to define adjustment settings for the undefined ones, e.g. adj.to= list(age = 50, sex = "female").  
如果你没有定义datadist所有的预测中,你将有定义调整设置为未定义的,例如: adj.to= list(age = 50, sex = "female")。


参数:lp
Set to FALSE to suppress creation of an axis for scoring X beta.  
抑制创作的轴得分FALSE设置为X beta。


参数:lp.at
If lp=TRUE, lp.at may specify a vector of settings of X beta. Default is to use pretty(range of linear predictors, nint).  
如果lp=TRUE,lp.at可以指定一个向量的设置X beta。默认是使用pretty(range of linear predictors, nint)。


参数:fun
an optional function to transform the linear predictors, and to plot on another axis.  If more than one transformation is plotted, put them in a list, e.g. list(function(x) x/2, function(x) 2*x). Any function values equal to NA will be ignored.   
一个可选的功能转换的线性预测,并绘制在另一个轴。如果有一个以上的转换曲线,把它们放在一个列表,例如list(function(x) x/2, function(x) 2*x)。任何函数值等于NA将被忽略。


参数:fun.at
function values to label on axis.  Default fun evaluated at lp.at.   If more than one fun was specified, using a vector for fun.at will cause all functions to be evaluated at the same argument values.  To use different values, specify a list of vectors for fun.at, with elements corresponding to the different functions (lists of vectors also applies to fun.lp.at and fun.side).  
函数值,标签上轴。默认fun评价lp.at的。如果有一个以上fun被指定,使用矢量fun.at会导致在相同的参数值进行评估的所有功能。要使用不同的值,指定的向量列表fun.at,与元素对应不同的功能(向量名单,也适用于fun.lp.at和fun.side)。


参数:fun.lp.at
If you want to evaluate one of the functions at a different set of linear predictor values than may have been used in constructing the linear predictor axis, specify a vector or list of vectors  of linear predictor values at which to evaluate the function.  This is especially useful for discrete functions.  The presence of this attribute also does away with the need for nomogram to compute numerical approximations of  the inverse of the function.  It also allows the user-supplied function to return factor objects, which is useful when e.g. a single tick mark position actually represents a range. If the fun.lp.at parameter is present, the fun.at vector for that function is ignored.  
如果您要评估的功能之一(在一组不同的线性预测值比)可能已被用于在构造线性预测轴,指定的线性预测值,在评价函数的矢量的矢量或列表。这是特别有用的离散函数。此属性的存在,也摒弃了需要nomogram计算的数值逼近的逆的功能。它也允许用户提供的功能返回factor的对象,这是很有用时,例如:一个单一的刻度线的位置,实际上是代表一个范围。如果fun.lp.at参数存在,fun.at向量,该功能将被忽略。


参数:funlabel
label for fun axis.  If more than one function was given but funlabel is of length one, it will be duplicated as needed.  If fun is a list of functions for which you specified names (see the final example below), these names will be used as labels.  
标签fun轴。如果一个以上的功能,但一个长度funlabel是,它会根据需要被复制。如果fun是一个列表的功能,为您指定的名称(请参阅下面的最后一个例子),这些名字将被用来作为标签。


参数:interact
When a continuous variable interacts with a discrete one, axes are constructed so that the continuous variable moves within the axis, and separate axes represent levels of interacting factors.  For interactions between two continuous variables, all but the axis variable must have discrete levels defined in interact.   For discrete interacting factors, you may specify levels to use in constructing the multiple axes.  For continuous interacting factors, you must do this.  Examples: interact = list(age = seq(10,70,by=10),       treat = c("A","B","D")).  
当连续变量与离散交互,轴被构造成使得连续的变量内的轴移动,和单独的轴代表相互作用的因子的水平。对于两个连续变量之间的相互作用,但轴变量都必须有定义的离散电平interact。对于离散的相互作用的因素,你可以指定使用在构建多个轴的水平。对于连续相互作用的因素,你必须这样做。例子:interact = list(age = seq(10,70,by=10),       treat = c("A","B","D"))。


参数:intercept
for models such as the ordinal logistic model with multiple intercepts, specifies which one to use in evaluating the linear predictor.  



参数:conf.int
confidence levels to display for each scoring.  Default is FALSE to display no confidence limits.  Setting conf.int to TRUE is the same as setting it to c(0.7, 0.9), with the line segment between the 0.7 and 0.9 levels shaded using gray scale.   
置信水平显示为每个得分。默认是FALSE显示没有自信的限制。设置conf.int到TRUE将其设置为c(0.7, 0.9),灰度阴影使用的0.7和0.9的水平之间的线段是一样的。


参数:conf.lp
default is "representative" to group all linear predictors evaluated into deciles, and to show, for the linear predictor confidence intervals, only the mean linear predictor within the deciles along with the median standard error within the deciles.  Set conf.lp = "none" to suppress confidence limits for the linear predictors, and to "all" to show all confidence limits.  
默认情况下是"representative"分组到十分位的线性预测评估,并显示,线性预测的置信区间,只有在十分位数的十分位数的中位数标准误差在平均线预测。设置conf.lp = "none"抑制的置信区间的线性预测,并"all"来显示所有的置信区间。


参数:est.all
To plot axes for only the subset of variables named in ..., set est.all = FALSE.  Note: This option only works when zero has a special meaning for the variables that are omitted from the graph.  
要绘制轴的子集的变量命名...,将est.all = FALSE。注:此选项仅适用时零从图中省略的变量,具有特殊的意义。


参数:abbrev
Set to TRUE to use the abbreviate function to abbreviate levels of categorical factors, both for labeling tick marks and for axis titles. If you only want to abbreviate certain predictor variables, set abbrev to a vector of character strings containing their names.  
设置为TRUE使用abbreviate功能的缩写水平的绝对的因素,标注刻度线和坐标轴标题。如果你只需要一定的预测变量,设置abbrev他们的名字的字符串包含一个矢量缩写。


参数:minlength
applies if abbrev = TRUE.  Is the minimum abbreviation length passed to the abbreviate function.  If you set minlength = 1, the letters of the alphabet are used to label tick marks for categorical predictors, and all letters are drawn no matter how close together they are.  For labeling axes (interaction settings), minlength = 1 causes minlength = 4 to be used.  
适用于abbrev = TRUE。是最低的缩写的长度,传递给abbreviate功能,。如果你设置minlength = 1“的英文字母是用来标记刻度线分类预测,并绘制所有字母不管他们是如何紧密。用于标识轴(交互设置),minlength = 1导致minlength = 4使用。


参数:maxscale
default maximum point score is 100  
默认的最高点满分为100分


参数:nint
number of intervals to label for axes representing continuous variables. See pretty.  
数轴代表连续变量的时间间隔标签。见pretty。


参数:vnames
By default, variable labels are used to label axes.  Set vnames = "names" to instead use variable names.  
默认情况下,变量标签使用的标签轴。设置vnames = "names",而不是使用的变量名。


参数:omit
vector of character strings containing names of variables for which to suppress drawing axes.  Default is to show all variables.  
矢量的字符串中的抑制绘图轴的变量的名称。默认是显示所有的变量。


参数:verbose
set to TRUE to get printed output detailing how tick marks are chosen and labeled for function axes.  This is useful in seeing how certain linear predictor values cannot be solved for using inverse linear interpolation on the (requested linear predictor values, function values at  these lp values).  When this happens you will see NAs in the verbose output, and the corresponding tick marks will not appear in the nomogram.  
设置为TRUE得到的打印输出,详细介绍了如何选择和标记功能轴的刻度线。看到使用逆线性内插有一定的线性预测值不能得到解决,这是非常有用的(请求的线性预测值,函数值的在这些LP值)。当这一切发生的时候,你会看到NAS的详细输出,将不会出现在诺模图和相应的刻度线。


参数:x
an object created by nomogram, or the x coordinate for a legend
创建的对象nomogram,或x坐标的传说


参数:dec
number of digits to the right of the decimal point, for rounding point scores in print.nomogram.  Default is to round to the nearest whole number of points.  
数的小数点右边的数字,四舍五入分数print.nomogram。默认值是四舍五入到最接近的整数点。


参数:lplabel
label for linear predictor axis.  Default is "Linear Predictor".  
线性预测轴的标签。默认是"Linear Predictor"。


参数:fun.side
a vector or list of vectors of side parameters for the axis function for labeling function values. Values may be 1 to position a tick mark label below the axis (the default), or 3 for above the axis.  If for example an axis has 5 tick mark labels and the second and third will run into each other, specify fun.side=c(1,1,3,1,1) (assuming only one function is specified as fun).  
一个向量或向量sideaxis功能标记函数值的参数列表。值可以是1到下面的轴刻度线标签(默认值),或3个以上的轴定位。例如,如果一个轴有5个刻度标记标签和第二次和第三次碰到对方,指定fun.side=c(1,1,3,1,1)(假设只有一个函数被指定为fun)。


参数:col.conf
colors corresponding to conf.int.  
颜色对应的conf.int。


参数:conf.space
a 2-element vector with the vertical range within which to draw confidence bars, in units of 1=spacing between main bars.  Four heights are used within this range (8 for the linear predictor if more than 16 unique values were evaluated), cycling them among separate confidence intervals to reduce overlapping.  
一个2元素的向量与垂直范围内的绘制信心条形,1 =主杆之间的间距为单位。在此范围内4个高度(8的线性预测,如果超过16个独特的价值进行评估),骑自行车,他们之间独立的置信区间,以减少重叠。


参数:label.every
Specify label.every = i to label on every ith tick mark.  
指定label.every = i标记在每个i个刻度线。


参数:force.label
set to TRUE to force every tick mark intended to be labeled to have a label plotted (whether the labels run into each other or not)  
设置为TRUE强制被贴上标签,标签的绘制每一个刻度标记(标签是否碰到对方或不)


参数:xfrac
fraction of horizontal plot to set aside for axis titles  
分数水平的图设置预留轴标题


参数:cex.axis
character size for tick mark labels  
字符大小刻度标记标签


参数:cex.var
character size for axis titles (variable names)  
坐标轴标题的字符大小(变量名)


参数:col.grid
If left unspecified, no vertical reference lines are drawn.  Specify a vector of length one (to use the same color for both minor and major reference lines) or two (corresponding to the color for the major and minor divisions, respectively) containing colors, to cause vertical reference lines to the top points scale to be drawn.  For R, a good choice is col.grid = gray(c(0.8, 0.95)).  
如果未指定,没有垂直参考线绘制。指定一个向量的长度为1(使用相同的颜色为主要和次要的参考线)或两个(对应的颜色的主要和次要的区划,分别)含有颜色,导致最佳点的垂直参考线规模绘制。对于R,一个不错的选择col.grid = gray(c(0.8, 0.95))。


参数:varname.label
In constructing axis titles for interactions, the default is to add (interacting.varname = level) on the right.  Specify varname.label = FALSE to instead use "(level)".  
在建立坐标轴标题的互动,默认情况下是,加上(interacting.varname = level)的权利。指定varname.label = FALSE,而不是使用"(level)"。


参数:varname.label.sep
If varname.label = TRUE, you can change the separator to something other than = by specifying this parameter.  
如果varname.label = TRUE,你可以更换分离器以外的东西=指定此参数。


参数:ia.space
When multiple axes are draw for levels of interacting factors, the default is to group combinations related to a main effect.  This is done by spacing the axes for the second to last of these  within a group only 0.7 (by default) of the way down as compared with normal space of 1 unit.  
当多个轴画的水平相互作用的因素,默认的是组组合的主要作用。这是的轴间距倒数第二的这些组内的只有0.7(默认情况下)的方式下降,比正常的空间为1个单位。


参数:tck
see tck under par  
看到tck下par


参数:tcl
length of tick marks in nomogram
在诺模图的刻度线长度


参数:lmgp
spacing between numeric axis labels and axis (see par for mgp)  
数值轴标签和轴之间的间距(见par的mgp)


参数:naxes
maximum number of axes to allow on one plot.  If the nomogram requires more than one “page”, the &ldquooints” axis will be repeated at the top of each page when necessary.  
最大轴数上允许一个图。如果诺模图需要一个以上的“页面”,“点”轴顶部的每一页,必要时重复。


参数:points.label
a character string giving the axis label for the points scale  
一个字符串给点规模的轴标签


参数:total.points.label
a character string giving the axis label for the total points scale  
轴标签的字符串,总规模


参数:total.sep.page
set to TRUE to force the total points and later axes to be placed on a separate page  
设置为TRUE强制的总积分,后来轴被放置在一个单独的页面


参数:total.fun
a user-provided function that will be executed before the total points axis is drawn.  Default is not to execute a function.  This is useful e.g. when total.sep.page = TRUE and you wish to use locator to find the coordinates for positioning an abbreviation legend before it's too late and a new page is started (i.e., total.fun = function() print(locator(1))).  
一个用户提供的函数将被执行前的总积分轴画。默认情况下不执行的功能。这是有用的例如当total.sep.page = TRUE“,你想用locator找到的坐标定位的缩写传说的前为时已晚,开始了新的一页(即total.fun = function() print(locator(1))”)。


参数:cap.labels
logical: should the factor labels have their first letter capitalized?
逻辑的因素标签的第一个字母大写?


参数:object
the result returned from nomogram  
返回的结果从nomogram


参数:which
a character string giving the name of a variable for which to draw a legend with abbreviations of factor levels  
给一个字符串变量的名称,画一个传说因子水平的缩写


参数:y
y-coordinate to pass to the legend function.  This is the upper left corner of the legend box.  You can omit y if x is a list with named elements x and y.  To use the mouse to locate the legend, specify locator(1) for x.  For print, x is the result of nomogram.  
y坐标传递给legend功能。这是图例框的左上角。您可以省略y如果x命名的元素的列表x和y。要使用鼠标来找到传说中,指定locator(1)x。对于print,x的结果nomogram。


参数:ncol
the number of columns to form in drawing the legend.  
数列形成在绘制的传说。


Details

详细信息----------Details----------

A variable is considered to be discrete if it is categorical or ordered or if datadist stored values for it (meaning it had <11 unique values). A variable is said to be indirectly related to another variable if the two are related by some interaction.  For example, if a model has variables a, b, c, d, and the interactions are a:c and c:d, variable d is indirectly related to variable a.  The complete list of variables related to a is c, d.  If an axis is made for variable a, several axes will actually be drawn, one for each combination of c and d specified in interact.
一个变量被认为是离散的,如果它是明确的,或订购或datadist存储values它(有<11独特的价值)。一个变量被说成是间接有关的另一个变量,如果两个是相关的一些相互作用。例如,如果一个模型的变量a,B,C,D,和的相互作用是:c和C:D,变量d间接相关的变量a。涉及到的变量的完整列表,C,D。如果一个轴为变量a,将实际绘制多个轴,c和d的每一种组合中指定interact之一。

Note that with a caliper, it is easy to continually add point scores for individual predictors, and then to place the caliper on the upper &ldquooints&rdquo; axis (with extrapolation if needed).  Then transfer these points to the &ldquo;Total Points&rdquo; axis.  In this way, points can be added without without writing them down.
请注意,用游标卡尺,它很容易不断添加点分数为个别预测因子,然后放置在卡钳上的上部的“积分”轴线(与外推如果需要的话)。然后把这些点,“共点”轴。在这种方式中,可以添加,而不写下来。

Confidence limits for an individual predictor score are really confidence limits for the entire linear predictor, with other predictors set to adjustment values.  If lp = TRUE, all confidence bars for all linear predictor values evaluated are drawn.  The extent to which multiple confidence bars of differing widths appear at the same linear predictor value means that precision depended on how the linear predictor was arrived at (e.g., a certain value may be realized from a setting of a certain predictor that was associated with a large standard error on the regression coefficients for that predictor).
个人的预测得分是真正的可信限为整个线性预测,与其他预测调整值的置信区间。如果lp = TRUE“的所有线性预测值的绘制了所有的信心条。在何种程度上多个不同宽度的信心条形出现在相同的线性预测值是指精度取决于如何的线性预测到达一定值(例如,可实现从设定有一定的预测是与大的标准误差的回归系数的预测)。

On occasion, you may want to reverse the regression coefficients of a model to make the &ldquo;points&rdquo; scales reverse direction.  For parametric survival models, which are stated in terms of increasing regression effects meaning longer survival (the opposite of a Cox model), just do something like fit$coefficients <- -fit$coefficients before invoking nomogram,  and if you add function axes, negate the function arguments.  For the Cox model, you also need to negate fit$center. If you omit lp.at, also negate fit$linear.predictors.
有时,您可能希望,扭转回归系数的模型,使“点”尺度相反的方向。参数生存模型,这是在回归效应增加,这意味着较长的生存期(相反的Cox比例风险模型)表示,做这样的事情fit$coefficients <- -fit$coefficients,然后再调用nomogram,如果你添加功能轴,否定函数的参数。 Cox模型,你还需要否定fit$center。如果省略lp.at,也否定fit$linear.predictors。


值----------Value----------

a list of class "nomogram" that contains information used in plotting the axes.  If you specified abbrev = TRUE, a list called abbrev is also returned that gives the abbreviations used for tick mark labels, if any.   This list is useful for making legends and is used by legend.nomabbrev (see the last example). The returned list also has components called total.points, lp, and the function axis names.  These components have components x (at argument vector given to axis), y (pos for axis), and x.real, the x-coordinates appearing on tick mark labels. An often useful result is stored in the list of data for each axis variable, namely the exact number of points that correspond to each tick mark on that variable's axis.
一个列表类"nomogram"的包含用于策划轴的信息。如果你指定了abbrev = TRUE,一个叫做abbrev的也返回,使刻度标记标签中使用的缩写,如果有的话。此列表是用于使传说和使用legend.nomabbrev(见最后一个例子)。返回的列表也有total.points,lp,和功能轴的名称。这些组件有组件x(ataxis的参数向量),y(posaxis),和x.real ,刻度标记标签上出现的x坐标。往往是有用的结果存储在数据列表中的每个轴的变量,即对应于每个刻度标记该变量的轴点的确切数量。


(作者)----------Author(s)----------



Frank Harrell<br>
Department of Biostatistics<br>
Vanderbilt University<br>
<a href="mailto:f.harrell@vanderbilt.edu">f.harrell@vanderbilt.edu</a>




参考文献----------References----------

Editors: S Kotz and NL Johnson.  New York: Wiley; 1985.
of a diagnostic or prognostic function.  Meth. Inform. Med. 17:127&ndash;129; 1978.


参见----------See Also----------

rms, plot.Predict, plot.summary.rms, axis, pretty, approx, latex.rms, rmsMisc
rms,plot.Predict,plot.summary.rms,axis,pretty,approx,latex.rms,rmsMisc


实例----------Examples----------


n &lt;- 1000    # define sample size[确定样本量]
set.seed(17) # so can reproduce the results[所以可以重现的结果]
age            <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol    <- rnorm(n, 200, 25)
sex            <- factor(sample(c('female','male'), n,TRUE))


# Specify population model for log odds that Y=1[指定的log几率的人口模型Y = 1]
L <- .4*(sex=='male') + .045*(age-50) +
  (log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)][模拟二进制y以有PROB(y = 1时)= 1 / [1 +(-L)]]
y <- ifelse(runif(n) < plogis(L), 1, 0)


ddist <- datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')


f <- lrm(y ~ lsp(age,50)+sex*rcs(cholesterol,4)+blood.pressure)
nom &lt;- nomogram(f, fun=function(x)1/(1+exp(-x)),  # or fun=plogis[或有趣的plogis]
    fun.at=c(.001,.01,.05,seq(.1,.9,by=.1),.95,.99,.999),
    funlabel="Risk of Death")
#Instead of fun.at, could have specified fun.lp.at=logit of[而不是fun.at,可以指定fun.lp.at =罗吉特的]
#sequence above - faster and slightly more accurate[序列以上 - 更快,更准确的]
plot(nom, xfrac=.45)
print(nom)
nom <- nomogram(f, age=seq(10,90,by=10))
plot(nom, xfrac=.45)
g <- lrm(y ~ sex + rcs(age,3)*rcs(cholesterol,3))
nom <- nomogram(g, interact=list(age=c(20,40,60)),
                conf.int=c(.7,.9,.95))
plot(nom, col.conf=c(1,.5,.2), naxes=7)


cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
d.time <- -log(runif(n))/h
death <- ifelse(d.time <= cens,1,0)
d.time <- pmin(d.time, cens)


f <- psm(Surv(d.time,death) ~ sex*age, dist='lognormal')
med  <- Quantile(f)
surv &lt;- Survival(f)  # This would also work if f was from cph[这也将工作,如果f是从CPH]
plot(nomogram(f, fun=function(x) med(lp=x), funlabel="Median Survival Time"))
nom <- nomogram(f, fun=list(function(x) surv(3, x),
                            function(x) surv(6, x)),
            funlabel=c("3-Month Survival Probability",
                       "6-month Survival Probability"))
plot(nom, xfrac=.7)

## Not run: [#不运行:]
nom <- nomogram(fit.with.categorical.predictors, abbrev=TRUE, minlength=1)
nom$x1$points   # print points assigned to each level of x1 for its axis[分配给其轴线的x1每个级别的打印点]
#Add legend for abbreviations for category levels[添加分类级别的缩写传说]
abb <- attr(nom, 'info')$abbrev$treatment
legend(locator(1), abb$full, pch=paste(abb$abbrev,collapse=''),
       ncol=2, bty='n')  # this only works for 1-letter abbreviations[这仅适用于1个字母的缩写]
#Or use the legend.nomabbrev function:[或者使用legend.nomabbrev:]
legend.nomabbrev(nom, 'treatment', locator(1), ncol=2, bty='n')

## End(Not run)[#(不执行)]


#Make a nomogram with axes predicting probabilities Y&gt;=j for all j=1-3[的诺模图与轴的预测概率Y> = J J = 1-3]
#in an ordinal logistic model, where Y=0,1,2,3[在一个有序logistic回归模型Y = 0,1,2,3]
Y <- ifelse(y==0, 0, sample(1:3, length(y), TRUE))
g <- lrm(Y ~ age+rcs(cholesterol,4)*sex)
fun2 <- function(x) plogis(x-g$coef[1]+g$coef[2])
fun3 <- function(x) plogis(x-g$coef[1]+g$coef[3])
f <- Newlabels(g, c(age='Age in Years'))  
#see Design.Misc, which also has Newlevels to change [Design.Misc,这也有Newlevels改变]
#labels for levels of categorical variables[标签分类变量的水平]
g <- nomogram(f, fun=list('Prob Y>=1'=plogis, 'Prob Y>=2'=fun2,
                     'Prob Y=3'=fun3),
         fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99))
plot(g, lmgp=.2, cex.axis=.6)
options(datadist=NULL)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-23 16:31 , Processed in 0.024949 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表