knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
jeksterslabRdata
is a collection of functions that I find useful in studying data generation and sampling.
You can install the released version of jeksterslabRdata
from GitHub with:
library(devtools) install_github("jeksterslabds/jeksterslabRdata")
See GitHub Pages for package documentation.
library(jeksterslabRdata)
univ()
Generates an n x 1
univariate data vector
or a list of n x 1
univariate data vectors of length R
.
The default data generating function
is the normal distribution.
Run the function.
x <- univ(n = 100, rFUN = rnorm, mean = 100, sd = sqrt(225))
Explore the output.
str(x, list.len = 6) hist(x, main = expression(italic(N)(list(mu == 100, sigma^2 == 225))))
Run the function.
xstar <- univ(n = 100, rFUN = rnorm, mean = 100, sd = sqrt(225), R = 100)
Explore the output.
str(xstar, list.len = 6)
mvn()
Generates an n x k
multivariate data matrix
or a list of n x k
multivariate data matrices of length R
from the multivariate normal distribution.
This function is a wrapper around MASS::mvrnorm()
.
Set mu
and Sigma
.
mu <- c(100, 100, 100) Sigma <- matrix( data = c(225, 112.50, 56.25, 112.5, 225, 112.5, 56.25, 112.50, 225), ncol = 3 )
Run the function.
X <- mvn(n = 100, mu = mu, Sigma = Sigma)
Explore the output.
str(X) pairs(X) colMeans(X) cov(X) cor(X)
Run the function.
Xstar <- mvn(n = 100, mu = mu, Sigma = Sigma, R = 100)
Explore the output.
str(Xstar, list.len = 6)
mvnram()
Generates an n x k
multivariate data matrix
or a list of n x k
multivariate data matrices of length R
from the multivariate normal distribution.
The model-implied matrices used to generate data
is derived from the Reticular Action Model (RAM) Matrices.
Set matrices.
mu <- c(100, 100, 100) A <- matrix( data = c(0, sqrt(0.26), 0, 0, 0, sqrt(0.26), 0, 0, 0), ncol = 3 ) S <- diag(c(225, 166.5, 116.5)) F <- I <- diag(3)
Run the function.
X <- mvnram(n = 100, mu = mu, A = A, S = S, F = F, I = I)
Explore the output.
str(X) pairs(X) colMeans(X) cov(X) cor(X)
Run the function.
Xstar <- mvnram(n = 100, mu = mu, A = A, S = S, F = F, I = I, R = 100)
Explore the output.
str(Xstar, list.len = 6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.