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

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

[复制链接]
发表于 2012-9-27 22:43:44 | 显示全部楼层 |阅读模式
plotPlane(rockchalk)
plotPlane()所属R语言包:rockchalk

                                        Draw a 3-D regression plot for two predictors from any linear or nonlinear lm or glm object
                                         从任何线性或非线性LM或GLM对象的绘制3-D两个预测回归图

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

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

This allows user to fit a regression model with many variables and then plot 2 of its predictors and the output plane for those predictors with other variables set at mean or mode (numeric or factor).  This is a front-end (wrapper) for R's persp function. Persp does all of the hard work, this function reorganizes the information for the user in a more readily understood way.  It intended as a convenience for students (or others) who do not want to fight their way through the details needed to use persp to plot a regression plane. The fitted model can have any number of input variables, this will display only two of them. And, at least for the moment, I insist these predictors must be numeric variables. They can be transformed in any of the usual ways, such as poly, log, and so forth.
这允许用户以适应回归模型有许多变量,然后积2的预测因子和输出平面那些与其他变量设置在平均或模式(数字或因素)的预测。这是一个前端(包装)ŕ的persp功能的。 Persp所有的辛勤工作,此功能整理在一个更容易理解的方式,为用户的信息。它打算的学生(或其他人)谁不想打的细节需要使用persp绘制的回归平面的方式,通过一个方便。拟合模型可以有任意数量的输入变量,这将显示只有他们两个人。而且,至少在目前,我坚持这些预测必须是数值型变量。它们可在任何通常的方法,如聚,log转化,并依此类推。


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


  plotPlane(model = NULL, plotx1 = NULL, plotx2 = NULL,
    drawArrows = FALSE, plotPoints = TRUE, npp = 20, x1lab,
    x2lab, ylab, x1floor = 5, x2floor = 5, pch = 1,
    pcol = "blue", plwd = 0.5, pcex = 1, llwd = 0.3,
    lcol = 1, llty = 1, acol = "red", alty = 4, alwd = 0.3,
    alength = 0.1, envir = environment(formula(model)),
    ...)

  ## Default S3 method:
plotPlane(model = NULL, plotx1 = NULL,
    plotx2 = NULL, drawArrows = FALSE, plotPoints = TRUE,
    npp = 20, x1lab, x2lab, ylab, x1floor = 5, x2floor = 5,
    pch = 1, pcol = "blue", plwd = 0.5, pcex = 1,
    llwd = 0.3, lcol = 1, llty = 1, acol = "red", alty = 4,
    alwd = 0.3, alength = 0.1,
    envir = environment(formula(model)), ...)



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

参数:model
an lm or glm fitted model object
LM或GLM拟合模型对象


参数:plotx1
name of one variable to be used on the x1 axis
要使用一个变量的名称上的x1轴


参数:plotx2
name of one variable to be used on the x2 axis
要使用一个变量的名称上的x2轴


参数:drawArrows
draw red arrows from prediction plane toward observed values TRUE or FALSE
画红色箭头预测面向观测值TRUE或FALSE


参数:plotPoints
Should the plot include scatter of observed scores?
如果图包括分散的观察分数?


参数:npp
number of points at which to calculate prediction
在哪些数量的点来计算预测


参数:x1lab
optional label
可选的标签


参数:x2lab
optional label
可选的标签


参数:ylab
optional label
可选的标签


参数:x1floor
Default=5. Number of "floor" lines to be drawn for variable x1
默认值= 5。要绘制的“地板”行变量x1


参数:x2floor
Default=5. Number of "floor" lines to be drawn for variable x2
默认值= 5。要绘制的“地板”行数为变量x2


参数:pch
plot character, passed on to the "points" function
图字符,通过“点”功能


参数:pcol
color for points, col passed to "points" function
颜色分,列通过“点”功能


参数:plwd
line width, lwd passed to "points" function
线条的宽度,随钻测井传递到“点”功能


参数:pcex
character expansion, cex passed to "points" function
字符扩展,CEX通过“点”功能


参数:llwd
line width, lwd passed to the "lines" function
线宽,LWD传递给的“线”的功能


参数:lcol
line color, col passed to the "lines" function
线的颜色,列通过的“线”功能


参数:llty
line type, lty passed to the "lines" function
线的类型,LTY传递给的“线”的功能


参数:acol
color for arrows, col passed to "arrows" function
颜色箭头,列通过的“箭头”功能


参数:alty
line type, lty passed to the "arrows" function
线的类型,LTY传递的“箭头”功能


参数:alwd
line width, lwd passed to the "arrows" function
线条的宽度,随钻测井通过的“箭头”功能


参数:alength
arrow head length, length passed to "arrows" function
箭头长度,长度通过的“箭头”功能


参数:envir
environment from whence to grab data
环境从何处获取数据


参数:...
additional parameters that will go to persp
额外的参数,会去persp


Details

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

Besides a fitted model object, plotPlane requires two additional arguments, plotx1 and plotx2. These are the names of the plotting variables. Please note, that if the term in the regression is something like poly(fish,2) or log(fish), then the argument to plotx1 should be the quoted name of the variable "fish". plotPlane will handle the work of re-organizing the information so that R's predict functions can generate the desired information. This might be thought of as a 3D version of "termplot", with a significant exception. The calculation of predicted values depends on predictors besides plotx1 and plotx2 in a different ways. The sample averages are used for numeric variables, but for factors the modal value is used.
除了一个合适的模型对象,plotPlane需要两个额外的的参数,plotx1和plotx2。这些是绘图的变量的名称。请注意,如果术语在回归plotx1的东西,如聚(鱼,2)或log(鱼),则该参数是引用变量“鱼”的名称。 plotPlane将处理重新组织的信息,因此,R的预测函数可以生成所需的信息的工作。这可能是想到了作为3D版“termplot”中,一个显着的例外。预测值的计算依赖于预测除了plotx1和plotx2在一个不同的方式。所使用的样本平均数值变量,但使用模态值的因素。

This function creates an empty 3D drawing and then fills in the pieces. It uses the R functions lines, points, and arrows. To allow customization, several parameters are introduced for the users to choose colors and such. These options are prefixed by "l" for the lines that draw the plane, "p" for the points, and "a" for the arrows. Of course, if plotPoints=FALSE or drawArrows=FALSE, then these options are irrelevant.
这个函数创建一个空的3D绘图与填充件。它使用的R功能lines,points,arrows。要允许自定义,介绍几个参数供用户选择颜色等。这些选项的前缀“l”的绘制的线的平面中,“p”表示的点,和“a”的箭头。当然,如果plotPoints = FALSE或drawArrows = FALSE,则这些选项是无关的。


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

The main point is the plot that is drawn, but for record keeping the return object is a list including 1) res: the transformation matrix that was created by persp 2) the call that was issued, 3) x1seq, the "plot sequence" for the x1 dimension, 4) x2seq, the "plot sequence" for the x2 dimension, 5) zplane, the values of the plane corresponding to locations x1seq and x2seq.
主要的一点是所绘制的图,但对记录保存返回的对象是一个列表,其中包括1)RES:变换矩阵,是由persp 2)发出的呼叫,3)x1seq,的“图序列” ; x1的维数,4)x2seq,的x2维度“图序列”,5)zplane,的值平面对应位置x1seq和x2seq。


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



Paul E. Johnson <pauljohn@ku.edu>




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

persp, scatterplot3d, regr2.plot
persp,scatterplot3d,regr2.plot


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


library(rockchalk)


set.seed(12345)
x1 <- rnorm(100)
x2 <- rnorm(100)
x3 <- rnorm(100)
x4 <- rnorm(100)
y <- rnorm(100)
y2 <- 0.03 + 0.1*x1 + 0.1*x2 + 0.25*x1*x2 + 0.4*x3 -0.1*x4 + 1*rnorm(100)
dat <- data.frame(x1,x2,x3,x4,y, y2)
rm(x1, x2, x3, x4, y, y2)

## linear ordinary regression[#线性常回归]
m1 <- lm(y ~ x1 + x2 +x3 + x4, data = dat)

plotPlane(m1, plotx1 = "x3", plotx2 = "x4")

plotPlane(m1, plotx1 = "x3", plotx2 = "x4", drawArrows = TRUE)

plotPlane(m1, plotx1 = "x1", plotx2 = "x4", drawArrows = TRUE)


plotPlane(m1, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE, npp = 10)
plotPlane(m1, plotx1 = "x3", plotx2 = "x2", drawArrows = TRUE, npp = 40)

plotPlane(m1, plotx1 = "x3", plotx2 = "x2", drawArrows = FALSE, npp = 5, ticktype = "detailed")


## regression with interaction[#回归与互动]
m2 <- lm(y ~ x1  * x2 +x3 + x4, data = dat)

plotPlane(m2, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE)


plotPlane(m2, plotx1 = "x1", plotx2 = "x4", drawArrows = TRUE)
plotPlane(m2, plotx1 = "x1", plotx2 = "x3", drawArrows = TRUE)

plotPlane(m2, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE, phi = 10, theta = 30)



## regression with quadratic;[#回归二次;]
## Required some fancy footwork in plotPlane, so be happy[#在plotPlane需要一些奇特的步法,所以很高兴]
dat$y3 <- 0 + 1 * dat$x1 + 2 * dat$x1^2 + 1 * dat$x2 + 0.4*dat$x3 + 8 * rnorm(100)
m3 <- lm(y3 ~ poly(x1,2) + x2 +x3 + x4, data = dat)
summary(m3)

plotPlane(m3, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE, x1lab = "my great predictor", x2lab = "a so-so predictor", ylab = "Most awesomest DV ever")

plotPlane(m3, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE, x1lab = "my great predictor", x2lab = "a so-so predictor", ylab = "Most awesomest DV ever", phi=-20)

plotPlane(m3, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE, phi = 10, theta = 30)

plotPlane(m3, plotx1 = "x1", plotx2 = "x4", drawArrows = TRUE, ticktype = "detailed")
plotPlane(m3, plotx1 = "x1", plotx2 = "x3", drawArrows = TRUE)

plotPlane(m3, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE, phi = 10, theta = 30)

m4 <- lm(y ~ sin(x1) + x2*x3 +x3 + x4, data = dat)
summary(m4)


plotPlane(m4, plotx1 = "x1", plotx2 = "x2", drawArrows = TRUE)
plotPlane(m4, plotx1 = "x1", plotx2 = "x3", drawArrows = TRUE)



eta3 <- 1.1 + .9*dat$x1 - .6*dat$x2 + .5*dat$x3
dat$y4 <- rbinom(100, size = 1, prob = exp( eta3)/(1+exp(eta3)))
gm1 <- glm(y4 ~ x1 + x2 + x3, data = dat, family = binomial(logit))
summary(gm1)
plotPlane(gm1, plotx1 = "x1", plotx2 = "x2")
plotPlane(gm1, plotx1 = "x1", plotx2 = "x2", phi = -10)

plotPlane(gm1, plotx1 = "x1", plotx2 = "x2", ticktype = "detailed")
plotPlane(gm1, plotx1 = "x1", plotx2 = "x2", ticktype = "detailed", npp = 30, theta = 30)
plotPlane(gm1, plotx1 = "x1", plotx2 = "x3", ticktype = "detailed", npp = 70, theta = 60)

plotPlane(gm1, plotx1 = "x1", plotx2 = "x2", ticktype = c("detailed"), npp = 50, theta = 40)

dat$x2 <- 5 * dat$x2
dat$x4 <- 10 * dat$x4
eta4 <- 0.1 + .15*dat$x1 - 0.1*dat$x2 + .25*dat$x3 + 0.1*dat$x4
dat$y4 <- rbinom(100, size = 1, prob = exp( eta4)/(1+exp(eta4)))
gm2 <- glm(y4 ~ x1 + x2 + x3 + x4, data = dat, family = binomial(logit))
summary(gm2)
plotPlane(gm2, plotx1 = "x1", plotx2 = "x2")
plotPlane(gm2, plotx1 = "x2", plotx2 = "x1")
plotPlane(gm2, plotx1 = "x1", plotx2 = "x2", phi = -10)
plotPlane(gm2, plotx1 = "x1", plotx2 = "x2", phi = 5, theta = 70, npp = 40)

plotPlane(gm2, plotx1 = "x1", plotx2 = "x2", ticktype = "detailed")
plotPlane(gm2, plotx1 = "x1", plotx2 = "x2", ticktype = "detailed", npp = 30, theta = -30)
plotPlane(gm2, plotx1 = "x1", plotx2 = "x3", ticktype = "detailed", npp = 70, theta = 60)

plotPlane(gm2, plotx1 = "x4", plotx2 = "x3", ticktype = "detailed", npp = 50, theta = 10)

plotPlane(gm2, plotx1 = "x1", plotx2 = "x2", ticktype = c("detailed"))

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-25 13:01 , Processed in 0.023903 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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