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

R语言 RMark包 covariate.predictions()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-26 23:39:23 | 显示全部楼层 |阅读模式
covariate.predictions(RMark)
covariate.predictions()所属R语言包:RMark

                                        Compute estimates of real parameters for multiple covariate values
                                         多因素值计算的实际参数估计

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

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

Computes real estimates for a dataframe of covariate values and the var-cov matrix of the real estimates.
一个数据框的协变量值和真正的估计VAR-CoV的矩阵计算实际的估计。


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


  covariate.predictions(model, data = NULL, indices = NULL,
    drop = TRUE)



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

参数:model
MARK model object or marklist
MARK模型对象或marklist的


参数:data
dataframe with covariate values used for estimates; if it contains a field called index the covariates in each row are only applied to the parameter with that index and the argument indices is not needed
数据框用于估计的协变量值,如果它包含一个字段名为索引每行中的协变量只适用于与该索引的参数和参数指标不


参数:indices
a vector of indices from the all-different PIM structure for parameters to be computed
指数从不同的PIM结构的向量参数计算


参数:drop
if TRUE, models with any non-positive variance for betas are dropped
如果为TRUE,任何非正方差模型的贝他被丢弃


Details

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

This function has a similar use as compute.real except that it is specifically designed to compute real parameter estimates for multiple covariate values for either a single model or to compute model averaged estimates across a range of models within a marklist. This is particularly useful for computing and plotting the real parameter as a function of the covariate with pointwise confidence bands (see example below). The function also computes a variance-covariance matrix for the real parameters.  For example, assume you had a model with two age classes of young and adult and survial for young was a function of weight and you wanted to estimate survivorship to some adult age as a function of weight.  To do that you need the survival for young as a function of weight, the adult survival, the variance of each and their covariance.  This function will allow you to accomplish tasks like these and many others.
这个函数有一个类似用途为compute.real不同的是它是专门为一个单一的模型或计算模型多因素值计算的实际参数估计的平均估计在一系列的车型在marklist。这是特别有用的计算和绘图的实际参数的协变量的函数的逐点置信区间(见下面的例子)。该函数也计算的真实参数的方差 - 协方差矩阵。例如,假设你有一个模型,两个年龄层的年轻和年轻成人和存活率是一个函数的重量,你想一些成年的函数的重量估计生存。要做到这一点,你需要年轻的重量,成人求生存,以各自的方差和协方差函数的生存。此功能可以让你喜欢这些和许多其他人来完成任务。

When a variance-covariance matrix is computed for the real parameters, it can get too large for available memory for a large set of real parameters. Most models contain many possible real parameters to accomodate the general structure even if there are very few unique ones. It is necessary to use the most general structure to accomodate model averaging.  Most of the time you will only want to compute the values of a limited set of real parameters but possibly for a range of covariate values. Use the argument indices to select the real parameters to be computed.  The index is the value that the real parameter has been assigned with the all-different PIM structure. If you looked at the row numbers in the design data for the dipper example, you would see that the parameter for p and Phi are both numbered 1 to 21.  But to deal with multiple parameters effectively they are given a unique number in a specific order.  For the CJS model, p follows Phi, so for the dipper example, Phi are numbered 1 to 21 and then p are numbered 22 to 42. You can use the function PIMS to lookup the parameter numbers for a parameter type if you use simplified=FALSE. For example, with the dipper data, you could enter PIMS(dipper.model,"p",simplified=FALSE) and you would see that they are numbered 22 to 42. Alternatively, you can use summary.mark with the argument se=TRUE to see the list of indices named all.diff.index.  They are included in a dataframe for each model parameter which enables them to be selected based on the attached data values (e.g., time, group etc).  For example, if you fitted a model called dipper.model then you could use summary(dipper.model,se=TRUE)$real to list the indices for each parameter.
当方差 - 协方差矩阵计算的实际参数,就可以得到太大可用内存大集的实际参数。大多数型号都包含了许多可能的真实参数,以适应一般的结构,即使有非常独特的。这是必要的,使用最一般的结构,以适应模型平均。大多数的时间,你将只需要计算一组有限的实参的值,但有可能的协变量值的范围。使用参数indices选择真正的参数计算。该指数是实参的值已分配的所有不同的PIM结构。如果你看行号的设计资料dipper例如,你会看到的参数p和披编号为1至21。但是,为了有效地处理多个参数,在一个特定的顺序,给他们一个唯一的编号。 CJS模型,P如下披的瓢例如,披编号为1到21,然后p的编号为22至42。您可以使用的功能PIMS的来查找参数号参数类型,如果你使用simplified=FALSE。 dipper数据,例如,你可以输入PIMS(dipper.model,"p",simplified=FALSE),你会看到他们的编号为22至42。或者,你可以使用summary.mark的论点se=TRUE看到列表中的索引名为all.diff.index。它们被包含在一个数据框,使他们能够被选择的附加的数据值(例如,时间,组等)的基础上为每个模型参数。例如,如果你安装了一个模型,称为dipper.model然后你可以使用summary(dipper.model,se=TRUE)$real列出的每个参数的指数。

The argument data is a dataframe containing values for the covariates used in the models.  The names for the fields should match the names of the covariates used in the model.  If a time-varying covariate is used then you need to specify the covariate name with the time index included as it is specified in the data. You do not need to specify all covariates that were used.  If a covariate in one or more models is not included in data then the mean value will be used for each missing covariate. That can be very useful when you are only interested in prediction for one type of parameters (eg Phi) when there are many covariates that are not interesting in another parameter (e.g., p).  For each row in data, each parameter specified in indices is computed with those covariate values.  So if there were 5 rows in data and 10 parameters were specified there would be 10 sets of 5 (50) estimates produced.  If you do not want the full pairing of data and estimates, create a field called index in data and the estimate for that parameter will be computed with those specific values. For example, if you wanted parameter 1 to be computed with 5 different values of a covariate and then parameter 7 with 2 different covariate values, you could create a dataframe with 5 rows each having an index with the value 1 along with the relevant covariate data and an additional 2 rows with the index with the value 7. If you include the field index in data then you do not need to give a value for the argument indices.
参数data是一个数据框包含在模型中的协变量的值。的字段名协变量在模型中使用的名称相匹配。如果随时间变化的协变量,那么你需要指定的协变量的名称,时间指数,因为它是指定的数据。您不必指定所有的协变量。如果在一个或多个模型的协变量还没有包含在data然后平均值将被用来为每个丢失的协变量。这是非常有用的,当你只关注一种类型的参数(例如:PHI)时,有许多是不感兴趣的另一个参数(例如,p)的协变量的预测。中的每一行data,在indices每个指定的参数计算与协变量值。因此,如果有5行中的数据和10个参数指定了将有10套的5(50)估计的产生。如果你不想要的数据和估计的配对,创建一个字段称为index中data,估计该参数将与这些特定值计算。例如,如果你想5个不同的值有2个不同的协变量值的协变量和参数7参数计算,你可以创建一个数据框5行index值1,随着相关的协变量数据和一个额外的2行index值7。如果你的领域indexdata“,那么你不需要给定值的参数indices。


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

A list is returned containing a dataframe of estimates
返回一个列表,包含一个数据框的估计


参数:estimates
data frame containing estimates, se, confidence interval and the data values used to compute the estimates
数据框包含的估计,本身,置信区间和用于计算的估计的数据值


参数:vcv
variance-covariance matrix of real estimates
方差 - 协方差矩阵实时估计


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



Jeff Laake




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

compute.real,model.average
compute.real,model.average


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


pathtodata=paste(path.package("RMark"),"extdata",sep="/")

#[]
# indcov1.R[indcov1.R]
#[]
# CJS analysis of the individual covariate data from 12.2 of[的CJS分析,个别协数据从12.2]
# Cooch and White[库奇和白色]
#[]
# Import data (indcov1.inp) and convert it from the MARK inp file[导入数据(indcov1.inp“),MARK inp文件,并将其转换]
# format to the RMark format using the function convert.inp[格式来的RMark格式使用的功能convert.inp的]
# It is defined with 1 group but 2 individual covariates of mass and[它被定义为一组,但2个独立的协变量的质量和]
# squared.mass[squared.mass]
#[]
indcov1=convert.inp(paste(pathtodata,"indcov1",sep="/"),
               covariates=c("mass","squared.mass"))
#[]
# Next create the processed dataframe and the design data.[接下来,创建的处理的数据框和设计数据。]
#[]
  ind1.process=process.data(indcov1,model="CJS")
  ind1.ddl=make.design.data(ind1.process)
#[]
# Next create the function that defines and runs the set of models[接下来,创建函数定义和运行的模型集]
# and returns a marklist with the results and a model.table.[并返回一个marklist的结果和model.table的。]
# It does not have any arguments but does use the ind1.process[它没有任何参数,但使用ind1.process]
# and ind1.ddl objects created above in the workspace. The function[ind1.ddl在工作区中创建的对象。该功能]
# create.model.list is the function that creates a dataframe of the[create.model.list的功能是创建一个数据框的]
# names of the parameter specifications for each parameter in that[规格参数中的每个参数的名称]
# type of model. If none are given for any parameter, the default[行为型模式。如果没有给出任何参数,则默认]
# specification will be used for that parameter in mark.  The[规范将被用于该参数标记。 “]
# first argument of mark.wrapper is the model list of parameter[第一个参数mark.wrapper是模型的参数列表]
# specifications.  Remaining arguments that are passed to[规格。其余的参数被传递到]
# mark must be specified using the argument=value specification[标记必须指定使用参数=值规范]
# because the arguments of mark were not repeated in mark.wrapper[标志,因为这些论点不重复mark.wrapper]
# so they must be passed using the argument=value syntax.[因此,他们必须通过使用参数= value语法。]
#[]
ind1.models=function()
{
  Phi.dot=list(formula=~1)
  Phi.mass=list(formula=~mass)
  Phi.mass.plus.mass.squared=list(formula=~mass + squared.mass)
  p.dot=list(formula=~1)
  cml=create.model.list("CJS")
  results=mark.wrapper(cml,data=ind1.process,ddl=ind1.ddl,adjust=FALSE)
  return(results)
}
#[]
# Next run the function to create the models and store the results in[接下来运行函数来创建的模型,并把结果存储在]
# ind1.results which is a marklist. Note that beta estimates will differ[ind1.results这是一个marklist。需要注意的是测试版的估计会有所不同]
# from Cooch and White results because we are using covariate values[从库奇和白色的结果,因为我们使用的是协变量值]
# directly rather than standardized values.[而不是直接的标准值。]
#[]
ind1.results=ind1.models()
#[]
# Next compute real parameter values for survival as a function of[接下来计算实际生存的函数的参数值]
# mass which are model-averaged over the fitted models.[质量模型的拟合模型平均。]
#[]
minmass=min(indcov1$mass)
maxmass=max(indcov1$mass)
mass.values=minmass+(0:30)*(maxmass-minmass)/30
Phibymass=covariate.predictions(ind1.results,
   data=data.frame(mass=mass.values,squared.mass=mass.values^2),
    indices=c(1))
#[]
# Plot predicted model averaged estimates by weight with pointwise[图预测模型平均重量估计逐点]
# confidence intervals[置信区间]
#[]
plot(Phibymass$estimates$mass, Phibymass$estimates$estimate,
   type="l",lwd=2,xlab="Mass(kg)",ylab="Survival",ylim=c(0,.65))
lines(Phibymass$estimates$mass, Phibymass$estimates$lcl,lty=2)
lines(Phibymass$estimates$mass, Phibymass$estimates$ucl,lty=2)

# indcov2.R[indcov2.R]
#[]
# CJS analysis of the individual covariate data from 12.3 of[的CJS分析,个别协数据从12.3]
# Cooch and White[库奇和白色]
#[]
# Import data (indcov2.inp) and convert it from the MARK inp file[导入数据(indcov2.inp“),MARK inp文件,并将其转换]
# format to the RMark format using the function convert.inp  It is[格式的RMark格式使用的功能convert.inp它是]
# defined with 1 group but 2 individual covariates of mass and[定义1组,但2个独立的协变量的质量和]
# squared.mass[squared.mass]
#[]
indcov2=convert.inp(paste(pathtodata,"indcov2",sep="/"),
        covariates=c("mass","squared.mass"))
#[]
# Standardize covariates[标准化的协变量]
#[]
actual.mass=indcov2$mass
standardize=function(x,z=NULL)
{
   if(is.null(z))
   {
       return((x-mean(x))/sqrt(var(x)))
   }else
   {
      return((x-mean(z))/sqrt(var(z)))
   }
}
indcov2$mass=standardize(indcov2$mass)
indcov2$squared.mass=standardize(indcov2$squared.mass)
#[]
# Next create the processed dataframe and the design data.[接下来,创建的处理的数据框和设计数据。]
#[]
  ind2.process=process.data(indcov2,model="CJS")
  ind2.ddl=make.design.data(ind2.process)
#[]
# Next create the function that defines and runs the set of models and[接下来,创建函数定义和运行的模型和]
# returns a marklist with the results and a model.table.  It does not[返回一个与的结果和model.table“marklist。它不]
# have any arguments but does use the ind1.process and ind1.ddl[有任何参数,但不使用的ind1.process和ind1.ddl]
# objects created above in the workspace. The function create.model.list[在工作区中创建的对象。功能create.model.list]
# is the function that creates a dataframe of the names of the parameter[是创建一个数据框的名称的参数的函数,该函数]
# specifications for each parameter in that type of model. If none are[这种类型的模型中的每个参数的规格。如果没有]
# given for any parameter, the default specification will be used for[给出任何参数,则默认的规范将被用于]
# that parameter in mark.  The first argument of mark.wrapper is the[该参数标记。第一个参数mark.wrapper是]
# model list of parameter specifications.  Remaining arguments that are[模型参数规格列表。其余的参数,]
# passed to mark must be specified using the argument=value specification[传递给标记必须指定使用参数=值规范]
# because the arguments of mark were not repeated in mark.wrapper so[因为没有重复的参数标记在mark.wrapper所以]
# they must be passed using the argument=value syntax.[他们必须通过使用参数= value语法。]
#[]
ind2.models=function()
{
  Phi.dot=list(formula=~1)
  Phi.time=list(formula=~time)
  Phi.mass=list(formula=~mass)
  Phi.mass.plus.mass.squared=list(formula=~mass + squared.mass)
  Phi.time.x.mass.plus.mass.squared=
        list(formula=~time:mass + time:squared.mass)
  Phi.time.mass.plus.mass.squared=
     list(formula=~time*mass + squared.mass+ time:squared.mass)
  p.dot=list(formula=~1)
  cml=create.model.list("CJS")
  results=mark.wrapper(cml,data=ind2.process,ddl=ind2.ddl,adjust=FALSE,threads=2)
  return(results)
}
#[]
# Next run the function to create the models and store the results in[接下来运行函数来创建的模型,并把结果存储在]
# ind2.results which is a marklist. Note that beta estimates will differ[ind2.results这是一个marklist。需要注意的是测试版的估计会有所不同]
# because we are using covariate values directly rather than[因为我们使用的协变量值,而不是直接]
# standardized values.[标准值。]
#[]
ind2.results=ind2.models()
#[]
# Next compute real parameter values for survival as a function of[接下来计算实际生存的函数的参数值]
# mass which are model-averaged over the fitted models. They are[质量模型的拟合模型平均。他们是]
# standardized individually so the values have to be chosen differently.[标准化单独的值都必须在不同的选择。]
#[]
minmass=min(actual.mass)
maxmass=max(actual.mass)
mass.values=minmass+(0:30)*(maxmass-minmass)/30
squared.mass.values=mass.values^2
mass.values=standardize(mass.values,actual.mass)
squared.mass.values=standardize(squared.mass.values,actual.mass^2)
Phibymass=covariate.predictions(ind2.results,
data=data.frame(mass=mass.values,squared.mass=squared.mass.values),
  indices=c(1:7))
#[]
# Plot predicted model averaged estimates by weight with pointwise[图预测模型平均重量估计逐点]
# confidence intervals[置信区间]
#[]
par(mfrow=c(4,2))
for (i in 1:7)
{
   mass=minmass+(0:30)*(maxmass-minmass)/30
   x=Phibymass$estimates
   plot(mass,x$estimate[x$par.index==i],type="l",lwd=2,
    xlab="Mass(kg)",ylab="Survival",ylim=c(0,1),main=paste("Time",i))
   lines(mass, x$lcl[x$par.index==i],lty=2)
   lines(mass, x$ucl[x$par.index==i],lty=2)
}


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 21:09 , Processed in 0.026539 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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