Title: | Group-Based Multivariate Trajectory Modeling |
---|---|
Description: | Estimation and analysis of group-based multivariate trajectory models (Nagin, 2018 <doi:10.1177/0962280216673085>; Magrini, 2022 <doi:10.1007/s10182-022-00437-9>). The package implements an Expectation-Maximization (EM) algorithm allowing unbalanced panel and missing values, and provides several functionalities for prediction and graphical representation. |
Authors: | Alessandro Magrini [aut, cre] |
Maintainer: | Alessandro Magrini <[email protected]> |
License: | GPL-2 |
Version: | 0.1.4 |
Built: | 2025-03-02 05:34:10 UTC |
Source: | https://github.com/cran/gbmt |
Estimation and analysis of group-based multivariate trajectory models.
Package: | gbmt |
Type: | Package |
Version: | 0.1.4 |
Date: | 2024-12-02 |
License: | GPL-2 |
Group-based trajectory modeling is a statistical method to determine groups of units based on the trend of a multivariate time series. It is a special case of latent class growth curves where the units in the same group have the same trajectory (Nagin, 2005), but it assumes a multivariate polynomial regression on time within each group, instead of a univariate one, to account for multiple indicators (Nagin et al., 2018; Magrini, 2022). A group-based multivariate trajectory model is estimated through the Expectation-Maximization (EM) algorithm, which allows unbalanced panel and missing values. The main functions currently implemented in the package are:
gbmt: to estimate a group-based multivariate trajectory model;
predict.gbmt: to perform prediction on trajectories;
plot.gbmt: to display estimated and predicted trajectories;
posterior: to compute posterior probabilities for new units.
Alessandro Magrini <[email protected]>
A. Magrini (2022). Assessment of agricultural sustainability in European Union countries: A group-based multivariate trajectory approach. AStA Advances in Statistical Analysis, 106, 673-703. DOI: 10.1007/s10182-022-00437-9
D. S. Nagin, B. L. Jones, V. L. Passos and R. E. Tremblay (2018). Group-based multi-trajectory modeling. Statistical Methods in Medical Research, 27(7): 2015-2023. DOI: 10.1177/0962280216673085
D. S. Nagin (2005). Group-based modeling of development. Harvard University Press, Cambridge, US-MA.
Simulated dataset containing the score on four achievement tests for 50 childrens attending the last year of primary school. The four tests are repeated five times at regular time intervals.
data(achievement)
data(achievement)
A data.frame with a total of 250 observations on the following 6 variables:
id
Child identifier.
time
Assessment time (1 to 5).
speaking
Score on speaking test (1=minimum, 5=maximum).
reading
Score on reading test (1=minimum, 5=maximum).
writing
Score on writing test (1=minimum, 5=maximum).
math
Score on math test (1=minimum, 5=maximum).
Data on several indicators covering the economic, social and environmental dimensions of agricultural sustainability for 26 EU countries in the period 2004-2018.
data(agrisus)
data(agrisus)
A data.frame with a total of 390 observations on the following 16 variables:
Country
Country name.
Country_code
Country code.
Year
Time of measurement (year).
Date
Time of measurement (date).
TFP_2005
Total Factor Productivity (TFP) index of agriculture (2005=100). Source: CMEF.
NetCapital_GVA
Net capital stocks in agriculture (2015 US dollars) to gross value added of agriculture (2015 US dollars). Source: Faostat.
Manager_ratio
Ratio young/elderly for farm managers (number of managers with less than 35 years by 100 managers with 55 years and over). Source: CMEF.
FactorIncome_paid_2010
Real income of agricultural factors per paid annual work unit (index 2010=100). Source: Eurostat.
EntrIncome_unpaid_2010
Net entrepreneurial income of agriculture per unpaid annual work unit (index 2010=100). Source: Eurostat.
Income_rur
Median equivalised net income in rural areas (power purchasing standard). Source: Eurostat.
Unempl_rur
At-risk-of-poverty rate in rural areas (%). Source: Eurostat.
Poverty_rur
Unemployment rate in rural areas (%). Source: Eurostat.
RenewProd
Production of renewable energy from agriculture (share of total production of renewable energy, %). Source: CMEF.
Organic_p
Area under organic cultivation (share of utilized agricultural area, %). Source: Faostat.
GHG_UAA
Greenhouse gas emissions due to agriculture (million CO2 equivalent grams per hectare of utilized agricultural area). Source: Faostat.
GNB_UAA
Gross nitrogen balance (tonnes of nutrient per hectare of utilized agricultural area). Source: Eurostat.
This is the dataset employed in Magrini (2022).
European Commission (2022). Eurostat database. https://ec.europa.eu/eurostat/data/database
European Commission (2020). Common Monitoring and Evaluation Framework (CMEF) for the CAP 2014-2020. https://agridata.ec.europa.eu/extensions/DataPortal/cmef_indicators.html
Food and Agriculture Organization (2022). FAOSTAT statistical database. https://www.fao.org/faostat/en/#home
A. Magrini (2022). Assessment of agricultural sustainability in European Union countries: A group-based multivariate trajectory approach. AStA Advances in Statistical Analysis, 106, 673-703. DOI: 10.1007/s10182-022-00437-9
Data on several indicators covering the economic, social and environmental dimensions of agricultural sustainability for 26 EU countries in the period 2004-2018. Missing values have been imputed.
data(agrisus2)
data(agrisus2)
A data.frame with a total of 390 observations on the following 16 variables:
Country
Country name.
Country_code
Country code.
Year
Time of measurement (year).
Date
Time of measurement (date).
TFP_2005
Total Factor Productivity (TFP) index of agriculture (2005=100). Source: CMEF.
NetCapital_GVA
Net capital stocks in agriculture (2015 US dollars) to gross value added of agriculture (2015 US dollars). Source: Faostat.
Manager_ratio
Ratio young/elderly for farm managers (number of managers with less than 35 years by 100 managers with 55 years and over). Source: CMEF.
FactorIncome_paid_2010
Real income of agricultural factors per paid annual work unit (index 2010=100). Source: Eurostat.
EntrIncome_unpaid_2010
Net entrepreneurial income of agriculture per unpaid annual work unit (index 2010=100). Source: Eurostat.
Income_rur
Median equivalised net income in rural areas (power purchasing standard). Source: Eurostat.
Unempl_rur
At-risk-of-poverty rate in rural areas (%). Source: Eurostat.
Poverty_rur
Unemployment rate in rural areas (%). Source: Eurostat.
RenewProd
Production of renewable energy from agriculture (share of total production of renewable energy, %). Source: CMEF.
Organic_p
Area under organic cultivation (share of utilized agricultural area, %). Source: Faostat.
GHG_UAA
Greenhouse gas emissions due to agriculture (million CO2 equivalent grams per hectare of utilized agricultural area). Source: Faostat.
GNB_UAA
Gross nitrogen balance (tonnes of nutrient per hectare of utilized agricultural area). Source: Eurostat.
This is the dataset employed in Magrini (2022) after imputation of missing values according to a group-based multivariate trajectory model with three groups and three polynomial degrees.
European Commission (2022). Eurostat database. https://ec.europa.eu/eurostat/data/database
European Commission (2020). Common Monitoring and Evaluation Framework (CMEF) for the CAP 2014-2020. https://agridata.ec.europa.eu/extensions/DataPortal/cmef_indicators.html
Food and Agriculture Organization (2022). FAOSTAT statistical database. https://www.fao.org/faostat/en/#home
A. Magrini (2022). Assessment of agricultural sustainability in European Union countries: A group-based multivariate trajectory approach. AStA Advances in Statistical Analysis, 106, 673-703. DOI: 10.1007/s10182-022-00437-9
Estimation of a group-based multivariate trajectory model through the Expectation-Maximization (EM) algorithm. Missing values are allowed and the panel may be unbalanced.
gbmt(x.names, unit, time, ng=1, d=2, data, scaling=2, pruning=TRUE, delete.empty=FALSE, nstart=NULL, tol=1e-4, maxit=1000, quiet=FALSE)
gbmt(x.names, unit, time, ng=1, d=2, data, scaling=2, pruning=TRUE, delete.empty=FALSE, nstart=NULL, tol=1e-4, maxit=1000, quiet=FALSE)
x.names |
Character vector including the names of the indicators. |
unit |
Character indicating the name of the variable identifying the units. |
time |
Character indicating the name of the variable identifying the time points. There must be at least two time points for each unit. |
ng |
Positive integer value indicating the number of groups to create. Cannot be greater than half the number of units. Default is 1. |
d |
Positive integer value indicating the polynomial degree of group trajectories. Cannot be greater than the minimum number of time points across all units minus 1. Default is 2. |
data |
Object of class |
scaling |
Normalisation method, that should be indicated as: 0 (no normalisation), 1 (centering), 2 (standardization), 3 (ratio to the mean) and 4 (logarithmic ratio to the mean). Default is 2 (standardization). See 'Details'. |
pruning |
Logical value indicating whether non-significant polynomial terms should be dropped. Default is |
delete.empty |
Logical value indicating whether empty groups should be deleted. Default is |
nstart |
Positive integer value indicating the number of random restarts of the EM algorithm. If |
tol |
Positive value indicating the tolerance of the EM algorithm. Default is 1e-4. |
maxit |
Positive integer value indicating the maximum number of iterations of the EM algorithm. Default is 1000. |
quiet |
Logical value indicating whether prompt messages should be suppressed. Default is |
Let be the considered indicators and
denote their observation on unit
(
) at time
(
).
Also, let
and
be, respectively, sample mean and sample standard deviation of indicator
for unit
across the whole period of observation.
Each indicator is normalized within units according to one among the following normalisation methods:
0) no normalisation:
1) centering:
2) standardization:
3) ratio to the mean:
4) logarithmic ratio to the mean:
Normalisation is required if the trajectories have different levels across units. When indicators have different scales of measurement, standardization is needed to compare the measurements of different indicators. Ratio to the mean and logaritmic ratio to the mean allow comparisons among different indicators as well, but they can be applied only in case of strictly positive measurements.
Denote the hypothesized groups as and let
be a latent variable taking value
if unit
belongs to group
.
A group-based multivariate trajectory model with polynomial degree
is defined as:
where is the
matrix of regression coefficients in group
, and
is the
covariance matrix of the indicators in group
.
The likelihood of the model is:
where is the multivariate Normal density of
in group
, and
is the prior probability of group
.
The posterior probability of group
for unit
is computed as:
where the hat symbol above a parameter denotes the estimated value for that parameter. See the vignette of the package and Magrini (2022) for details on maximum likelihood estimation through the EM algorithm.
S3 methods available for class gbmt
include:
print
: to see the estimated regression coefficients for each group;
summary
: to obtain the summary of the linear regressions (a list with one component for each group and each indicator);
plot
: to display estimated and predicted trajectories. See plot.gbmt for details;
coef
: to see the estimated coefficients (a list with one component for each group);
fitted
: to obtain the fitted values, equating to the estimated group trajectories (a list with one component for each group);
residuals
: to obtain the residuals (a list with one component for each group);
predict
: to perform prediction on trajectories. See predict.gbmt for details.
logLik
: to get the log likelihood;
AIC
, extractAIC
: to get the Akaike information criterion;
BIC
: to get the Bayesian information criterion.
An object of class gbmt
, including the following components:
call: |
list including details on the call. |
prior: |
vector including the estimated prior probabilities. |
beta: |
list of matrices, one for each group, including the estimated regression coefficients. |
Sigma: |
list of matrices, one for each group, including the estimated covariance matrix of the indicators. |
posterior: |
matrix including posterior probabilities. |
Xmat: |
the model matrix employed for each indicator in each group. |
fitted: |
list of matrices, one for each group, including the estimated group trajectories. |
reg: |
list of objects of class |
assign: |
vector indicating the assignement of the units to the groups. |
assign.list: |
list indicating the assignement of the units to the groups. |
logLik: |
log-likelihood of the model. |
npar: |
total number of free parameters in the model. |
ic: |
information criteria for the model (see Magrini, 2022 for details. |
appa: |
average posterior probability of assignments (APPA) for the model. |
data.orig: |
data provided to argument |
data.scaled: |
data after normalization. |
data.imputed: |
data after imputation of missing values, equal to |
em: |
matrix with one row for each run of the EM algorithm, including log-likelihood, number of iterations and convergence status (1=yes, 0=no). |
A. Magrini (2022). Assessment of agricultural sustainability in European Union countries: A group-based multivariate trajectory approach. AStA Advances in Statistical Analysis, 106, 673-703. DOI: 10.1007/s10182-022-00437-9
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 degrees and 3 groups using the imputed dataset # - log ratio to the mean is used as normalisation (scaling=4), thus values # represent relative changes with respect to country averages (see Magrini, 2022) # - by default, standardization (scaling=2) is used, which indicates the number # of standard deviations away from the country averages. m3_2 <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=3, data=agrisus2, scaling=4) ## Not run: # same model with multiple random restarts m3_2r <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=3, data=agrisus2, scaling=4, nstart=10) ## End(Not run) # resulting groups m3_2$assign.list # estimated group trajectories m3_2$fitted # summary of regressions by group summary(m3_2) # fit a model with 4 groups m4_2 <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=4, data=agrisus2, scaling=4) rbind(m3_2$ic, m4_2$ic) ## comparison ## Not run: ## model for children's achievement tests: 5 groups, 2 polynomial degrees # - scaling=1 (centering): values are interpreted as absolute differences # from the child average # - scaling=2 (standardization): values are interpreted as standard deviations # away from the child average data(achievement) m_achiev <- gbmt(x.names=c("speaking","reading","writing","math"), unit="id", time="time", d=2, ng=5, scaling=2, data=achievement) ## End(Not run)
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 degrees and 3 groups using the imputed dataset # - log ratio to the mean is used as normalisation (scaling=4), thus values # represent relative changes with respect to country averages (see Magrini, 2022) # - by default, standardization (scaling=2) is used, which indicates the number # of standard deviations away from the country averages. m3_2 <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=3, data=agrisus2, scaling=4) ## Not run: # same model with multiple random restarts m3_2r <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=3, data=agrisus2, scaling=4, nstart=10) ## End(Not run) # resulting groups m3_2$assign.list # estimated group trajectories m3_2$fitted # summary of regressions by group summary(m3_2) # fit a model with 4 groups m4_2 <- gbmt(x.names=varNames, unit="Country", time="Year", d=2, ng=4, data=agrisus2, scaling=4) rbind(m3_2$ic, m4_2$ic) ## comparison ## Not run: ## model for children's achievement tests: 5 groups, 2 polynomial degrees # - scaling=1 (centering): values are interpreted as absolute differences # from the child average # - scaling=2 (standardization): values are interpreted as standard deviations # away from the child average data(achievement) m_achiev <- gbmt(x.names=c("speaking","reading","writing","math"), unit="id", time="time", d=2, ng=5, scaling=2, data=achievement) ## End(Not run)
Visualization of estimated and predicted trajectories.
## S3 method for class 'gbmt' plot(x, group=NULL, unit=NULL, x.names=NULL, n.ahead=0, bands=TRUE, conf=0.95, observed=TRUE, equal.scale=FALSE, trim=0, ylim=NULL, xlab="", ylab="", titles=NULL, add.grid=TRUE, col=NULL, transparency=75, add.legend=TRUE, pos.legend=c(0,0), cex.legend=0.6, mar=c(5.1,4.1,4.1,2.1), ...)
## S3 method for class 'gbmt' plot(x, group=NULL, unit=NULL, x.names=NULL, n.ahead=0, bands=TRUE, conf=0.95, observed=TRUE, equal.scale=FALSE, trim=0, ylim=NULL, xlab="", ylab="", titles=NULL, add.grid=TRUE, col=NULL, transparency=75, add.legend=TRUE, pos.legend=c(0,0), cex.legend=0.6, mar=c(5.1,4.1,4.1,2.1), ...)
x |
Object of class |
group |
Numerical value indicating the group for which the estimated trajectories should be displayed. If |
unit |
Character indicating the name of the unit for which estimated trajectories should be displayed. If |
x.names |
Character including the names of the indicators for which the estimated trajectory should be displayed. If |
n.ahead |
Non-negative integer value indicating the number of steps ahead to perform prediction. Default is 0, meaning no prediction. |
bands |
Logical value indicating whether the prediction bands for should be drawn. Default is |
conf |
Numerical value indicating the confidence level for the prediction bands. Default is 0.05. Ignored if |
observed |
Logical indicating whether observed trajectories should be drawn. Default is |
equal.scale |
Logical indicating whether indicators should have the same scale across all groups. Default is |
trim |
Numerical value indicating the proportion of extreme values to trim when either |
ylim |
vector of length 2 indicating the limits of the y-axis, which will be applied to all indicators. If |
xlab |
label for the x-axis, which will be applied to all indicators. Default is empty string. |
ylab |
label for the y-axis, which will be applied to all indicators. Default is empty strings. |
titles |
vector of titles for the indicators. If |
add.grid |
Logical value indicating whether the grid should be added. Default is |
col |
Character or numerical vector indicating the color of group trajectories. If |
transparency |
Numerical value between 0 and 100 indicating the trasparency of prediction regions. If negative, only prediction bands are displayed. Default is 75. Ignored if |
add.legend |
Logical value indicating whether the legend for groups should be added. Default is |
pos.legend |
Numerical vector of length 2 indicating the horizontal-vertical shift of the legend for groups with respect to the position 'topleft'. Default is |
cex.legend |
Expansion factor relative to the legend for groups. Default is 0.6. Ignored if |
mar |
Numerical vector of length 4 indicating the margin size in the order: bottom, left, top, right, which will be applied to all indicators. Default is |
... |
Further graphical parameters. |
No return value.
If unit
is not NULL
, values are back transformed to the original scales of indicators.
gbmt.
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) # group trajectories including 3 steps ahead prediction mar0 <- c(3.1,2.55,3.1,1.2) plot(m3_2, n.ahead=3, mar=mar0) ## overlapped groups plot(m3_2, group=1, n.ahead=3, mar=mar0) ## group 1 plot(m3_2, group=2, n.ahead=3, mar=mar0) ## group 2 plot(m3_2, group=3, n.ahead=3, mar=mar0) ## group 3 # same scale to ease comparisons plot(m3_2, n.ahead=3, mar=mar0, equal.scale=TRUE) plot(m3_2, group=1, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) plot(m3_2, group=2, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) plot(m3_2, group=3, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) # overlapped groups plot(m3_2, group=1, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) # trajectories including 3 steps ahead prediction for unit 'Italy' plot(m3_2, unit="Italy", n.ahead=3)
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) # group trajectories including 3 steps ahead prediction mar0 <- c(3.1,2.55,3.1,1.2) plot(m3_2, n.ahead=3, mar=mar0) ## overlapped groups plot(m3_2, group=1, n.ahead=3, mar=mar0) ## group 1 plot(m3_2, group=2, n.ahead=3, mar=mar0) ## group 2 plot(m3_2, group=3, n.ahead=3, mar=mar0) ## group 3 # same scale to ease comparisons plot(m3_2, n.ahead=3, mar=mar0, equal.scale=TRUE) plot(m3_2, group=1, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) plot(m3_2, group=2, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) plot(m3_2, group=3, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) # overlapped groups plot(m3_2, group=1, n.ahead=3, mar=mar0, equal.scale=TRUE, trim=0.05) # trajectories including 3 steps ahead prediction for unit 'Italy' plot(m3_2, unit="Italy", n.ahead=3)
Computation of posterior probabilities for new units.
posterior(x, newdata=NULL)
posterior(x, newdata=NULL)
x |
Object of class |
newdata |
Object of class |
An object of class data.frame
with one entry for each unit, containing the posterior probability of each group for that unit.
Data in newdata
must be expressed on the original scale of the indicators. Normalisation is applied internally.
gbmt.
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")),] )
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")),] )
Computation of in-sample and/or out-of-sample prediction of trajectories.
## S3 method for class 'gbmt' predict(object, unit=NULL, n.ahead=0, bands=TRUE, conf=0.95, in.sample=FALSE, ...)
## S3 method for class 'gbmt' predict(object, unit=NULL, n.ahead=0, bands=TRUE, conf=0.95, in.sample=FALSE, ...)
object |
Object of class |
unit |
Character indicating the name of the unit for which prediction should be performed. If |
n.ahead |
Non-negative integer value indicating the number of steps ahead for prediction. If a numerical vector is provided, only the maximum value is considered. If 0 (the default), in-sample prediction is returned. |
bands |
Logical value indicating whether the prediction bands should be computed. |
conf |
Numerical value indicating the confidence level for the prediction bands. Default is 0.05. Ignored if |
in.sample |
Logical value indicating whether in-sample prediction should be returned along with out-of-sample one. If |
... |
Further arguments for the generic |
If unit
is NULL
, a list with one component for each group, including a list with one object of class data.frame
for each indicator. Otherwise, a list with one object of class data.frame
for each indicator. Each of these dataframes has one column containing point predictions if bands
=FALSE
, otherwise three columns containing point predictions and their respective predictive bands.
If unit
is not NULL
, values are back transformed to the original scales of indicators.
gbmt.
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) # 3 steps ahead prediction of group trajectories predict(m3_2, n.ahead=3) predict(m3_2, n.ahead=3, in.sample=TRUE) ## include in-sample prediction # 3 steps ahead prediction for unit 'Italy' predict(m3_2, unit="Italy", n.ahead=3) predict(m3_2, unit="Italy", n.ahead=3, in.sample=TRUE) ## include in-sample prediction
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) # 3 steps ahead prediction of group trajectories predict(m3_2, n.ahead=3) predict(m3_2, n.ahead=3, in.sample=TRUE) ## include in-sample prediction # 3 steps ahead prediction for unit 'Italy' predict(m3_2, unit="Italy", n.ahead=3) predict(m3_2, unit="Italy", n.ahead=3, in.sample=TRUE) ## include in-sample prediction