mcsimex(simex)
mcsimex()所属R语言包:simex
Misclassification in models using MCSIMEX
误分类模型中使用MCSIMEX
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Implementation of the misclassification MCSIMEX algorithm as described by K眉chenhoff, Mwalili and Lesaffre.
的误判MCSIMEX执行算法所描述的Küchenhoff,Mwalili和乐斯福。
用法----------Usage----------
mcsimex(model, SIMEXvariable, mc.matrix, lambda = c(0.5, 1, 1.5, 2),
B = 100, fitting.method = "quadratic", jackknife.estimation = "quadratic",
asymptotic = TRUE)
## S3 method for class 'mcsimex':
print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'mcsimex':
summary(object,...)
## S3 method for class 'mcsimex':
plot(x, xlab = expression((1 + lambda)), ylab = colnames(b[, -1]),
ask = FALSE, show = rep(TRUE, NCOL(b) - 1), ...)
## S3 method for class 'mcsimex':
predict(object, newdata, ...)
## S3 method for class 'mcsimex':
refit(object, fitting.method = "quadratic",
jackknife.estimation = "quadratic", asymptotic = TRUE, ...)
参数----------Arguments----------
参数:model
the naive model, the misclassified variable must be a factor
天真的模型,错误分类的变量必须是一个因素
参数:SIMEXvariable
vector of names of the variables for which the MCSIMEX-method should be applied
向量的该MCSIMEX方法应适用的变量的名称
参数:mc.matrix
if one variable is misclassified it can be a matrix. If more than one variable is misclassified it must be a list of the misclassification matrices, names must match with the SIMEXvariable names, column- and row-names must match with the factor levels. If a special misclassification is desired, the name of a function can be specified (see details)
被错误分类,如果一个变量,它可以是一个矩阵。如果一个以上的变量被错误分类误判矩阵,它必须是一个列表,名称必须匹配与SIMEXvariable名称,列和行的名称必须与因子水平相匹配。如果需要的话,一个特殊的误分类的名称,可以指定一个函数(见详情)
参数:lambda
vector of exponents for the misclassification matrix (without 0)
矢量误判矩阵指数(不含0)
参数:B
number of iterations for each lambda
每个lambda的迭代次数
参数:fitting.method
linear, quadratic and loglinear are implemented (first 4 letters are enough)
linear,quadratic和loglinear实施(第4个字母是足够的)
参数:jackknife.estimation
specifying the extrapolation method for jackknife variance estimation. Can be set to FALSE if it should not be performed
指定的刀切法方差估计,外推法。如果它不应该被执行,可以设置为FALSE
参数:asymptotic
logical, indicating if asymptotic variance estimation should be done, the option x = TRUE must be enabled in the naive model
逻辑,表示如果渐近方差估计应该做的,选项“x = TRUE必须启用天真的模型
参数:x
object of class 'mcsimex'
对象类的mcsimex“
参数:digits
number of digits to be printed
要打印的数字位数
参数:object
object of class 'mcsimex'
对象类的mcsimex“
参数:xlab
optional name for the X-Axis
X-轴的名称(可选)
参数:ylab
vector containing the names for the Y-Axis
向量含有的Y-轴的名称
参数:ask
logical. If TRUE, the user is asked for input, before a new figure is drawn
逻辑。如果TRUE,用户被要求输入,绘制在一个新的数字
参数:show
vector of logicals indicating for wich variables a plot should be produced
向量,逻辑值至极的变量,一个图,应
参数:newdata
optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used
可选的数据框中寻找变量,用以预测。如果省略该参数,拟合的线性预测
参数:...
arguments passed to other functions
参数传递给其他函数
Details
详细信息----------Details----------
if mc.matrix is a function the first argument of that function must be the whole dataset used in the naive model, the second argument must be the exponent (lambda) for the misclassification. The function must return a data.frame containing the misclassified SIMEXvariable. An example can be found below.
如果mc.matrix是一个函数,该函数的第一个参数必须是整个数据集天真的模型中,第二个参数必须是误分类指数(λ)。该函数必须返回一个data.frame包含错误分类的SIMEXvariable。一个例子可以在下面找到。
Asymptotic variance estimation is only implemented for lm and glm
渐近方差估计只执行lm和glm
The loglinear fit has the form g(lambda, GAMMA) = exp(gamma0 + gamma1 * lambda). It is realized via the log() function. To avoid negative values the minimum +1 of the dataset is added and after the prediction later substracted exp(predict(...)) - min(data) - 1.
对数线性拟合的形式g(lambda, GAMMA) = exp(gamma0 + gamma1 * lambda)。它实现通过log()功能。为了避免负值的最小+1的数据集后,加入后的预测减去exp(predict(...)) - min(data) - 1。
The 'log2' fit is fitted via the nls() function for direct fitting of the model y ~ exp(gamma.0 + gamma.1 * lambda). As starting values the results of a LS-fit to a linear model with a log transformed response are used. If nls does not converge, the model with the starting values is returned.
通过nls()功能,直接安装的模式y ~ exp(gamma.0 + gamma.1 * lambda)LOG2“适合安装。作为起始值的LS适合与转化log响应的线性模型的结果使用。如果nls不收敛,模型的初始值返回。
refit() refits the object with a different extrapolation function.
refit()改装一个不同的外推功能的对象。
值----------Value----------
An object of class 'mcsimex' which contains: <table summary="R valueblock"> <tr valign="top"><td>coefficients</td> <td> corrected coefficients of the MCSIMEX model,</td></tr> <tr valign="top"><td>SIMEX.estimates</td> <td> the MCSIMEX-estimates of the coefficients for each lambda,</td></tr> <tr valign="top"><td>lambda</td> <td> the values of lambda,</td></tr> <tr valign="top"><td>model</td> <td> the naive model,</td></tr> <tr valign="top"><td>mc.matrix</td> <td> the misclassification matrix,</td></tr> <tr valign="top"><td>B</td> <td> the number of iterations,</td></tr> <tr valign="top"><td>extrapolation</td> <td> the model object of the extrapolation step,</td></tr> <tr valign="top"><td>fitting.method</td> <td> the fitting method used in the extrapolation step,</td></tr> <tr valign="top"><td>SIMEXvariable</td> <td> name of the SIMEXvariables,</td></tr> <tr valign="top"><td>call</td> <td> the function call,</td></tr> <tr valign="top"><td>variance.jackknife</td> <td> the jackknife variance estimates,</td></tr> <tr valign="top"><td>extrapolation.variance</td> <td> the model object of the variance extrapolation,</td></tr> <tr valign="top"><td>variance.jackknife.lambda</td> <td> the data set for the extrapolation,</td></tr> <tr valign="top"><td>variance.asymptotic</td> <td> the asymptotic variance estimates,</td></tr> <tr valign="top"><td>theta</td> <td> all estimated coefficients for each lambda and B,</td></tr> </table> ...
对象的类的mcsimex“,其中包含:<table summary="R valueblock"> <tr valign="top"> <TD> coefficients</ TD> <TD>,修正系数在MCSIMEX模型,< / TD> </ TR> <tr valign="top"> <TD>SIMEX.estimates </ TD> <TD> MCSIMEX估计每个lambda的系数,</ TD> </ TR> < TR VALIGN =“”> <TD>lambda </ TD> <TD>的值λ,</ TD> </ TR> <tr valign="top"> <TD>model </ TD> <TD>的天真的模型,</ TD> </ TR> <tr valign="top"> <TD>mc.matrix </ TD> <TD>误判矩阵,</ TD > </ TR> <tr valign="top"> <TD>B </ TD> <TD>的迭代次数,</ TD> </ TR> <tr valign="top"> < extrapolation TD> </ TD> <TD>模型对象外推步骤,</ TD> </ TR> <tr valign="top"> <TD> fitting.method</ TD> <TD>外推步骤中使用的拟合方法,</ TD> </ TR> <tr valign="top"> <TD> SIMEXvariable</ TD> <TD>的SIMEXvariables名称,</ TD> </ TR> <tr valign="top"> <TD> call </ TD> <TD>的函数调用,</ TD> </ TR> <tr valign="top"> < variance.jackknife TD> </ TD> <TD>刀切法方差估计,</ TD> </ TR> <tr valign="top"> <TD> extrapolation.variance</ TD> <TD>模型对象的变异推断,</ TD> </ TR> <tr valign="top"> <TD> variance.jackknife.lambda</ TD> <TD>的数据的外推法,</ TD> </ TR> <tr valign="top"> <TD> variance.asymptotic </ TD> <TD>渐近方差的估计,</ TD> </ TR> <tr valign="top"> <TD >theta</ TD> <TD>所有的估计系数为每个lambda和B </ TD> </ TR> </ TABLE> ...
(作者)----------Author(s)----------
Wolfgang Lederer, <a href="mailto:wolfgang.lederer@googlemail.com">wolfgang.lederer@googlemail.com</a>
参考文献----------References----------
K眉chenhoff, H., Mwalili, S. M. and Lesaffre, E. (2006) A general method for dealing with misclassification in regression: The Misclassification SIMEX. Biometrics, 62, 85 – 96
K眉chenhoff, H., Lederer, W. and E. Lesaffre. (2006) Asymptotic Variance Estimation for the Misclassification SIMEX. Computational Statistics and Data Analysis, 51, 6197 – 6211
Lederer, W. and K眉chenhoff, H. (2006) A short introduction to the SIMEX and MCSIMEX. R News, 6(4), 26–31
参见----------See Also----------
misclass, simex
misclass,simex
实例----------Examples----------
x <- rnorm(200, 0, 1.142)
z <- rnorm(200, 0, 2)
y <- factor(rbinom(200, 1, (1 / (1 + exp(-1 * (-2 + 1.5 * x -0.5 * z))))))
Pi <- matrix(data = c(0.9, 0.1, 0.3, 0.7), nrow = 2, byrow = FALSE)
dimnames(Pi) <- list(levels(y), levels(y))
ystar <- misclass(data.frame(y), list(y = Pi), k = 1)[, 1]
naive.model <- glm(ystar ~ x + z, family = binomial, x = TRUE, y = TRUE)
true.model <- glm(y ~ x + z, family = binomial)
simex.model <- mcsimex(naive.model, mc.matrix = Pi, SIMEXvariable = "ystar")
op <- par(mfrow = c(2, 3))
invisible(lapply(simex.model$theta, boxplot, notch = TRUE, outline = FALSE,
names = c(0.5, 1, 1.5, 2)))
plot(simex.model)
simex.model2 <- refit(simex.model, "line")
plot(simex.model2)
par(op)
# example for a function which can be supplied to the function mcsimex()[例如,为一个函数,它可被提供给功能mcsimex()]
# "ystar" is the variable which is to be misclassified[“ystar”是变量,该变量是被错误分类]
# using the example above[使用上面的示例]
my.misclass <- function (datas, k) {
ystar <- datas$"ystar"
p1 <- matrix(data = c(0.75, 0.25, 0.25, 0.75), nrow = 2, byrow = FALSE)
colnames(p1) <- levels(ystar)
rownames(p1) <- levels(ystar)
p0 <- matrix(data = c(0.8, 0.2, 0.2, 0.8), nrow = 2, byrow = FALSE)
colnames(p0) <- levels(ystar)
rownames(p0) <- levels(ystar)
ystar[datas$x < 0] <-
misclass(data.frame(ystar = ystar[datas$x < 0]), list(ystar = p1), k = k)[, 1]
ystar[datas$x > 0] <-
misclass(data.frame(ystar = ystar[datas$x > 0]), list(ystar = p0), k = k)[, 1]
ystar <- factor(ystar)
return(data.frame(ystar))
}
simex.model.differential <- mcsimex(naive.model, mc.matrix = "my.misclass", SIMEXvariable = "ystar")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|