split: Spliting Data in Trainset and Test Set.

Description Usage Arguments Value Examples

View source: R/Split.R

Description

Split Splits Data in Trainset and Test Set

Usage

1
split(X, y, Trainset_Proportion)

Arguments

X

A N X p matrix of covariates

y

A N X 1 vector of responses

Trainset_Proportion

(A real no between 0 and 1 both exclusive)

Value

Train_X A [N * Trainset_Proportion] X p matrix of covariates.

Train_Y A [N * Trainset_Proportion] X 1 vector of responses.

Test_X A [N * (1 - Trainset_Proportion)] X p matrix of covariates.

Test_Y A [N * (1 - Trainset_Proportion)] X 1 vector of responses.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(250)
N <- 500 # Total no of observations.
x1 <- seq(-1, 1, length.out = N) # Generating Covariate 1
x2 <- rnorm(N, 0, 1) # Genearting Covariate 2
# Generating the design matrix of interest
X <- as.matrix(cbind(rep(1,N), x1, x2))
# Fixing values of regression coeffiecients theta
theta <- c(-.5, 3.3, 2)
# Define a vector with probabilities of success p using the probit link
p <- pnorm(X %*% theta)
# Generate binary response data y with success probabilit p
y <- rbinom(N, 1, p)
split(X, y, Trainset_Proportion = .7)

zovialpapai/PolyGibbs documentation built on Dec. 9, 2019, 6:52 a.m.