library("FIAR") ###### DCM ## DCM <- dcmParam(auto=TRUE) DCM <- list() DCM$n<- 3 # number of regions DCM$names <- c('V1','V2','V3') # names of regions DCM$m<- 2 # number of inputs DCM$ons<-list() # onsets of inputs DCM$ons$input1<-c(0,60,120,180) DCM$ons$input2<-c(0,30,60,90,120,150,180,210) DCM$dur<-list() # duration of inputs DCM$dur$input1<-30 DCM$dur$input2<-15 DCM$a <- c(0,0,0, # anatomical connections .7,0,0, # from region 1 to region 2 and from 0,.4,0) # region 2 to region 3 DCM$b <- c(0,0,0, # functional connections 0,0,0, # induced by input 1 from region 2 0,.2,0, # to region 3 0,0,0, # functional connections 0,0,.2, # induced by input 2 from region 3 0,0,0) # to region 2 DCM$c <- c(.4,0,0, # input 1 on region 1 0,.3,0) # input 2 on region 2 DCM$h<-c(.65, .41, .98, .32, .34,0) # hemodynamic parameters DCM$x <- 5*DCM$n # number of states per region DCM$TR<-1 # TR DCM$TE<-.04 # TE DCM$T<- 16 # Timebins per TR DCM$v<- 240 # number of scans set.seed(11111112) ts <- dcmGenerate(DCM,SNR=1,ar=.2,names=c('V1','V2','V3')) head(ts) DCM <- dcmEstimate(DCM,ts=ts) DCM$A DCM$pA DCM <- dcmEvidence(DCM,ts=ts) DCM$AIC DCM$BIC ###### SEM model0 <- c(0,0,0, + 1,0,0, + 0,1,0) fit0 <- ARsem(model0,data=semdata) summary(fit0) order <- ARorder(semdata) order fit3 <- ARsem(model0,data=semdata,order=3) summary(fit3) AIC(fit0) AIC(fit3) ####### GC head(grangerdata) ARorder(grangerdata,max=10) condGranger(grangerdata,nx=1,ny=2,order=3) set.seed(22222223) fit <- condGranger(grangerdata,nx=1,ny=2,order=3,boot=TRUE) fit fit$sig partGranger(grangerdata,nx=1,ny=2,order=3) set.seed(33333334) fit <- partGranger(grangerdata,nx=1,ny=2,order=3,boot=TRUE) fit set.seed(44444445) fit<-diffGranger(grangerdata,nx=1,ny=2,order=3,boot=TRUE) fit ###### Attention to visual motion DCM <- list() DCM$a <- c(0,1,0, 1,0,1, 0,1,0) # anatomical connections DCM$b <- c(0,0,0, 0,0,0, 0,0,0, 0,0,0, 1,0,0, 0,0,0, 0,0,0, 0,0,1, 0,0,0 ) # functional connections DCM$c <- c(1,0,0, 0,0,0, 0,0,0) # input DCM$h<-c(.65, .41, .98, .32, .34,0) # hemodynamic parameters DCM$v<- 360 # number of scans DCM$n<- 3 # number of regions DCM$names <- c('V1','V5','SPC') # names of regions DCM$m<- 3 # number of inputs DCM$TE<-.04 # TE DCM$T<- 16 # Timebins DCM$ons<-list() DCM$ons$photic<-c(10,50,100,140,210,250,300,340,30,70,120,160,190,230,280,320, 80,170,260,350) DCM$ons$motion<-c(10,50,100,140,210,250,300,340,30,70,120,160,190,230,280,320) DCM$ons$attention<-c(10,50,100,140,210,250,300,340) DCM$dur<-list() DCM$dur$photic<-10 DCM$dur$motion<-10 DCM$dur$attention<-10 DCM$TR<-3.22 # TR DCM$x <- 5*DCM$n # number of states DCM$X0 <- X0 ts <- attentiondata DCM <- dcmEstimate(DCM,ts=ts) DCM$A DCM$pA DCM2 <- DCM DCM2$a <- c(0,0,0, 1,0,1, 0,1,0) # anatomical connections DCM2 <- dcmEstimate(DCM2,ts=ts) DCM <- dcmEvidence(DCM,ts=ts) DCM2 <- dcmEvidence(DCM2,ts=ts) dcmCompare(DCM,DCM2) Model1 <- c(0,1,0, 1,0,1, 0,1,0) ts_photic <- SEMextract(ts,ons=DCM$ons$photic,dur=DCM$dur$photic) fit1 <- ARsem(Model1,data=ts_photic) Model2 <- c(0,0,0, 1,0,0, 0,1,0) fit2 <- ARsem(Model2,data=ts_photic) summary(fit2) fit3 <- ARsem(Model2,data=ts_photic,order=1) summary(fit3) AIC(fit2) AIC(fit3) set.seed(5555556) cgc <- condGranger(ts,boot=TRUE) cgc cgc$sig set.seed(6666667) pgc <- partGranger(ts,boot=TRUE) pgc pgc$sig set.seed(7777778) dgc <- diffGranger(ts,boot=TRUE) dgc dgc$sig set.seed(0000001) cgc <- condGranger(ts,order=50,boot=TRUE,bs=100) cgc cgc$sig