Skip to content
Snippets Groups Projects
Commit 347ca06a authored by wbonat's avatar wbonat
Browse files

Fix minor errors

parent 582dbc12
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
#' @param scope a vector specyfing the covariate to be tested.
#' @param interaction Maximum number of covariates interacting.
#' @param penalty penalty term (default = 2).
#' @param n_max Maximum number of models to be fitted.
#' @return The selected model.
#' @export
......@@ -18,7 +19,6 @@ mc_fast_forward <- function(object, scope, interaction = 1,
for (i in 2:interaction) {
int_terms[[c(i-1)]] <- combn(length(scope), i)
}
}
fun_temp <- function(int_terms) {
output <- c()
for(i in 1:dim(int_terms)[2]) {
......@@ -26,8 +26,10 @@ mc_fast_forward <- function(object, scope, interaction = 1,
}
return(output)
}
scope <- c(scope, do.call(c, lapply(int_terms, fun_temp)))
scope <- do.call(c, lapply(int_terms, fun_temp))
}
for (i in 1:n_max) {
if(length(scope) == 0) break
sic <- mc_sic(object = object, scope = scope,
data = data, response = 1)
if (all(sic$SIC < 0)) break
......@@ -35,11 +37,13 @@ mc_fast_forward <- function(object, scope, interaction = 1,
cov_enter <- scope[as.numeric(rownames(sic[which.max(sic$SIC),]))]
next_cov <- paste("~. +", cov_enter)
new_formula <- update.formula(object$linear_pred[[1]], next_cov)
temp_models <- mcglm(c(new_formula), matrix_pred = matrix_pred,
temp_models <- mcglm(c(new_formula),
matrix_pred = object$matrix_pred,
link = object$link, variance = object$variance,
covariance = object$covariance, data = data)
object <- temp_models
scope <- scope[-cov_new]
cat(paste("Iteration", i), "\n")
}
return(object)
}
......@@ -15,6 +15,8 @@ mc_fast_forward(object, scope, interaction = 1, penalty = 2, n_max = 10)
\item{interaction}{Maximum number of covariates interacting.}
\item{penalty}{penalty term (default = 2).}
\item{n_max}{Maximum number of models to be fitted.}
}
\value{
The selected model.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment