# Import data
data(banana)
## Example 1: Application to a three-way panel data
# Select data for all the three levels of the third way
bioimp.df2 <- banana
# Estimation: three-way ptm on bioimpedance data with the lagged
# dependent variable as transition variable
estimates2 <- ptm3(data.=bioimp.df2, nameI="i", nameT="t",
nameJ="j", nameY="bioimpedance", nameTV=NULL,
nameXexo="weight", nameIV=NULL, trimrate=0.4,
ngrid=100, h0=1.5, Iweight=FALSE,
test.lin=FALSE)
# Change point computation using a data frame (unique input choice)
CP3 <- cpoint(data.=bioimp.df2, nameI="i", nameT="t", nameJ="j",
nameY="bioimpedance",
thresholds=estimates2@"threshold"[,2])
## NOT RUN
### Example 2: Application to a two-way panel data
#
## Select data for a specific level of the third way
#bioimp.df <- banana[which(banana$j==1),]
#
## Prepare input matrix for ptm2
#bioimp.m <- matrix(bioimp.df$bioimpedance,
# ncol=length(unique(bioimp.df$t)), byrow=TRUE)
#
## Estimation: two-way ptm on bioimpedance data with the lagged
## dependent variable as transition variable
#estimates <- ptm2(Y=bioimp.m, TV=NULL, Xendo=NULL, Xexo=NULL,
# IV=NULL, trimrate=0.4, ngrid=100, h0=1.5,
# Iweight=FALSE, test.lin=FALSE)
#
## Change point computation using a data frame as input
#CP1 <- cpoint(data.=bioimp.df, nameI="i", nameT="t", nameJ="j",
# nameY="bioimpedance",
# thresholds=estimates@"threshold"[[1]])
#
## Change point computation using a data matrix as input
#CP2 <- cpoint(data.=bioimp.m, nameI=NA, nameT=NA, nameJ=NA,
# nameY=NA, thresholds=estimates@"threshold"[[1]])
##
Run the code above in your browser using DataLab