Description Usage Arguments Value Examples
Data generator under the framework of generalized linear model
1 2 3 4 5 6 7 8 9 | glmDataGen(
n,
d,
family = c("gaussian", "binomial", "multinomial"),
trueb0,
trueb,
s = 0.5,
seed = NULL
)
|
n |
integer. The number of observations. |
d |
integer. The number of predictors. |
family |
string. The value of starting inertia weight in PSO updating procedure. The default is 1.2. |
trueb0 |
double. |
trueb |
vector. |
s |
double. |
seed |
integer. The random seed. |
An List.
x the matrix of the predictors.
y the vector of the response variable.
For family = 'multinomial'
, the output is a matrix of size $n\times$#(categories).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # Intercept
trueb0 <- 1
# Regression Coefficients (the first 3 are active)
trueact <- c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0)
trueb <- runif(10, -1, 1)*10
trueb[which(trueact == 0)] <- 0
# Generate data of continuous response
df <- glmDataGen(n = 500, d = 10, family = "gaussian", trueb0, trueb, s = 0.5, seed = 1)
# Generate data of binary response
dfb <- glmDataGen(n = 500, d = 10, family = "binomial", trueb0, trueb, seed = 1)
# Generate data of multi-categorical response (not run)
#
# Intercepts of the three log-linear models
# trueb0 <- c(1, 1, 1)
# Regression Coefficients of the three log-linear models
# trueact <- cbind(
# c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0),
# c(0, 0, 0, 1, 1, 1, 1, 0, 0, 0),
# c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0)
# )
# trueb <- matrix(runif(10*3, -1, 1)*10, 10, 3)
# for (m in 1:3) { trueb[which(trueact[,m] == 0),m] <- 0 }
#
# Generate data. The response y is a matrix of 3 columns.
# dfm <- glmDataGen(n = 500, d = 10, family = "multinomial", trueb0, trueb, seed = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.