simulate_data: simulate_data

Description Usage Arguments Details Value Examples

View source: R/simulate_data.R

Description

function to generate simulation data for test

Usage

1
2
3
4
5
6
7
8
9
simulate_data(
  datasize1,
  datasize2,
  error_range,
  data_range,
  offsets_range,
  weights_range,
  coefficients
)

Arguments

datasize1

a integer represents the amounts of every variables .

datasize2

a integer represents the numbers of variables.

error_range

the range of errors of outcomes. This should be NULL or a numeric vector of size datasize1

data_range

a datasize2*2 matrix: every row represents the range of every variable.

offsets_range

the range of expected offsets. This should be NULL or a numeric vector of size datasize1.

weights_range

the range of expected weights. This should be NULL or a numeric vector of size datasize1.

coefficients

a numeric vector with length datasize1: the simulated coefficient for every variable.

Details

you can use this function to create random datasets for testing.

Value

'simulate' returns a dataframe of results containing the following components:

V1: the simulated Outcome. It should be a numeric vector with length of datasize1

V2, V3,...: the simulated Predictors. It should be a numeric vector with length of datasize1

(weights): If not NULL, the simulated weights. It should be a numeric vector with length of datasize1

(offsets): If not NULL, the simulated offsets. It should be a numeric vector with length of datasize1

Examples

1
2
3
4
5
data_range = matrix(c(0,0,0,1,1,1),3,2)
offsets_range = c(0,1)
weights_range = c(0,1)
coefficients = c(1,2,3)
data = simulate_data(10, 3, error_range= c(0,1), data_range, offsets_range, weights_range,coefficients)

lxfjwj/lmpackage documentation built on Dec. 21, 2021, 12:46 p.m.