library(QlikQonnections2016) library(dplyr) library(knitr) library(sqldf) library(MARSS) library(ggplot2) library(foreach) library(doParallel)
# This script provides the datainput to Qlik for application #1 startp <- c(2007,1) sluttp <- c(2016,2) sluttpro <- c(2016,12) #modelltype <- c(1) variabler <- c(1,2)[1] modelltype <- c(1,2)[1:2] #[1:2] customers <- seq(1,15)[1:15] #[1:15] tidseriedatadf <- sqldf::read.csv.sql("data/PGlonnaggps.rda",sql = "SELECT * FROM PGlonnaggps") %>% dplyr::filter(avtalenr%in%customers) %>% dplyr::select(observasjonsdato,avtalenr,aar,maaned,premiestatus,nobs,pensjonslonn,antallStillinger) tidseriedata <- as.list(tidseriedatadf) custforecast <- prognoseestimeringb(startp,sluttp,sluttpro,tidseriedata,modelltype,variabler) colnames(custforecast) <- rep(c("customer","year","month","wagelevel (pension)","wageforcasting","wageforcastingvariance","model"),length(modelltype)) #Storing results ## from estimation devtools::use_data(custforecast,overwrite = TRUE) write.csv(custforecast, file = "data/custforecast.csv")
$$\text{Combinations before}= 111200 = 1200 $$ $$\text{Combinations now} = 321200 = 7200 $$
# This script provides the datainput to Qlik for application #2 (works only on Linux operating system) ## Settings aaa <- 1 # customer number mmm <- 2 # model number startp <- c(2007,1) sluttp <- c(2016,2) sluttpro <- c(2016,12) ## Finding data tidseriedatadf <- sqldf::read.csv.sql("data/PGlonnaggps.rda",sql = "SELECT * FROM PGlonnaggps") %>% dplyr::filter(avtalenr==aaa) %>% dplyr::select(observasjonsdato,avtalenr,aar,maaned,premiestatus,nobs,pensjonslonn,antallStillinger) tidseriedata <- as.list(tidseriedatadf) este <- enkeltavtestimeringb(tidseriedata,aaa,mmm,startp,sluttp,sluttpro) estenkavtmodell <- cbind(este,mmm) colnames(estenkavtmodell) <- c("customer","year","month","wagelevel (pension)","wageforcasting","wageforcastingvariance","modelchoice") estenkavtmodtable <- data.frame(estenkavtmodell) %>% left_join(premtable,by=c("customer"="avtale")) ## One customer estimation esttableforec <- enkeltavtestimeringb(tidseriedata,aaa,mmm,startp,sluttp,sluttpro) ## One customer plot estplot <- plotenkeltavtestimering(tidseriedata,aaa,mmm,startp,sluttp,sluttpro) ## One customer html-table esttablepaym <- custtabpayhtml(tidseriedata,aaa,mmm,startp,sluttp,sluttpro) estplotq <- plotenkeltavtestimering2(esttableforec,2) esttabq <- custtabpayhtml2(esttableforec,2)
# This script provides the datainput to Qlik for application #3 (works only on Linux operating system) startp <- c(2007,1) sluttp <- c(2016,2) sluttpro <- c(2016,12) #modelltype <- c(1) variabler <- c(1,2)[1] modelltype <- c(1,2)[1:2] #[1:2] customers <-seq(1,15)[1:3] tidseriedatadf <- sqldf::read.csv.sql("data/PGlonnaggps.rda",sql = "SELECT * FROM PGlonnaggps") %>% dplyr::filter(avtalenr%in%customers) %>% dplyr::select(observasjonsdato,avtalenr,aar,maaned,premiestatus,nobs,pensjonslonn,antallStillinger) ## One customer estimation tidseriedata <- as.list(tidseriedatadf) custforecast <- prognoseestimering(startp,sluttp,sluttpro,tidseriedata,modelltype,variabler) colnames(custforecast) <- rep(c("customer","year","month","wagelevel (pension)","wageforcasting","wageforcastingvariance","model")) prempaytable <- data.frame(custforecast) %>% dplyr::filter(year==2016,month==12) %>% dplyr::select(customer,wageforcasting,model) %>% left_join(premtable,by=c("customer"="avtale"))
https://github.com/joernih/QlikQonnections2016Public
<<<<<<< HEAD
$$ x_{t} = B_{t}x_{t-1} + u_{t} + C_{t}c_{t} + w_{t} \text{ where } w_{t} \sim MVN(0,\textbf{Q}{t}) \ y{t} = Z_{t}x_{t} + a_{t} + D_{t}d_{t} + v_{t}, \text{ where } v_{t} \sim MVN(0,\textbf{R}{t}) \ x{1} \sim MVN(\pi,\Lambda) \text{ and } x_{0} \sim MVN(\pi,\Lambda) $$
$$ Y_t=T_{t}+C_{t}+v_{t} \ C_{t}=C_{t-1}+C_{t-2}+w_{3,t} $$
$$ Y_t=T_{t}+C_{t}+v_{t} \ T_{t}=T_{t-1}+\beta_{t}+w_{1,t} \ \beta_{t}=\beta_{t-1}+w_{2,t} \ C_{t}=C_{t-1}+C_{t-2}+w_{3,t} $$
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.