R/transform_model_data.R

Defines functions transform_model_data

transform_model_data <- function(res){
  data_type <- 1
  model <- res$CALL$pars$model
  x <- res$CALL$pars$data_pre_fixed
  if(model=="MLVAR" && data_type != 1){
    if (data_type==2) x <- as.data.frame(x)
    if (data_type==3) x <- longi_to_dataframe(x)
  }
  if (model== "SMVAR"){
    x <- sapply(x, function(i) as.numeric(as.character(i)))
  }
  if(model=="GGVAR" && data_type != 3){
    x <- data_to_longi(x)
  }
  if(model=="GVAR" && (!data_type %in% c(1, 2))){
    x <- longi_to_matrix1(x)
  }
  if(model %in% c("SVARHL","SVARHLX","SVARHLMA") && (data_type != 3 | data_type != 2)){
    x <- as.matrix(x)
  }
  if(model %in% c("SVAR","SVECM") && data_type != 2){
    if (data_type==3) x <- longi_to_matrix1(x)
    if (data_type==1) x <- as.matrix(x)
  }
  return(x)
}

Try the psychNET package in your browser

Any scripts or data that you put into this service are public.

psychNET documentation built on April 14, 2020, 6:39 p.m.