genCorrelatedData(rockchalk)
genCorrelatedData()所属R语言包:rockchalk
Generates a data frame (x1,x2,y) with user-specified correlation between x1 and x2
与用户指定的x1和x2之间的相关性,生成一个数据框的(X1,X2,y)的
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The vector (x1,x2) is drawn from a multivariate normal distribution in which the expected value (mean) is the parameter means and the var/covar matrix is built from the assumed standard deviations sds and the correlation between x1 and x2 (rho). It is also necessary to specify the standard deviation of the error term (stde) and the coefficients of the regression equation (beta). The y (output) variable is created according to the equation y = b1 + b2 * x1 + b3 * x2 + b4 * x1 * x2 + e
来自多元正态分布的预期值(平均)参数means和的var / COVAR矩阵的构建假定的标准偏差sds和向量(X1,X2) x1和x2之间的相关性(rho)。也有必要以指定的误差项的标准偏差(stde)和系数的回归方程(beta)。 Y(输出)变量被创建,根据方程为y = B1 + B2 * X1 + B3 * X2 + B4 * X1 * X2 + E
用法----------Usage----------
genCorrelatedData(N = 100, means = c(50, 50),
sds = c(10, 10), rho = 0, stde = 1,
beta = c(0, 0.2, 0.2, 0))
参数----------Arguments----------
参数:N
Number of cases desired
需要的情况下,数
参数:means
2-vector of means for x1 and x2
2 - 向量x1和x2的装置,用于
参数:sds
2-vector of standard deviations for x1 and x2
2-x1和x2的矢量的标准偏差
参数:rho
Correlation coefficient for x1 and x2
x1和x2的相关系数为
参数:stde
standard deviation of the error term in the data generating equation
的数据的生成方程中的误差项的标准偏差
参数:beta
beta vector of at most 4 coefficients for intercept, slopes, and interaction
测试向量的拦截,坡地,互动最多4个系数
实例----------Examples----------
## 1000 observations of uncorrelated x1 and x2 with no[没有不相关的x1和x2 1000个观测]
## interaction between x1 and x2[#x1和x2之间的相互作用]
dat <- genCorrelatedData(N=1000, rho=0, beta=c(1, 1.0, -1.1, 0.0))
mcGraph1(dat$x1, dat$x2, dat$y, theta=20, phi=8, ticktype="detailed", nticks=10)
m1 <- lm(y ~ x1 + x2, data = dat)
plotPlane(m1, plotx1 = "x1", plotx2 = "x2")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|