# NOT RUN {
<!-- %% -->
# }
# NOT RUN {
################################################################################
##
## SR Weibull MODEL: the SYS1 data
##
################################################################################
library(NGSSEML)
#Classical:
data(sys1_data)
Ytm=sys1_data[,1]+0.00001
Xtm=as.matrix(sys1_data[,2])
hh=3
Xtprev=as.matrix(135+1:hh)
model="SRWeibull"
#model="SRGamma"
LabelParTheta=c("w","nu","Beta1")
StaPar=c(0.9,0.7,0.01)
#Fit:
fit=ngssm.mle(Ytm~Xtm,data=data.frame(Ytm,Xtm),
model=model,pz=NULL,StaPar=StaPar,a0=0.01,b0=0.01,ci=0.95)
estopt=c(0.99,0.75262104,0.02342691)
estopt=fit[[1]][1:3]
predpar=Prediction(Ytm~Xtm,data=data.frame(Ytm,Xtm),
model=model,StaPar=estopt,pz=NULL,a0=0.01,
b0=0.01,distl="FILTER",ci=0.95,samples=500,hh=hh,
Xtprev=Xtprev,method="MLE")
#library(NGSSEML)
#Bayesian:
#### Inputs:
data(sys1_data)
Yt=sys1_data[,1]+0.00001
Xt=as.matrix(sys1_data[,2]) # Xt as matrix always!
hh=3
Xtprev=as.matrix(135+1:hh)
Zt="NULL"
model="SRWeibull"
#model="SRGamma"
LabelParTheta=c("w","nu","Beta1")
pointss=4 ### points
nsamplex=50 ## Multinomial sampling posterior
StaPar=c(0.9,0.7,0.01)
#Fit:
fitbayes=ngssm.bayes(Ytm~Xtm,data=data.frame(Ytm,Xtm),
model=model,pz=NULL,StaPar=StaPar,
prw=c(1,1),prnu=c(0.1,0.1),prbetamu=rep(0,1),prbetasigma=diag(100,1,1),
pointss=pointss,nsamplex=50,postplot=FALSE,contourplot=FALSE)
posts=fitbayes[[2]]
#Prediction:
set.seed(1000)
predpar=Prediction(Ytm~Xtm,data=data.frame(Ytm,Xtm),
model=model,pz=NULL,StaPar=posts,
a0=0.01,b0=0.01,distl="PRED",ci=0.95,samples=500,hh=hh,
Xtprev=Xtprev,method="Bayes")
predpar
# }
Run the code above in your browser using DataLab