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

R语言 SpatioTemporal包 calc.tF.times.mat()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 13:02:08 | 显示全部楼层 |阅读模式
calc.tF.times.mat(SpatioTemporal)
calc.tF.times.mat()所属R语言包:SpatioTemporal

                                         Compute Matrix Productes Involving the Smooth Trends
                                         涉及的计算矩阵Productes的平滑趋势

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

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

Computes the matrix products between a sparse matrix F containing the temporal basis functions and other matrices.
计算产品之间的稀疏矩阵的矩阵F的时间的基础功能和其他矩阵。


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


calc.tF.times.mat(X, F, loc.ind, n.x = dim(X)[2],
     n.loc = max(loc.ind))

calc.tF.mat.F(mat, F, loc.ind, n.blocks = 1, block.sizes =
     rep(dim(mat)[1]/n.blocks, n.blocks), n.loc = max(loc.ind))

calc.F.times.X(LUR, F, loc.ind)



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

参数:X
A vector or matrix.  
一个向量或矩阵。


参数:F
A (number of obs.) - by - (number of temporal trends) matrix containing the temporal trends. Usually mesa.data.model$F, where mesa.data.model is obtained from create.data.model.  
A(数OBS) -   - (时间趋势)矩阵的时间趋势。通常是mesa.data.model$F,mesa.data.model是从create.data.model。


参数:loc.ind
A vector indicating which location each row in F corresponds to, usually <br> mesa.data.model$obs$idx.  
一个向量,表示哪个位置中的每一行F对应,以,通常<BR>的mesa.data.model$obs$idx。


参数:n.loc
Number of locations.  
的位置数目。


参数:n.x
Number of columns in X, defaults correctly if X is a matrix.  
数列在正确的话X,默认X是一个矩阵。


参数:mat
A block diagonal, square matrix.  
块对角方阵。


参数:n.blocks
Number of diagonal blocks in mat. Defaults to 1 (i.e. a full matrix) if not given.  
数的对角线块mat。如果没有给出,默认为1(即一个完整的矩阵)。


参数:block.sizes
A vector of length n.blocks with the size of each of the diagonal blocks. If not given it will assume equal size blocks.  
的向量的长度n.blocks与每个对角块的大小。如果没有给它承担同等大小的块。


参数:LUR
A list of matrices, usually mesa.data.model$X. Each matrix in the list should have the same number of rows, but the number of columns may vary.  
矩阵,列表通常是mesa.data.model$X。在列表中的每个矩阵应具有相同的行数,但可能会发生变化的列数。


Details

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

calc.tF.times.mat computes F times a matrix. calc.tF.mat.F computes the quadratic form F' *  mat * F where mat is a block diagonal, square matrix. And calc.F.times.X computes F times a block matrix represented as a list of matrices.
calc.tF.times.mat计算F次矩阵。 calc.tF.mat.F计算二次型Fmat*F其中mat是块对角,方形矩阵。和calc.F.times.X计算F分块矩阵表示为矩阵的列表。

See the examples for details.
的详细信息,请参阅的例子。


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

Returns a matrix with the result of the relevant matrix computation(s).
返回一个矩阵的相关矩阵计算()的结果。


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



Johan Lindstr枚m and Adam Szpiro




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

Block matrices can be created by make.sigma.B,  make.sigma.B.full, and <br> make.sigma.nu.
分块矩阵可以创建make.sigma.B,make.sigma.B.full,和<br> make.sigma.nu。

Other block matrix functions makeCholBlock,  block.mult, calc.iS.X,  dot.prod, and <br> sumLogDiag.
其他分块矩阵的功能makeCholBlock,block.mult,calc.iS.X,dot.prod,和<br>sumLogDiag。

This function is called by loglike.
此功能被称为loglike。


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


##This starts with a couple of simple examples, more elaborate examples[#该开始用一些简单的例子,更详细的例子]
##with real data can be found further down.[#与真实的数据可以发现进一步下降。]

##create a trend[#创建一个趋势]
trend <- cbind(1:5,sin(1:5))
##an index of locations[#索引的位置]
idx <- c(rep(1:3,3),1:2,2:3)
##a list of time points for each location/observation[#为每个位置/观察的时间点的列表]
T <- c(rep(1:3,each=3),4,4,5,5)
##create a random observations matrix[#创建一个随机观察矩阵]
obs <- rnorm(length(T))

##expand the F matrix to match the locations/times in idx/T.[扩大的F矩阵IDX / T相匹配的地点/时间]
F <- trend[T,]

##compute tF %*% obs[TF%*%#计算OBS]
tFobs <- calc.tF.times.mat(obs, F, idx, n.x=1)

##alternatievly this can be computed as observtions for each location[#alternatievly这可以被计算为observtions为每个位置]
##multiplied by the trend function at the corresponding time points.[#乘以在相应的时间点的趋势函数。]
tFobs.alt <- double(length(tFobs))
for(j in 1:dim(trend)[2]){
  for(i in 1:max(idx)){
    tFobs.alt[i+(j-1)*max(idx)] <- sum(obs[idx==i]*trend[T[idx==i],j])
  }
}
##compare results[#比较结果]
print( cbind(tFobs,tFobs.alt) )

##create a covariance matrix for locations and each of [#创建一个协方差矩阵的位置和每个]
C <- make.sigma.nu(1, 0, 1, c(3,3,3,2,2), idx,
                   as.matrix(dist(1:max(idx))) )
##compute F' %*% C %*% F[计算F%*%C%*%F]
tFmatF <- calc.tF.mat.F(C, F, idx, block.sizes = c(3,3,3,2,2),
                        n.blocks = 5)
##which is equivalent of[#这是相当于]
tFmatF.alt <- calc.tF.times.mat(t(calc.tF.times.mat(C, F, idx)), F, idx)

print(tFmatF-tFmatF.alt)


##some examples using the mesa.data[#的一些例子,使用mesa.data]
data(mesa.data.model)

##Some information about the size(s) of the model.[#一些有关的大小(S)的模式。]
dim <- loglike.dim(mesa.data.model)

##compute F' %*% obs[F%*%#计算OBS]
tFobs <- calc.tF.times.mat(mesa.data.model$obs$obs, mesa.data.model$F,
                           mesa.data.model$obs$idx,n.x=1)

##The resulting matrix contains 75 elements (3 temporal trend at 25[#基体中含有75种元素(3时间的趋势,在25]
##sites). The first element are the observations at the first site[#站点)。第一个元素是第一个站点的观测]
##multiplied by the constant temporal trend, e.g.[#乘以常数的时间的趋势,例如]
print(tFobs[1])
print( sum(mesa.data.model$obs$obs[mesa.data.model$obs$idx==1]) )


##The 27:th element are the observations at the second site (27-25)[#27:个元素是在第二个站点的意见(27-25)]
##multiplied by the first temporal trend (second element in F)[#乘以所述第一时间的趋势(在F的第二个元素)]
print(tFobs[dim$n+2])
print(sum(mesa.data.model$obs$obs[mesa.data.model$obs$idx==2] *
          mesa.data.model$F[mesa.data.model$obs$idx==2,2]))


##compute F %*% X[#计算F%*%X]
FX <- calc.F.times.X(mesa.data.model$X, mesa.data.model$F,
                     mesa.data.model$obs$idx)
##The resulting matrix is[#得到的矩阵是]
##(number of time points) - by - (number of land use covariates)[#(时间点的数量) - 由 - (土地使用协变量的数量)]
##where the number of land use covariates are computed over all the[#土地利用协变量的数量在所有的计算]
##two + intercept temporal trends.[#2 +拦截的时间趋势。]
##Each column contains the temporal trend for the observations[#每列中包含的时间趋势的观察]
##multiplied by the corresponding LUR-covariate[#由相应的LUR-协变量乘以]
par(mfrow=c(3,1))
plot(FX[,2])
points(mesa.data.model$X[[1]][mesa.data.model$obs$idx,2] *
       mesa.data.model$F[,1],col=2,pch=3)

plot(FX[,dim$p[1]+1])
points(mesa.data.model$X[[2]][mesa.data.model$obs$idx,1] *
       mesa.data.model$F[,2],col=2,pch=3)

plot(FX[,dim$p[1]+dim$p[2]+2])
points(mesa.data.model$X[[3]][mesa.data.model$obs$idx,2] *
       mesa.data.model$F[,3],col=2,pch=3)

##If the regression parameters, alpha, are known (or estimated)[#如果回归参数,α,已知(或估计)]
##The intercept part of the model is given by FX %*% alpha[#截距模型的一部分,是由FX%*%的α-]


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-11 06:24 , Processed in 0.027369 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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