Regression Model Simulation

Description

Simulates regression models.

Usage

1
2
3
4
5
regSim(model = "LM3", n = 100, ...)

LM3(n = 100, seed = 4711)
LOGIT3(n = 100, seed = 4711)
GAM3(n = 100, seed = 4711)

Arguments

model

a character string defining the function name from which the regression model will be simulated.

n

an integer value setting the length, i.e. the number of records of the output series, an integer value. By default n=100.

seed

an integer value, the recommended way to specify seeds for random number generation.

...

arguments to be passed to the underlying function specified by the model argument.

Details

The function regSim allows to simulate from various regression models defined by one of the three example functions LM3, LOGIT3, GAM3 or by a user specified function.

The examples are defined in the following way:

# LM3:
> y = 0.75 * x1 + 0.25 * x2 - 0.5 * x3 + 0.1 * eps

# LOGIT3:
> y = 1 / (1 + exp(- 0.75 * x1 + 0.25 * x2 - 0.5 * x3 + eps))

# GAM3:
> y = scale(scale(sin(2 * pi * x1)) + scale(exp(x2)) + scale(x3))
> y = y + 0.1 * rnorm(n, sd = sd(y))

"LM3" models a liner regression model, "LOGIT3" a generalized linear regression model expressed by a logit model, and "GAM" an additive model. x1, x2, x3, and eps are random normal deviates of length n.

The model function should return an rectangular series defined as an object of class data.frame, timeSeries or mts which can be accepted from the parameter estimation functions regFit and gregFit.

Value

The function garchSim returns an object of the same class as returned by the underlying function match.fun(model). These may be objects of class data.frame, timeSeries or mts.

Note

This function is still under development. For the future we plan, that the function regSim will be able to generate general regression models.

Author(s)

Diethelm Wuertz for the Rmetrics R-port.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## LM2 -
   # Data for a user defined linear regression model:
   LM2 = function(n){
     x = rnorm(n)
     y = rnorm(n)
     eps = 0.1 * rnorm(n)
     z = 0.5 + 0.75 * x + 0.25 * y + eps
     data.frame(Z = z, X = x, Y = y)
   }
   for (FUN in c("LM2", "LM3")) {
     cat(FUN, ":\n", sep = "")
     print(regSim(model = FUN, n = 10))
   }