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

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

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

                                        Mallard nest survival example
                                         野鸭巢生存的例子

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

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

A nest survival data set on mallards.  The data set and analysis is described by Rotella et al.(2004).
巢生存数据集野鸭。罗泰拉等人(2004)描述的数据集和分析。


格式----------Format----------

A data frame with 565 observations on the following 13 variables.
一个数据框有565以下13个变量的观察。




FirstFound the day the nest was first found
FirstFound日在鸟巢首次被发现




LastPresent the last day that chicks were present
LastPresent的最后一天,小鸡




LastChecked the last day the nest was checked
LastChecked最后一天的巢检查

  


Fate the fate
命运的命运

  


Freq the frequency of nests
频率的频率巢的

  


Robel Robel reading of
Robel Robel阅读

  


PpnGrass proportion grass in vicinity of nest
在巢附近的PpnGrass比例草




Native dummy 0/1 variable; 1 if native vegetation
如果原生植被原生的虚拟0/1变量;




Planted dummy 0/1 variable; 1 if planted vegetation
如果种植植被种植假人0/1变量; 1




Wetland dummy 0/1 variable; 1 if wetland vegetation
湿地假人0/1变量,如果湿地植被




Roadside dummy 0/1 variable; 1 if roadside vegetation
路边的植物,如果路边假人0/1变量;




AgeFound age of nest in days the day the nest was found
AgeFound年龄一天的巢窝在天




AgeDay1 age of nest at beginning of study
在研究开始AgeDay1岁的巢


Details

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

The first 5 fields must be named as they are shown for nest survival models. Freq and the remaining fields are optional.  See killdeer for more description of the nest survival data structure and the use of the special field AgeDay1. The habitat variables Native,Planted,Wetland,Roadside were originally coded as 0/1 dummy variables to enable easier modelling with MARK.  A better alternative in RMark is to create a single variable habitat with values of "Native","Planted", "Wetland", and "Roadside". Then the Hab model in the example below would become:
前5个字段必须被命名为他们所显示的巢生存模式。 Freq和余下的字段是可选的。见killdeer多描述的巢生存的数据结构和使用的特殊领域AgeDay1的。的栖息地变量Native,Planted,Wetland,Roadside最初编码为0/1的虚拟变量,可以更轻松地建模与MARK。在RMark一个更好的选择是建立一个单一的变量habitat与"Native","Planted","Wetland"和"Roadside"值。在下面的例子将成为哈模型:


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



Jay Rotella




源----------Source----------

Rotella, J.J., S. J. Dinsmore, T.L. Shaffer.  2004. Modeling nest-survival data: a comparison of recently developed methods that can be implemented in MARK and SAS.  Animal Biodiversity and Conservation 27:187-204.
路路达,J.J.,S. J.丁斯莫尔,T.L.谢弗。 2004年。巢生存建模数据:最近开发的方法,可以实现在MARK和SAS的比较。动物生物多样性和保护27:187-204。


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


# Last updated June 2, 2011[最后更新日期:2011年6月2日]
# Read in data, which are in a simple text file that[读入数据,这是一个简单的文本文件,]
# looks like a MARK input file but (1) with no comments or semicolons and[看起来像MARK输入文件,但(1)无意见或分号]
# (2) with a 1st row that contains column labels[(2)与第1行,包含列标签]
# mallard=read.table("mallard.txt",header=TRUE)[野鸭= read.table(的“mallard.txt”,头= TRUE)]

# The mallard data set is also incuded with RMark and can be retrieved with[绿头鸭数据集也incuded与RMark和可以检索与]
# data(mallard)[数据(野鸭)]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~#]
# Example of use of RMark for modeling nest survival data -   #[巢生存数据建模使用的RMark的示例 - #]
# Mallard nests example                                       #[野鸭巢例如#]
# The example runs the 9 models that are used in the Nest     #[该示例运行的9款车型中使用的鸟巢#]
# Survival chapter of the Gentle Introduction to MARK and that#[生存的温柔章介绍MARK和#]
# appear in Table 3 (page 198) of                             #[出现在表3(第198页)#]
# Rotella, J.J., S. J. Dinsmore, T.L. Shaffer.  2004.         #[路路达,J.J.,S. J.丁斯莫尔,T.L.谢弗。 2004年。 #]
# Modeling nest-survival data: a comparison of recently       #[建模巢生存的比较数据:最近#]
# developed methods that can be implemented in MARK and SAS.  #[开发的方法,可以实现在MARK和SAS。 #]
#   Animal Biodiversity and Conservation 27:187-204.          #[动物生物多样性和保护27:187-204。 #]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~#]

require(RMark)

# Retrieve data[检索数据]
data(mallard)

# Treat dummy variables for habitat types as factors[治疗栖息地类型的虚拟变量的因素]
mallard$Native=factor(mallard$Native)
mallard$Planted=factor(mallard$Planted)
mallard$Wetland=factor(mallard$Wetland)
mallard$Roadside=factor(mallard$Roadside)

# Examine a summary of the dataset[检查的概要的数据集]
summary(mallard)

# Write a function for evaluating a set of competing models[写一个函数评估组的竞争车型]
run.mallard=function()
{
# 1. A model of constant daily survival rate (DSR)[1。模型的恒定的日常生存率(DSR)]
        Dot=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~1)))

# 2. DSR varies by habitat type - treats habitats as factors[2。 DSR不同的生境类型 - 把栖息地的因素]
#  and the output provides S-hats for each habitat type[每个栖息地类型的输出提供了S-帽子]
        Hab=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~Native+Planted+Wetland)),
                        groups=c("Native","Planted","Wetland"))

# 3. DSR varies with vegetation thickness (Robel reading)[3。 DSR变化与植被的厚度(Robel阅读)]
# Note: coefficients are estimated using the actual covariate[注:系数估计的实际协]
# values. They are not based on standardized covariate values.[值。他们没有根据标准化的协变量值。]
        Robel=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~Robel)))

# 4. DSR varies with the amount of native vegetation in the surrounding area[4。 DSR与周边区域的原生植被变化]
# Note: coefficients are estimated using the actual covariate[注:系数估计的实际协]
# values. They are not based on standardized covariate values.[值。他们没有根据标准化的协变量值。]
        PpnGr=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~PpnGrass)))

# 5. DSR follows a trend through time[5。 DSR遵循一个趋势,通过时间]
        TimeTrend=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~Time)))

# 6. DSR varies with nest age[6。 DSR与巢时代的变化而变化]
        Age=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~NestAge)))

# 7. DSR varies with nest age & habitat type[7。 DSR随巢的年龄和栖息地类型]
        AgeHab=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~NestAge+Native+Planted+Wetland)),
                        groups=c("Native","Planted","Wetland"))

# 8. DSR varies with nest age & vegetation thickness[8。 DSR随巢的年龄和植被厚度]
        AgeRobel=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~NestAge+Robel)))

# 9. DSR varies with nest age & amount of native vegetation in surrounding area[9。 DSR随周边区域原生植被巢年龄及金额]
        AgePpnGrass=mark(mallard,nocc=90,model="Nest",
                        model.parameters=list(S=list(formula=~NestAge+PpnGrass)))

#[]
# Return model table and list of models[回归模型的表格和列表的车型]
#[]
        return(collect.models() )
}

# The next line runs the 9 models above and takes a minute or 2[下一行执行上述9款车型,并采取一分钟或2]
mallard.results=run.mallard()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Examine table of model-selection results #[检查表的模型选择结果#]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]

export.MARK(mallard.results$Age$data,"MallDSR",mallard.results,replace=TRUE,ind.covariates="all")
mallard.results                        # print model-selection table to screen[打印模式选择表屏幕]
options(width=100)                     # set page width to 100 characters[设置页面的宽度为100个字符]
sink("results.table.txt")              # capture screen output to file[捕获屏幕输出到文件]
print.marklist(mallard.results)        # send output to file[将输出发送到文件]
sink()                                 # return output to screen[返回输出到屏幕]

# remove "#" on next line to see output in notepad[下一行看到输出在记事本中删除“#”]
# system("notepad results.table.txt",invisible=FALSE,wait=FALSE)[(“记事本results.table.txt”,无形= FALSE,等待= FALSE)]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Examine output for constant DSR model #[检查输出恒定的DSR模型#]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Remove "#" on next line to see output[删除“#”下一行看到输出]
# mallard.results$Dot                  # print MARK output to designated text editor[mallard.results点#打印MARK输出到指定的文本编辑器]
mallard.results$Dot$results$beta       # view estimated beta for model in R[查看模型估计贝在R]
mallard.results$Dot$results$real       # view estimated DSR estimate in R[查看估计DSR估计在R]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Examine output for 'DSR by habitat' model #[检查输出DSR栖息地“的模式#]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Remove "#" on next line to see output[删除“#”下一行看到输出]
# mallard.results$Hab                  # print MARK output to designated text editor[mallard.results MARK哈#打印输出到指定的文本编辑器]
mallard.results$Hab$design.matrix      # view the design matrix that was used[查看使用的设计矩阵,]
mallard.results$Hab$results$beta       # view estimated beta for model in R[查看模型估计贝在R]
mallard.results$Hab$results$beta.vcv   # view variance-covariance matrix for beta's[查看方差 - 协方差矩阵的β]
mallard.results$Hab$results$real       # view the estimates of Daily Survival Rate[查看每日成活率的估计]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Examine output for best model #[检查输出为最佳模型#]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#]
# Remove "#" on next line to see output[删除“#”下一行看到输出]
# mallard.results$AgePpnGrass            # print MARK output to designated text editor[mallard.results AgePpnGrass#打印MARK输出到指定的文本编辑器]
mallard.results$AgePpnGrass$results$beta # view estimated beta's in R[估计贝在R]
mallard.results$AgePpnGrass$results$beta.vcv # view estimated var-cov matrix in R[查看估计的VAR-CoV的矩阵在R]

# To obtain estimates of DSR for various values of 'NestAge' and 'PpnGrass'[要获得估计DSR为“NestAge”和“PpnGrass的各种价值观的”]
#   some work additional work is needed.[一些工作需要额外的工作。]

# Store model results in object with simpler name[对象存储模型结果,简单的名称]
AgePpnGrass=mallard.results$AgePpnGrass
# Build design matrix with ages and ppn grass values of interest[建立设计矩阵,年龄和利益的的PPN草值]
# Relevant ages are age 1 to 35 for mallards[有关年龄1至35岁的野鸭]
# For ppngrass, use a value of 0.5[ppngrass,使用值0.5]
fc=find.covariates(AgePpnGrass,mallard)
fc$value[1:35]=1:35                    # assign 1:35 to 1st 35 nest ages[分配1:35至1日35窝年龄]
fc$value[fc$var=="PpnGrass"]=0.1       # assign new value to PpnGrass[分配新的价值PpnGrass]
design=fill.covariates(AgePpnGrass,fc) # fill design matrix with values[填写设计矩阵的值]
# extract 1st 35 rows of output[提取首35行输出]
AgePpn.survival=compute.real(AgePpnGrass,design=design)[1:35,]
# insert covariate columns[插入协列]
AgePpn.survival=cbind(design[1:35,c(2:3)],AgePpn.survival)
colnames(AgePpn.survival)=c("Age","PpnGrass","DSR","seDSR","lclDSR","uclDSR")
AgePpn.survival       # view estimates of DSR for each age and PpnGrass combo[估计DSR为每个年龄和PpnGrass的组合]

# Plot results[图结果]
with(data=AgePpn.survival,plot(Age,DSR,'l',ylim=c(0.88,1)))
grid()
axis.break(axis=2,breakpos=0.879,style='slash')
with(data=AgePpn.survival,points(Age,lclDSR,'l',lty=3))
with(data=AgePpn.survival,points(Age,uclDSR,'l',lty=3))

# assign 17 to 1st 50 nest ages[分配17日至1日50窝年龄]
fc$value[1:89]=17
# assign range of values to PpnGrass[指定的值的范围PpnGrass]
fc$value[fc$var=="PpnGrass"]=seq(0.01,0.99,length=89)
design=fill.covariates(AgePpnGrass,fc) # fill design matrix with values[填写设计矩阵的值]
AgePpn.survival=compute.real(AgePpnGrass,design=design)
# insert covariate columns[插入协列]
AgePpn.survival=cbind(design[,c(2:3)],AgePpn.survival)
colnames(AgePpn.survival)=
                c("Age","PpnGrass","DSR","seDSR","lclDSR","uclDSR")
# view estimates of DSR for each age and PpnGrass combo[估计DSR为每个年龄和PpnGrass的组合]
AgePpn.survival

# Plot results[图结果]
# open new graphics window for new plot[新的图形窗口打开新的图]
dev.new()
with(data=AgePpn.survival,plot(PpnGrass,DSR,'l',ylim=c(0.88,1)))
grid()
axis.break(axis=2,breakpos=0.879,style='slash')
with(data=AgePpn.survival,points(PpnGrass,lclDSR,'l',lty=3))
with(data=AgePpn.survival,points(PpnGrass,uclDSR,'l',lty=3))

# The "rm" command can be used to remove all objects from the .Rdata file.[“rm”命令可用于从。RDATA文件中删除所有对象。]
# Cleaning up objects as shown in this script is good programming[在此脚本中所示的清理对象是良好的编程]
# practice and a good idea as long as the computations are not time consuming.[只要计算的实践和一个好主意是不费时。]
# However, if your analysis is taking several hours or days in MARK then[但是,如果您的分析几个小时或几天MARK,然后]
# clearly you'll want to hang onto the resulting objects in R and you[清楚你要挂在R上产生的对象,]
# won't want to use the following command. It has been commented out for[不希望使用下面的命令。它已被注释掉]
# this example; the "#" on the next line needs to be removed to do the clean up.[于此,例如,需要被移除的下一行上的“#”做清理。]
# rm(list=ls(all=TRUE))[RM(,列表= LS(所有= TRUE))]

# The next line deletes orphaned output files from MARK.[从MARK下一行删除孤立的输出文件。]
# ?cleanup will give a more complete description of this function.[?清理会给此功能的更完整的描述。]
cleanup(ask=FALSE)


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-19 17:24 , Processed in 0.026362 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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