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

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

[复制链接]
发表于 2012-10-1 15:54:00 | 显示全部楼层 |阅读模式
smartpred(VGAM)
smartpred()所属R语言包:VGAM

                                         Smart Prediction
                                         智能预测

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

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

Data-dependent parameters in formula terms can cause problems in when predicting. The smartpred package for R and S-PLUS saves data-dependent parameters on the object so that the bug is fixed. The lm and glm functions have been fixed properly. Note that the VGAM package by T. W. Yee automatically comes with smart prediction.
数据相关的参数式条款,可能会导致问题时预测。 smartpred包R和S-PLUS数据相关的参数保存的对象,这样的错误是固定的。 lm和glm功能已被妥善固定。请注意,VGAM包由TW仪自动与智能预测。


Details

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

R version 1.6.0 introduced a partial fix for the prediction problem because it does not work all the time, e.g., for terms such as I(poly(x, 3)),  poly(c(scale(x)), 3), bs(scale(x), 3),  scale(scale(x)). See the examples below. Smart prediction, however, will always work.
R版本1.6.0引入了部分修复的预测问题,因为它不工作的时候,例如,如I(poly(x, 3)),poly(c(scale(x)), 3),bs(scale(x), 3),scale(scale(x)) 。请参见下面的例子。智能预测,但是,会一直工作。

The basic idea is that the functions in the formula are now smart, and the modelling functions make use of these smart functions.  Smart prediction works in two ways: using smart.expression, or using a combination of put.smart and get.smart.
其基本思路是,公式中的功能,现在的智能,建模功能,利用这些智能功能。智能预测的工作方式有两种:使用smart.expression,或组合使用put.smart和get.smart的。


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

Returns the usual object, but with one list/slot component called smart.prediction containing any data-dependent parameters.
返回通常的对象,但一个列表/插槽部分称为smart.prediction包含任何数据相关的参数。


副作用----------Side Effects----------

The variables .max.smart, .smart.prediction and  .smart.prediction.counter are created while the model is being fitted. In R they are created in a new environment called smartpredenv. In S-PLUS they are created in frame 1. These variables are deleted after the model has been fitted. However, in R, if there is an error in the model fitting function or the fitting model is killed (e.g., by typing control-C) then these variables will be left in smartpredenv.  At the beginning of model fitting, these variables are deleted if present in smartpredenv.
的变量.max.smart,.smart.prediction和.smart.prediction.counter,时创建的模型正在装修。在R中创建一个新的环境称为smartpredenv。在S-PLUS中创建的第1帧。这些变量被删除后,该模型已安装。然而,在R,如果有一个错误的模型拟合函数的拟合模型被杀害(例如,键入control-C),那么这些变量会被留在smartpredenv。模型拟合开始时,这些变量都将被删除,如果在smartpredenv。

During prediction, the variables .smart.prediction and  .smart.prediction.counter are reconstructed and read by the smart functions when the model frame is re-evaluated.  After prediction, these variables are deleted.
在预测变量.smart.prediction和.smart.prediction.counter重建和阅读的智能功能时,模型框架进行重新评估。预测后,这些变量将被删除。

If the modelling function is used with argument smart = FALSE (e.g., vglm(..., smart = FALSE)) then smart prediction will not be used, and the results should match with the original R or S-PLUS functions.
如果使用参数建模功能smart = FALSE(例如,vglm(..., smart = FALSE)),然后智能预测将不会被使用,其结果应与原来的R或S-PLUS功能相匹配。


警告----------WARNING ----------

In S-PLUS, if the "bigdata" library is loaded then it is detach()'ed. This is done because scale cannot be made smart if "bigdata" is loaded (it is loaded by default in the Windows version of Splus 8.0, but not in Linux/Unix). The function search tells what is currently attached.
在S-PLUS,如果"bigdata"库被加载,那么它是detach()版。这是因为scale不能作出聪明的,如果"bigdata"被加载(它被加载默认情况下,Windows版本的S-PLUS 8.0,但不是在Linux / Unix)。说明当前连接的功能search。

In R and S-PLUS the functions predict.bs and predict.ns are not smart. That is because they operate on objects that contain attributes only and do not have list components or slots. In R the function predict.poly is not smart.
在R和S-PLUS的功能predict.bs和predict.ns是不聪明的。那是因为他们操作的对象只包含属性,没有列表组件或插槽。在R的功能predict.poly是不聪明。


注意----------Note----------

In S-PLUS you will need to load in the smartpred library with the argument first = T, e.g., library(smartpred, lib = "./mys8libs", first = T). Here, mys8libs is the name of a directory of installed packages. To install the smartpred package in Linux/Unix, type something like Splus8 INSTALL -l ./mys8libs ./smartpred_0.8-2.tar.gz.
在S-PLUS中,你将需要加载的说法smartpred,例如,first = Tlibrary(smartpred, lib = "./mys8libs", first = T)库。在这里,mys8libs安装的软件包的目录的名称。要安装的smartpred的包在Linux / Unix,键入类似于Splus8 INSTALL -l ./mys8libs ./smartpred_0.8-2.tar.gz。


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


T. W. Yee and T. J. Hastie



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

get.smart.prediction, get.smart, put.smart, smart.expression, smart.mode.is, setup.smart, wrapup.smart. Commonly used data-dependent functions include scale,  poly,  bs,  ns. In R,  the functions bs and ns are in the splines package, and this library is automatically loaded in because it contains compiled code that  bs and ns call.
get.smart.prediction,get.smart,put.smart,smart.expression,smart.mode.is,setup.smart,wrapup.smart。常用的数据相关的功能包括scale,poly,bs,ns。在R,功能bs和nssplines包,该库自动加载,因为它包含编译的代码bs和ns打检测。

The website http://www.stat.auckland.ac.nz/~yee contains more information such as how to write a smart function, and other technical details.
的的网站http://www.stat.auckland.ac.nz/~仪包含更多的信息,比如如何写的智能功能,和其他技术细节。

The functions vglm, vgam, rrvglm and cqo in T. W. Yee's VGAM package are examples of modelling functions that employ smart prediction.
的功能vglm,vgam,rrvglm和cqoTW仪的VGAM包的建模功能,采用了智能预测。


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


# Create some data first[先创建一些数据]
n <- 20
set.seed(86) # For reproducibility of the random numbers[的随机数的可重复性]
x <- sort(runif(n))
y <- sort(runif(n))
## Not run: if(is.R()) library(splines)   # To get ns() in R[(is.R())#库(曲线)NS()在R#不运行:]


# This will work for R 1.6.0 and later, but fail for S-PLUS[这将工作的R 1.6.0和更高版本,但失败的S-PLUS]
fit <- lm(y ~ ns(x, df = 5))
## Not run:  plot(x, y)[#未运行图(X,Y)]
lines(x, fitted(fit))
newx <- seq(0, 1, len = n)
points(newx, predict(fit, data.frame(x = newx)), type = "b",
       col = 2, err = -1)
## End(Not run)[#(不执行)]

# The following fails for R 1.6.x and later but works with smart prediction[下面的R 1.6.x版和更高版本中失败,但与智能预测]
fit <- lm(y ~ ns(scale(x), df = 5))
## Not run:  fit$smart.prediction[#不运行:适合$ smart.prediction]
plot(x, y)
lines(x, fitted(fit))
newx <- seq(0, 1, len = n)
points(newx, predict(fit, data.frame(x = newx)), type = "b",
       col = 2, err = -1)
## End(Not run)[#(不执行)]

# The following requires the VGAM package to be loaded [要加载以下要求VGAM的软件包]
## Not run:  library(VGAM)[#运行库(VGAM)]
fit <- vlm(y ~ ns(scale(x), df = 5))
fit@smart.prediction
plot(x, y)
lines(x, fitted(fit))
newx <- seq(0, 1, len = n)
points(newx, predict(fit, data.frame(x = newx)), type = "b",
       col = 2, err = -1)
## End(Not run)[#(不执行)]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-26 11:44 , Processed in 0.023438 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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