Skip to content

Commit

Permalink
reset github and fix bug bwselect
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbh committed Jun 29, 2017
1 parent 2eacc47 commit e1b0581
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 125 deletions.
Binary file modified .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: mgm
Type: Package
Title: Estimating Time-Varying k-Order Mixed Graphical Models
Version: 1.2-0
Date: 2017-05-26
Version: 1.2-1
Date: 2017-06-20
Author: Jonas Haslbeck
Maintainer: Jonas Haslbeck <jonashaslbeck@gmail.com>
Description: Estimation of k-Order time-varying Mixed Graphical Models and mixed VAR(p) models via elastic-net regularized neighborhood regression.
Expand All @@ -11,4 +11,4 @@ BugReports: https://github.com/jmbh/mgm/issues
License: GPL (>= 2)
Imports: matrixcalc, glmnet, stringr, Hmisc
LazyData: true
Packaged: 2017-05-25 19:13:23 UTC; jo
Packaged: 2017-06-20 10:13:23 CET; jo
3 changes: 1 addition & 2 deletions R/bwSelect.R
Expand Up @@ -44,8 +44,7 @@ bwSelect <- function(data,

if(is.null(args$saveData)) args$saveData <- FALSE

if(modeltype == 'mgm') if(is.null(args$overparameterize)) args$overparameterize <- TRUE
if(modeltype == 'mgm') if(is.null(args$overparameterize)) args$overparameterize <- FALSE
if(is.null(args$overparameterize)) args$overparameterize <- TRUE


# ----- Compute Aux Variables -----
Expand Down
9 changes: 7 additions & 2 deletions R/lagData.R
Expand Up @@ -75,12 +75,17 @@ lagData <- function(data, lags, consec = NULL) {


# ---------- Output ----------

outlist <- list()
outlist$data_response <- data_response
outlist$l_data_lags <- l_data_lags

if(!is.null(consec)) outlist$included <- v_check
if(!is.null(consec)) {
outlist$included <- v_check
} else {
outlist$included <- rep(TRUE, n)
outlist$included[lags_ext] <- FALSE
}


return(outlist)
Expand Down
3 changes: 3 additions & 0 deletions R/mgm.R
Expand Up @@ -258,6 +258,7 @@ mgm <- function(data, # n x p data matrix
level = level[-v],
labels = colnames(data)[-v],
d = d)

X <- X_over
} else {
X <- X_standard
Expand Down Expand Up @@ -682,13 +683,15 @@ mgm <- function(data, # n x p data matrix

# if(sum(pair == c(1,3))==2) browser()


int_sign <- getSign(l_w_ind,
l_w_par,
type,
set_signdefined,
overparameterize,
ord)


} else {
int_sign <- 0 # if not defined (set_signdefined): 0
}
Expand Down
9 changes: 8 additions & 1 deletion R/mvar.R
Expand Up @@ -168,9 +168,12 @@ mvar <- function(data, # n x p data matrix


# ----- Split up predictor Sets by lags -----


# Divide Data in several parts: one response set, and one set of each lag
data_lagged <- lagData(data, lags, consec)
data_lagged <- lagData(data = data,
lags = lags,
consec = consec)

data_response <- data_lagged$data_response
l_data_lags <- data_lagged$l_data_lags
Expand Down Expand Up @@ -253,6 +256,7 @@ mvar <- function(data, # n x p data matrix
npar_standard <- rep(NA, p)

for(v in 1:p) {


# ----- Create VAR Design Matrix -----

Expand Down Expand Up @@ -442,6 +446,7 @@ mvar <- function(data, # n x p data matrix

# Update Progress Bar
if(pbar==TRUE) setTxtProgressBar(pb, v)


} # end for: p

Expand All @@ -464,6 +469,8 @@ mvar <- function(data, # n x p data matrix
if(length(pred_names) != (no_lags * p)) stop('Length of predictor variable names does not match calculated number of predictor varibales')




# Fill parameter list

for(v in 1:p) {
Expand Down

0 comments on commit e1b0581

Please sign in to comment.