Learn R Programming

MXM (version 0.8.7)

reg.fit: Regression modelling

Description

Generic regression modelling function

Usage

reg.fit(y, dataset, event = NULL, reps = NULL, group = NULL, slopes = FALSE, 
reml = FALSE, model = NULL, robust = FALSE, xnew = NULL)

Arguments

y
The target (dependent) variable. It can be a numerical variable, factor, ordinal factor, percentages, matrix, or time to event. If the values are proportions or percentages, i.e. strictly within 0 and 1 they are mapped into R using log( target/(1 - targ
dataset
The indendent variable(s). It can be a vector, a matrix or a dataframe with continuous only variables, a data frame with mixed or only categorical variables.
event
This is NULL unless you have time to event data (survival regression).
reps
This is NULL unless you have time measurements (longitudinal data).
group
This is NULL unless you have grouped (or clustered) data or longitudinal data (is the latter case the arugment reps is required).
slopes
This is for the longitudinal data only, TRUE or FALSE. Should random slopes be added or not?
reml
This is for the longitudinal or grouped data only, TRUE or FALSE. If TRUE, REML will be used, otherwise ML will be used.
model
The type of model you want to use. It can be specified by the user or left NULL, if other correct arguments have been passed. Poissible values (apart from NULL) are: "gaussian" (default), "binary", "multinomial", "poisson", "ordinal", "Cox", "weibull",
robust
A boolean variable. If TRUE robust models will be returned. Currently this is supported by models "gaussian", "poisson" and "binary".
xnew
If you have new data whose target values you want to predict put it here, otherwise leave it blank.

Value

  • A list including:
  • modThe fitted model.
  • predIf you have new data the predicted values of the target (dependent) variable.

Details

This is a generic regression function, which offers prediction as well. It is important that you pass the arguments with their names, for example if you have time to event data, write "event = ..." and not just put your event variable. This will avoid confusion.

References

Almost the same as in CondIndTests.

See Also

ridge.reg, model

Examples

Run this code
#simulate a dataset with continuous data
dataset <- matrix(runif(100 * 10, 1, 100), nrow = 100 ) 
#the target feature is the last column of the dataset as a vector
target <- dataset[, 1]
dataset <- dataset[, -1]
a <- reg.fit(target, dataset)

Run the code above in your browser using DataLab