A package for various type of linear model decomposition.
You can install decomplm
from github
using the devtools
package
install.packages("devtools")
require(devtools)
install_github('yoruhyde/decomplm')
library(decomplm) # load package
Usually, work directory, data_var and cs_var change everytime you setting up a new project. Make sure double check them before running the code.
setwd("C:\\Users\\yuemeng1\\Desktop\\code\\decomplm\\data") # set work directory
data=fread("input_data.csv") # load data
var=fread("input_var.csv") # load variable coefficients
layer=fread("input_layer.csv") # load model structure
date_var="week" # date variable name in input_data
cs_var=c("cs") # variable names for cross section in input_data; support multiple dimensions
Then you can run the code below to get the final decomposition of the main model. The code would choose the way that you specified in the file input_layer.csv - column if_direct
if.direct=unique(layer$is_direct[!is.na(layer$is_direct)])
if (length(if.direct)==1) {
if(if.direct==1) {
result=direct_weight(is.output.final=T,model_name=NULL)
} else {
result=seperate_decomp(is.output.final=T,model_name=NULL)
}
} else {
result=mixed_approach(is.output.final=T,model_name=NULL)
}
runApp(result$app) # activate output panel
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.