knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(jeksterslabRdata)

Documentation

See fit() for more details.

Examples

univ()

Normal Distribution

Generate Data
xstar <- univ(n = 100, rFUN = rnorm, mean = 100, sd = sqrt(225), R = 100)
Fit the mean() Function Using fit()

Run the function.

thetahatstar <- fit(Xstar = xstar, fitFUN = mean, rbind = TRUE)

Explore the output.

str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(mu)),
  xlab = expression(hat(mu))
)
Fit the var() Function Using fit()

Run the function.

thetahatstar <- fit(Xstar = xstar, fitFUN = var, rbind = TRUE)

Explore the output.

str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(sigma)^2),
  xlab = expression(hat(sigma)^2)
)

Bernoulli Distribution

Generate Data
xstar <- univ(n = 100, rFUN = rbinom, size = 1, prob = 0.50, R = 100)
Fit the mean() Function Using fit()

Run the function.

thetahatstar <- fit(Xstar = xstar, fitFUN = mean, rbind = TRUE)

Explore the output.

str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(mu)),
  xlab = expression(hat(mu))
)
Fit the var() Function Using fit()

Run the function.

thetahatstar <- fit(Xstar = xstar, fitFUN = var, rbind = TRUE)

Explore the output.

str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(sigma)^2),
  xlab = expression(hat(sigma)^2)
)

Binomial Distribution

Generate Data
xstar <- univ(n = 100, rFUN = rbinom, size = 40, prob = 0.50, R = 100)
Fit the mean() Function Using fit()

Run the function.

thetahatstar <- fit(Xstar = xstar, fitFUN = mean, rbind = TRUE)

Explore the output.

str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(mu)),
  xlab = expression(hat(mu))
)
Fit the var() Function Using fit()

Run the function.

thetahatstar <- fit(Xstar = xstar, fitFUN = var, rbind = TRUE)

Explore the output.

str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(sigma)^2),
  xlab = expression(hat(sigma)^2)
)

mvn()

Generate Data
Sigma <- matrix(
  data = c(1, 0.50, 0.50, 1),
  ncol = 2
)
Xstar <- mvn(n = 100, Sigma = Sigma, R = 100)
Fit a custom cov() Function Using fit()

Run the function.

foo <- function(X) {
  as.vector(cov(X))
}
thetahatstar <- fit(Xstar = Xstar, fitFUN = foo, rbind = TRUE)

Explore the output.

thetahatstar <- thetahatstar[, 2]
str(thetahatstar)
hist(thetahatstar,
  main = expression("Sampling distribution of" ~ hat(rho)),
  xlab = expression(hat(rho))
)


jeksterslabds/jeksterslabRdata documentation built on July 24, 2020, 5:49 a.m.