Learn R Programming

gbmt (version 0.1.4)

posterior: Posterior probabilities based on a group-based multivariate trajectory model

Description

Computation of posterior probabilities for new units.

Usage

posterior(x, newdata=NULL)

Value

An object of class data.frame with one entry for each unit, containing the posterior probability of each group for that unit.

Arguments

x

Object of class gbmt.

newdata

Object of class data.frame containing the multivariate time series of the indicators for the new units. If NULL (the default), posterior probabilities of the sample units are returned. If newdata is not NULL, it must include the variable identifying the time points. If newdata does not include the variable identifying the units, it is assumed that all observations refer to the same unit.

See Also

gbmt.

Examples

Run this code
data(agrisus2)

# names of indicators (just a subset for illustration)
varNames <- c("TFP_2005", "NetCapital_GVA",
  "Income_rur", "Unempl_rur", "GHG_UAA", "GNB_N_UAA")

# model with 2 polynomial degrees and 3 groups
m3_2 <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=3, data=agrisus2, scaling=4)

# pretend that 'Italy' is a new unit
posterior(m3_2, newdata=agrisus2[which(agrisus2$Country=="Italy"),])

# consider only the last 3 years
posterior(m3_2, newdata=
  agrisus2[which(agrisus2$Country=="Italy"&agrisus2$Year>=2016),]
  )

# provide more than one new unit
posterior(m3_2, newdata=
  agrisus2[which(agrisus2$Country%in%c("Italy","Austria","Greece")),]
  )

Run the code above in your browser using DataLab