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

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

[复制链接]
发表于 2012-9-30 09:28:34 | 显示全部楼层 |阅读模式
simFunction(simsem)
simFunction()所属R语言包:simsem

                                         Create function object
                                         创建函数对象

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

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

This function is a constrctor of a function object which can be used for data transformation. The aim of the object is to create a function but will use later in a simulation study. For example, set up a mean centering for a dataset for using in a simulation.
这个函数是一个对象,可以用于数据转换的函数constrctor。对象的目的是创建一个函数,但在以后使用了仿真研究。例如,设立中心平均在模拟中使用的数据集。


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


simFunction(fun, ...)



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

参数:fun
The desired function that will be used for data transformation  
所希望的功能,将被用于数据转换


参数:...
Additional arguments of the desired function.  
其他参数所需的功能。


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

SimFunction that saves the function to use later in the simulation (within simResult)
SimFunction,节省了使用功能,在模拟(simResult)


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



Sunthud Pornprasertmanit (University of Kansas; <a href="mailto:psunthud@ku.edu">psunthud@ku.edu</a>)




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

SimResult for how to use the simFunction in a simulation study
SimResultsimFunction的模拟研究如何使用


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



n65 <- simNorm(0.6, 0.05)
u35 <- simUnif(0.3, 0.5)
u68 <- simUnif(0.6, 0.8)
u2 <- simUnif(-0.2, 0.2)
n1 <- simNorm(0, 0.1)

loading <- matrix(0, 9, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 3] <- NA
loading.start <- matrix("", 9, 3)
loading.start[1:3, 1] <- 0.7
loading.start[4:6, 2] <- 0.7
loading.start[7:9, 3] <- "u68"
LY <- simMatrix(loading, loading.start)

RTE <- symMatrix(diag(9))

factor.cor <- diag(3)
factor.cor[1, 2] <- factor.cor[2, 1] <- NA
RPS <- symMatrix(factor.cor, 0.5)

path <- matrix(0, 3, 3)
path[3, 1:2] <- NA
path.start <- matrix(0, 3, 3)
path.start[3, 1] <- "n65"
path.start[3, 2] <- "u35"
BE <- simMatrix(path, path.start)

datGen <- simSetSEM(BE=BE, LY=LY, RPS=RPS, RTE=RTE)

loading.trivial <- matrix(NA, 9, 3)
loading.trivial[is.na(loading)] <- 0
LY.trivial <- simMatrix(loading.trivial, "u2")

error.cor.trivial <- matrix(NA, 9, 9)
diag(error.cor.trivial) <- 0
RTE.trivial <- symMatrix(error.cor.trivial, "n1")

misGen <- simMisspecSEM(LY = LY.trivial, RTE = RTE.trivial)

Data.Mis <- simData(datGen, 300, misspec=misGen)

loading <- matrix(0, 12, 4)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 4] <- NA
loading[10:12, 3] <- NA

path <- matrix(0, 4, 4)
path[4, 1:3] <- NA

analysis <- simParamSEM(BE=path, LY=loading)

Model <- simModel(analysis)

# Find the products of indicators[查找产品指标]
newFUN <- function(data, var1, var2, namesProd) {
        prod <- data[,var1] * data[,var2]
        colnames(prod) <- namesProd
        return(data.frame(data, prod))
}

fun <- simFunction(newFUN, var1=paste("y", 1:3, sep=""), var2=paste("y", 4:6, sep=""), namesProd=paste("y", 10:12, sep=""))

# Real simulation will need more than just 10 replications[真实模拟将需要更多的不仅仅是10重复]
Output <- simResult(10, Data.Mis, Model, objFunction=fun)
summary(Output)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-25 04:08 , Processed in 0.023923 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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