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

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

[复制链接]
发表于 2012-10-2 07:29:30 | 显示全部楼层 |阅读模式
AsciiGridImpute(yaImpute)
AsciiGridImpute()所属R语言包:yaImpute

                                        Imputes/Predicts data for Ascii Grid maps
                                         责难/预测数据为ASCII栅格图

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

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

AsciiGridImpute finds nearest neighbor reference observations for each point in the input grid maps and outputs maps of selected Y-variables in a set of output grid maps.
AsciiGridImpute发现近邻参考观测输入网格图和输出选择的Y中的变量的一组输出网格图的图中的每个点。

AsciiGridPredict applies a predict function to each point in the input grid maps and outputs maps of the prediction(s) in one or more output grid maps (see Details).
AsciiGridPredict适用预测函数输入网格图和图输出的预测()在一个或多个输出网格图中的每个点(见详情)。

One row of the each grid maps is read and processed at a time thereby avoiding the need to build huge objects in R that would be necessary if all
一排的每个栅格图的读取和处理,从而避免了需要建立庞大的对象在R这将是必要的,如果所有的时间


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


AsciiGridImpute(object,xfiles,outfiles,xtypes=NULL,ancillaryData=NULL,
                ann=NULL,lon=NULL,lat=NULL,rows=NULL,cols=NULL,
                nodata=NULL,myPredFunc=NULL,...)

AsciiGridPredict(object,xfiles,outfiles,xtypes=NULL,lon=NULL,lat=NULL,
                 rows=NULL,cols=NULL,nodata=NULL,myPredFunc=NULL,...)



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

参数:object
An object of class yai, any other object for which a predict function is defined, or an object that is passed to a predict function you define using argument myPredFunc. See Details.
一个对象的类yai,任何其他对象的predict函数的定义,或一个对象,它被传递给一个预测功能您使用参数myPredFunc定义。查看详细信息。


参数:xfiles
A list of input file names where there is one grid file for each X-variable. List elements must be given the same names as the X-variables they correspond with and there must be one file for each X-variable used when object was built.
Alist那里有一个网格文件,每个X-变量的输入文件名。 List中的元素,必须给予相同的名称X-变量对应,必须有一个文件,每个X-变量时使用object建。


参数:outfiles
One of these two forms:   
这两种形式之一:

(1) A file name that is understood to correspond to the single prediction returned by the generic predict function related to object or returned by myPredFunc. This form only applies to AsciiGridPredict, when the object is not class yai.  
(1)的文件名,被理解为对应于单一的预测,由通用predict返回功能涉及到object或由myPredFunc返回。这种形式只适用于AsciiGridPredict,当对象不是类yai。

(2) A list of output file names where there is one grid file for each desired output variable. While there may be many variables predicted for object, only those for which an output grid is desire need to be specified. Note that some predict functions return data frames, some return a single vector, and often what is returned depends on the value of arguments passed to predict. In addition to names of the predicted variables, the following two special names can be coded when the object class is yai: For distance=&ldquo;filename&rdquo; a map of the distances is output and if useid=&ldquo;filename&rdquo; a map of integer indices to row numbers of the reference observations is output. When the predict function returns a vector, an additional special name of predict=&ldquo;filename&rdquo; can be used.  </ul>
(2)Alist那里有一个网格文件,为每个所需的输出变量的输出文件名。虽然可能有许多预测object,只有那些输出电网的愿望,需要指定的变量。需要注意的是一些预测函数返回的数据框,一些返回一个向量,并经常返回什么依赖于传递的参数的值,来预测。除了预测变量的名称,以下两种特殊的名字时,对象类是可以被编码yai:对于distance=“文件名”图上的距离是输出,如果<X >图的整数索引行号的参考意见“文件名”输出。当预测函数返回一个向量,一个额外的特殊useid=“文件名”的名称都可以使用。 </ ul>


参数:xtypes
A list of data type names that corresponds exactly to data type of the maps listed in xfiles. Each value can be one of: "logical", "integer", "numeric", "character". If NULL, or if a type is missing for a member of xfiles, type "numeric" is used. See Details if you used factors as predictors.
完全对应的图中列出xfiles的数据类型,数据类型名列表。每个值可以是:"logical", "integer", "numeric", "character"之一。如果为NULL,或者如果一个类型是缺少的一员xfiles,请键入“"numeric"使用。详细,如果您使用作为预测的因素。


参数:ancillaryData
A data frame of Y-variables that may not have been used in the original call to yai. There must be one row for each reference observation, no missing data, and row names must match those used in the original reference observations.
一个数据框的Y-变量,可能没有被用来在原来的调用yai。必须有一个排的每个参考观察,没有丢失数据,行名称必须匹配那些在原来的参考意见。


参数:ann
if NULL, the value is taken from object. When TRUE, ann is used to find neighbors, and when FALSE a slow exact search is used (ignored for when method randomForest is used when the original yai object was created).
如果NULL,则是从object。 TRUE时,使用ann找到邻居,FALSE一个缓慢的精确搜索(忽略时所使用的方法randomForest是原始的yai对象被创建时)。


参数:lon
if NULL, the value of cols is used. Otherwise, a 2-element vector given the range of longitudes (horizontal distance) desired for the output.
如果为NULL,cols使用。否则,给定的2元素的向量经度(水平距离)的输出所期望的范围内。


参数:lat
if NULL, the value of rows is used. Otherwise, a 2-element vector given the range of latitudes (vertical distance) desired for the output.
如果为NULL,rows使用。否则,给定的2元素的向量纬度(垂直距离)的输出所期望的范围内。


参数:rows
if NULL, all rows from the input grids are used. Otherwise, rows is a 2-element vector given the rows desired for the output. If the second element is greater than the number of rows, the header value YLLCORNER is adjusted accordingly. Ignored if lon is specified.
如果为NULL,从电网输入的所有行。否则,行是一个给定的行的输出所期望的2元素向量。如果第二个元素的行数是大于,标头的值YLLCORNER相应的调整。如果忽略lon指定。


参数:cols
if NULL, all columns from the input grids are used. Otherwise, cols is a 2-element vector given the columns desired for the output. If the first element is greater than one, the header value XLLCORNER is adjusted accordingly. Ignored if lat is specified.
如果为NULL,从电网输入的所有列。否则,cols是给定的列的输出所期望的一个2元素的向量。如果第一个元素是大于1,标头的值XLLCORNER相应的调整。如果忽略lat指定。


参数:nodata
the NODATA_VALUE for the output. If NULL, the value is taken from the input grids.
NODATA_VALUE的输出。如果为NULL,值是从电网输入。


参数:myPredFunc
called to predict output using the object and newdata from the xfiles. Two arguments are passed to this function, the first is the value of object and the second is a data frame of the new predictor variables created for each row of data from your input maps. If NULL, the generic predict function is called for object.
所谓从object使用xfiles和newdata预测输出。两个参数传递给这个函数,第一个是价值的object,第二个是一个数据框创建的每一行数据输入图的新预测变量。如果为NULL,通用predict函数被称为object。


参数:...
passed to myPredFunc or predict.
传递myPredFunc或predict。


Details

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

The input maps are assumed to be Asciigrid maps with 6-line headers containing the following tags: NCOLS, NROWS, XLLCORNER, YLLCORNER,   CELLSIZE and NODATA_VALUE (case insensitive). The headers should be identical, a warning is issued if they are not. It is critical that NODATA_VALUE is the same on all input maps.
输入映射都被假定是Asciigrid图与6行头包含以下标签:NCOLS, NROWS, XLLCORNER, YLLCORNER,   CELLSIZE和NODATA_VALUE(不区分大小写)。标题应该是相同的,将发出警告,如果他们不。这是非常重要的,这NODATA_VALUE是相同的所有输入图上。

The function builds data frames from the input maps one row at a time and builds predictions using those data frames as newdata. Each row of the input maps is processed in sequence so that the entire maps are not stored in memory. The function works by opening all the input and reads one line (row) at a time from each. The output file(s) are created one line at time as the input maps are processed.
这个函数建立从输入图1以每次一行的数据框,并使用这些数据框作为newdata构建预测。没有存储在存储器中,从而使整个图,输入图的每一行的顺序处理。该功能的工作原理是打开所有的输入和在一个时间从每个读取一行(行)。的输出文件(s)是在时间创建一行输入映射处理。

Use AsciiGridImpute for objects builts with yai, otherwise use AsciiGridPredict. When AsciiGridPredict is used, the following rules apply. First, when myPredFunc is not null it is called with the arguments object, newdata, ... where the new data is the data frame built from the input maps, otherwise the generic predict function is called with these same arguments. When object and myPredFunc are both NULL a copy newdata used as the prediction. This is useful when lat, lon, rows, or cols are used in to subset the maps.
使用AsciiGridImpute的对象竣工图与yai,否则使用AsciiGridPredict。当AsciiGridPredict使用,适用以下规则。首先,当myPredFunc是不是null,则调用的参数object, newdata, ...新的数据的数据框从输入图,否则一般的predict函数调用这些相同的参数。当object和myPredFunc都是NULL副本newdata使用的预测。这是非常有用的,当lat, lon, rows,或cols是子集的映射。

The NODATA_VALUE is output for every NODATA_VALUE found on any grid cell on any one of the input maps (the predict function is not called for these grid cells). NODATA_VALUE is also output for any grid cell where the predict function returns an NA. If factors are used as X-variables in object, the levels found the map data are checked against those used in building the object. If new levels are found, the corresponding output map grid point is set to NODATA_VALUE; the predict function is not called for these cells as most predict functions will fail in these circumstances. Checking on factors depends on object containing a meaningful member named xlevels, as done objects model objects produced by lm.
NODATA_VALUE是为每一个输出NODATA_VALUE的任何一个上的的输入图(预测函数不被调用这些网格单元)上发现的任何网格单元。 NODATA_VALUE是输出为网格单元格中的预测功能返回一个NA。如果作为X-变量在object因素,各级检查发现的图数据,对那些用于建设object。如果发现一个新的水平,相应的输出映射网格点设置为NODATA_VALUE的预测功能不叫这些单元在这种情况下,因为大多数预测函数将失败。检查的因素取决于object包含一个有意义的成员xlevels做对象模型对象产生的lm。

Asciigrid maps do not contain character data, only numbers. The numbers in the maps are matched the xlevels by subscript (the first entry in a level corresponds to the numeric value 1 in the Asciigrid maps, the second to the number 2 and so on). Care must be taken by the user to insure that the coding scheme used in building the maps is identical to that used in building the object. See Value for information on how you can check the matching of these codes.
Asciigrid图不包含字符数据,只有数字。图中的号码相匹配的xlevels下标(在一个级别的第一个条目对应于数值1在Asciigrid映射,第二个数字2等)。必须小心,以确保用户的编码方案用于建设的图是相同的,用于建设object。价值的信息,你怎么可以检查这些代码的匹配。


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

An invisible list containing the following named elements:
invisible列表,其中包含以下元素:


参数:unexpectedNAs
A data frame listing the map row numbers and the number of NA values generated by the predict function for each row. If none are generated for a row the row is not reported, if none are generated for any rows, the data frame is NULL.
列出在图上的行数和NA的值所产生的每一行的预测功能的数目的数据框。如果没有生成一个行的行不是不报,如果没有产生的任何行,数据框是NULL。


参数:illegalLevels
A data frame listing levels found in the maps that were not found in the xlevels for the object. The row names are the illegal levels, the column names are the variable names, and the values are the number of grid cells where the illegal levels were found.
一个数据框房产的水平发现在图均未发现xlevels的object。行名称是非法的水平,列名的变量名,值是非法的水平,发现网格单元的数量。


参数:outputLegend
A data frame showing the relationship between levels in the output maps and those found in object. The row names are level index values, the column names are variable names, and the values are the levels. NULL if no factors are output.
一种数据框表示水平输出图和那些被发现在object之间的关系。行的名称是水平指数值,列名的变量名,值水平。 NULL,如果没有的因素是输出。


参数:inputLegend
A data frame showing the relationship between levels found in the input maps and those found in object. The row names are level index values (this function assumes they correspond to numeric values on the maps), the column names are variable names, and the values are the levels. NULL if no factors are input. This information is consistent with that in xlevels.
一个数据框水平之间的关系,发现在输入图和发现object。行的名称是水平指数值(此函数假定他们在图上的对应的数字值),列名的变量名,值水平。返回NULL,如果没有输入。此信息是一致的,在xlevels。


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



Nicholas L. Crookston <a href="mailto:ncrookston.fs@gmail.com">ncrookston.fs@gmail.com</a> <br>
Andrew O. Finley <a href="mailto:finleya@msu.edu">finleya@msu.edu</a>




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

yai, impute, and newtargets
yai,impute和newtargets


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



## These commands write new files to your working directory[#。这些命令写入新的文件到你的工作目录]

# Use the iris data[使用虹膜数据]
data(iris)

# Section 1: Imagine that the iris are planted in a planting bed.[第1部分:想象一下,虹膜被种植在种植床。]
# The following set of commands create Asciigrid map[下面的一组的命令创建Asciigrid的图]
# files for four attributes to illustrate the planting layout.[四个属性的文件来说明种植布局。]

# Change species from a character factor to numeric (the sp classes[改变物种从性格因素为数字(SP类]
# can not handle character data).[不能处理的字符数据)。]

sLen <- matrix(iris[,1],10,15)
sWid <- matrix(iris[,2],10,15)
pLen <- matrix(iris[,3],10,15)
pWid <- matrix(iris[,4],10,15)
spcd <- matrix(as.numeric(iris[,5]),10,15)

# Make maps of each variable.[使每个变量的图。]

header = c("NCOLS 15","NROWS 10","XLLCORNER 1","YLLCORNER 1",
           "CELLSIZE 1","NODATA_VALUE -9999")
cat(file="slen.txt",header,sep="\n")
cat(file="swid.txt",header,sep="\n")
cat(file="plen.txt",header,sep="\n")
cat(file="pwid.txt",header,sep="\n")
cat(file="spcd.txt",header,sep="\n")


write.table(sLen,file="slen.txt",append=TRUE,col.names=FALSE,
            row.names=FALSE)
write.table(sWid,file="swid.txt",append=TRUE,col.names=FALSE,
            row.names=FALSE)
write.table(pLen,file="plen.txt",append=TRUE,col.names=FALSE,
            row.names=FALSE)
write.table(pWid,file="pwid.txt",append=TRUE,col.names=FALSE,
            row.names=FALSE)
write.table(spcd,file="spcd.txt",append=TRUE,col.names=FALSE,
            row.names=FALSE)

# Section 2: Create functions to predict species[第2部分:创建功能来预测物种]

# set the random number seed so that example results are consistant[设置随机数种子,这样的例子的结果是consistant]
# normally, leave out this command[通常情况下,离开了这个命令]
set.seed(12345)

# sample the data[采样数据]
refs <- sample(rownames(iris),50)
y <- data.frame(Species=iris[refs,5],row.names=rownames(iris[refs,]))

# build a yai imputation for the reference data.[建立一个合艾插补的参考数据。]
rfNN <- yai(x=iris[refs,1:4],y=y,method="randomForest")

# make lists of input and output map files.[使输入和输出映射文件的列表。]

xfiles <- list(Sepal.Length="slen.txt",Sepal.Width="swid.txt",
               Petal.Length="plen.txt",Petal.Width="pwid.txt")
outfiles1 <- list(distance="dist.txt",Species="spOutrfNN.txt",
                  useid="useindx.txt")

# map the imputation-based predictions for the input maps[映射的输入图的归集为基础的预测]
AsciiGridImpute(rfNN,xfiles,outfiles1,ancillaryData=iris)

# demonstrate the use of useid:[展示使用useid:]
spViaUse <- read.table("useindx.txt",skip=6)
for (col in colnames(spViaUse)) spViaUse[,col]=as.character(y$Species[spViaUse[,col]])

# demonstrate how to use factors:[演示如何使用因素:]
spViaLevels  <- read.table("spOutrfNN.txt",skip=6)
for (col in colnames(spViaLevels)) spViaLevels[,col]=levels(y$Species)[spViaLevels[,col]]

identical(spViaLevels,spViaUse)


# build a randomForest predictor[建立一个randomForest预测]
rf <- randomForest(x=iris[refs,1:4],y=iris[refs,5])

# map the predictions for the input maps[映射预测的输入图]
outfiles2 <- list(predict="spOutrf.txt")
AsciiGridPredict(rf,xfiles,outfiles2,xtypes=NULL,rows=NULL)

# read the asciigrids and get them ready to plot[阅读的asciigrids,并让他们准备绘制]
spOrig <- t(as.matrix(read.table("spcd.txt",skip=6)))
sprfNN <- t(as.matrix(read.table("spOutrfNN.txt",skip=6)))
sprf <- t(as.matrix(read.table("spOutrf.txt",skip=6)))
dist <- t(as.matrix(read.table("dist.txt",skip=6)))

par(mfcol=c(2,2))
image(spOrig,main="Original",axes=FALSE,useRaster=TRUE)
image(sprfNN,main="Using Predict",axes=FALSE,useRaster=TRUE)
image(sprf,main="Using Impute",axes=FALSE,useRaster=TRUE)
image(dist,main="Neighbor Distances",axes=FALSE,useRaster=TRUE)


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 07:25 , Processed in 0.027119 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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