fitCDM: Fit a CDM Model

Description Usage Arguments Examples

View source: R/fitCDM.R

Description

This function fits a CDM model on the input data as it is described by the phenoSim function.

Usage

1
2
fitCDM(x, z, connect = NULL, nGibbs = 1000, nBurnin = 1, n.adapt = 100,
  n.chains = 4, quiet = FALSE, calcLatentGibbs = FALSE, trend = +1)

Arguments

x

Matrix of predictors [N x p].

z

Vector of response values [N x 1].

connect

The connectivity matrix for the z vector [n x 2]. Each row contains the last and next elements of the time-series. NA values indicate not connected.

nGibbs

Number of MCMC itterations

nBurnin

Number of burn-in itterations.

n.adapt

Number of itterations for adaptive sampling

n.chains

Number of MCMC chains

quiet

logical value indicating whether to report the progress

calcLatentGibbs

logical value indicating whether to calculate the latent states

trend

time-series expected trend as -1:decreasing, +1:increasing, 0: not constrained

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Summarize CDM Model Ouput

ssSim <- phenoSim(nSites = 2, #number of sites
                  nTSet = 30, #number of Time steps
                  beta = c(1, 2), #beta coefficients
                  sig = .01, #process error
                  tau = .1, #observation error
                  plotFlag = TRUE, #whether plot the data or not
                  miss = 0.05, #fraction of missing data
                  ymax = c(6, 3) #maximum of saturation trajectory
)

ssOut <- fitCDM(x = ssSim$x, #predictors
                nGibbs = 200,
                nBurnin = 100,
                z = ssSim$z,#response
                connect = ssSim$connect, #connectivity of time data
                quiet=TRUE)

summ <- getGibbsSummary(ssOut, burnin = 100, sigmaPerSeason = FALSE)

colMeans(summ$ymax)
colMeans(summ$betas)
colMeans(summ$tau)
colMeans(summ$sigma)

phenoCDM documentation built on May 2, 2018, 5:04 p.m.