Learn R Programming

dynia (version 0.2)

GetLikeDI: Calculate the Likelihood function value provide a certain intervention model

Description

Likelihood function value is calcuated for the intervention

Usage

GetLikeDI(delta, z, T, xint = NA, itype = c("step", "pulse"), ...)

Arguments

delta
The specific number for Intervention Level estimated
z
The time series we fit into the model
T
The start of the Intervention in the series
xint
The covariate considered in the model
itype
The type of intervention fitting in the model:"Step"(Default),"Step"
...
Supported argment for arima function

Value

Likelihood value is provided

Examples

Run this code
###Likelihood Test for Casualties with null:delta=1###
###Constrained Model Likelihood####
(LLRestricted<-GetLikeDI(delta=0,z=casualties[,1],T=70,xint=scale(casualties[,2]),
 itype="s",order=c(1,0,0),seasonal=list(order=c(0,0,1),period=12)))
###Full Model Likelihood###
(LLFull <- optimize(f = GetLikeDI, interval = c(0.1, 2),  maximum = TRUE, 
 z = casualties[,1], T = 70, xint = scale(casualties[,2]), itype = "s", 
 order=c(1,0,0),seasonal=list(order=c(0,0,1),period=12)))
X <- 2 * (LLFull$objective - LLRestricted)
###P-VLUE For Likelihood Test###
(pval <- 1 - pchisq(X, 1))
GetPV(delta0=1,z=casualties[,1],T=70,xint=scale(casualties[,2]),itype="s",order=c(1,0,0),
  seasonal=list(order=c(0,0,1),period=12))

######################################################
###Likelihood Test for Nile Flow with null:delta=1####
LLRestricted <- GetLikeDI(delta=1,z=Nile,T=34,itype="p",order=c(1,0,0))
ans <- optimize(f = GetLikeDI, interval = c(0.1, 2), maximum = TRUE,z=Nile,T=33
                ,itype="p",order=c(1,0,0)) 
LLFull <- ans$objective
X <- 2 * (LLFull - LLRestricted)
(pval <- 1 - pchisq(X, 1))
GetPV(delta0=0,z=Nile,T=34,itype="p",order=c(1,0,0))


Run the code above in your browser using DataLab