Learn R Programming

ImpShrinkage (version 1.0.0)

simdata: Simulation data

Description

This function generates a toy example. The error term, \(\varepsilon\), and the design matrix, \(X\), are simulated from standard normal distributions, \(\mathcal{N}(0,1)\), using the rnorm function. Given the true parameter vector, \(\beta\), the response vector, \(y\), is calculated as $$y = X \beta + \varepsilon.$$

Usage

simdata(n, p, beta, seed = NULL)

Value

A list containing the following components:

X

a matrix of dimensions n x p.

y

a numeric vector of length n.

Arguments

n

Number of observations.

p

Number of variables.

beta

Regression parameter.

seed

(Optional) The random seed for reproducibility. Default is NULL.

References

Saleh, A. K. Md. Ehsanes. (2006). Theory of Preliminary Test and Stein‐Type Estimation With Applications, Wiley.

Examples

Run this code
simulated_data <- simdata(n = 100, p = 5, beta = c(2, 1, 3, 0, 5))
X <- simulated_data$X
y <- simulated_data$y
X
y

Run the code above in your browser using DataLab