Description Usage Arguments Value Author(s) References
Runs a set of regression models to forecast time-series cross-sectional data by either considering independent regressions in each cross-sectional unit or by using a variety of techniques to smooth across units.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | yourcast(formula=NULL, dataobj=NULL,sample.frame=c(1950,2000,2001,2030),
standardize=TRUE, elim.collinear=FALSE,
tol=0.9999, solve.tol = 1.e-10,svdtol=10^(-10),
userfile=NULL, savetmp = T, model.frame=FALSE,
debug = F, rerun= "yourcast.savetmp",
### specific to models
model="OLS",zero.mean=FALSE,
#### smooth over ages
Ha.sigma = 0.3,
Ha.sigma.sd= 0.1, Ha.deriv=c(0,0,1),
Ha.age.weight=0, Ha.time.weight=0,
#### smooth over time
Ht.sigma= 0.3,
Ht.sigma.sd=0.1, Ht.deriv=c(0,0,1),
Ht.age.weight=0, Ht.time.weight=0,
#### smooth over age-time
Hat.sigma=0.2,
Hat.sigma.sd=0.1,Hat.a.deriv=c(0,1),Hat.t.deriv=c(0,1),
Hat.age.weight=0,Hat.time.weight=0,
#### smooth over cntry-time
Hct.sigma=0.3, Hct.sigma.sd =0.1,
Hct.t.deriv=1, Hct.time.weight = 0,
LI.sigma.mean=0.2,LI.sigma.sd = 0.1, nsample= 500,
low.pow=T, verbose=TRUE)
|
formula |
A standard R formula of the form y \sim x_1 +
x_2, except that an explanatory variable is included for a
particular cross-section only if it is both listed in the formula
and available in that cross-section's data set (see
|
dataobj |
A object of class ‘yourcast’ or equivalent. See
The The function |
sample.frame |
Vector. A four element vector containing, in order, the start
and end time periods to be used for the observed data and the start
and end time periods to be forecast. Years identified here that are
not available for a cross-section are ignored. Default:
|
standardize |
Boolean. Should the covariates in each
cross-sectional unit be standardized (to zero mean and standard
deviation of 1)? Standardization is performed for both the in-
and out-of-sample periods. Default: |
elim.collinear |
Boolean. Whether collinearity among covariates
should be tested and those that are collinear shoul be eliminated.
Default: |
tol |
Double scalar. Tolerance to find collinearities among
covariates. Default: |
solve.tol |
A real number smaller than one that is used in the
argument of the R-function |
svdtol |
A scalar; the tolerance used in inverting a matrix by SVD. Default: 10^{-10}. |
userfile |
A string with the name of a file that contains your
values for some or all of index.code <- 30 data <- "WHOmortalityData" If an option is specified in |
savetmp |
If |
model.frame |
If |
debug |
Boolean. It puts the
environment that contains parameters and arguments of the
simulation in the user workspace. Default |
rerun |
String. The name of the file that is saved in the default
directory with preliminary calculations; see
|
model |
A string indicating the forecasting method, including:
Bayes maximum a posteriori (
|
zero.mean |
A boolean or named vector with a value of \barμ
for each age group. If |
Ha.sigma |
This can be set in one of three ways: (1) a scalar
which sets σ_a, the prior standard deviation of E(Y),
indicating how much to smooth E(Y) over age groups (which may
vary over geographic areas and time periods, and with the standard
deviations averaged over age groups). A larger standard deviation
represents more prior uncertainty, which allows the data to play a
greater role. (2) |
Ha.sigma.sd |
A scalar; the standard deviation of parameter
Ha.sigma (for Gibbs sampling only). Default: |
Ha.deriv |
A numeric vector, each element of which is n,the
degree of a (discrete) derivative of the
smoothness functional with respect to the age group. Element k of
this vector refers to the (k-1)th derivative, where 0 excludes
the derviative, 1 includes it, and values in between include the
derivative but weight it down proportionally. The first element of
the vector corresponds to the weight on the derivative with respect
to age of order 0 (the identity operator), the second to the weight
on the derivative of order 1 (the 1st derivative), etc. For example,
c(0, 1, 1) corresponds to a mixed functional that penalizes the
first and second derivatives equally. The higher the order of
derivative, the more local smoothness over age groups; and lowest
specified derivative controls the form of prior
indifference. Default: |
Ha.age.weight |
A scalar or a numeric vector with weights that
determine how much smoothing occurs for different age groups. If set
to 0 or NA, age groups are weighted equally; if set to a nonzero
scalar, the weight for age group a is set proportional to
a^Ha.age.weight;
if a vector of length A, the ath element is the
weight of age group a. Default: |
Ha.time.weight |
A scalar or a numeric vector with weights that
determine how much smoothing occurs for different time periods when
smoothing over age groups. If |
Ht.sigma |
This can be set in one of three ways: (1) a scalar
which sets σ_t, the prior standard deviation of E(Y),
indicating how much to smooth E(Y) over time periods (which may
vary over geographic areas and age groups, and with the standard
deviations averaged over time periods). A larger standard deviation
represents more prior uncertainty, which allows the data to play a
greater role. (2) NA to not smooth in this way. (3) To have |
Ht.sigma.sd |
A scalar; the standard deviation of parameter
|
Ht.deriv |
A numeric vector, each element of which is
n, the degree of a (discrete) derivative of the
smoothness functional with respect to time. Element k of this
vector refers to the (k-1)th derivative, where 0 excludes the
derviative, 1 includes it, and values in between include the
derivative but weight it down proportionally. The first element of
the vector corresponds to the weight on the derivative with respect
to time of order 0 (the identity operator), the second to the weight
on the derivative of order 1 (the 1st derivative), etc. For example,
|
Ht.age.weight |
A scalar or a numeric vector with weights that
determine how much smoothing occurs for different age groups when
smoothing over time. If set to |
Ht.time.weight |
A scalar or a numeric vector with weights that
determine how much smoothing occurs for different time periods when
smoothing over time. If |
Hat.sigma |
This can be set in one of three ways: (1) a
scalar which sets σ_{at}, the prior standard deviation
of E(Y), indicating how much to smooth the time trend in E(Y) over
age groups. A larger standard deviation represents more prior
uncertainty, which allows the data to play a greater role. (2) NA to
not smooth in this way. (3) To have |
Hat.sigma.sd |
A scalar; the standard deviation of parameter
|
Hat.a.deriv |
A numeric vector, each element of which is n, the degree of a (discrete) derivative of the
smoothness functional of time trends with respect to age
groups. Element k of this vector refers to the (k-1)th
derivative of the time trend v with respect to age, where 0 excludes
the derviative, 1 includes it, and values in between include the
derivative but weight it down proportionally. The first element of
the vector corresponds to the weight on the derivative of the time
trend with respect to age of order 0 (the identity operator), the
second to the weight on the derivative of order 1 (the 1st
derivative), etc. For example, |
Hat.t.deriv |
A numeric vector, each element of which is n, the degree of a (discrete) derivative of the
smoothness functional of age derivative with respect to
time. Element k of this vector refers to the (k-1)th
derivative of the age derivative with respect to time, where 0
excludes the derviative, 1 includes it, and values in between
include the derivative but weight it down proportionally. The first
element of the vector corresponds to the weight on the age
derivative with respect to time of order 0 (the identity operator),
the second to the weight on the derivative of order 1 (the 1st
derivative), etc. For example, |
Hat.age.weight |
A scalar or a numeric vector with weights that
determines how much smoothing occurs for different age groups when
smoothing over age and time. If set to |
Hat.time.weight |
A scalar or a numeric vector with weights that
determine how much smoothing occurs for different time periods when
smoothing over age and time. If |
Hct.sigma |
A scalar which sets σ_t, the prior standard
deviation of E(Y), which indicates how to smooth E(Y) over
geographic areas, or NA to not smooth in this way. The parameter
σ_ct is the expected prior standard deviation of E(Y) for a
geographic area (varying over time periods and age groups, and with
the standard deviations averaged over geographic areas). (A larger
standard deviation represents more prior uncertainty, which allows
the data to play a greater role.) Default: |
Hct.sigma.sd |
A scalar; the standard deviation of parameter
Ht.sigma (for Gibbs sampling only). Default: |
Hct.t.deriv |
A numeric vector; controls whether smoothing the
level or the time trend of E(Y) over geographic areas (both
cannot presently be done simultaneously). To smooth the level of
E(Y) over geographic areas, set to 1, the identity. To smooth the
time trend, set this (as in |
Hct.time.weight |
A scalar or a numeric vector with weights
that determine how much smoothing occurs for different time periods
when smoothing over geographic areas. If |
LI.sigma.mean |
A scalar; used in the likelihood and in the
calculation of the priors in conjunction with |
LI.sigma.sd |
A scalar; the standard deviation of
|
nsample |
A scalar; represents the number of iterations in the
Gibbs algorithm |
low.pow |
Boolean. Whether to include lower-power of explanatory
variables in the simulation as derived from |
verbose |
Boolean. Suppress verbose output. Default: |
Returns a list of class ‘yourcast’ containing the following components:
call |
The full call, including all command line options when yourcast was called. |
userfile |
The full userfile if it was specified. |
yhat |
A list with the same cross-sectional elements as the input
data, but with two columns: ‘y’ for the observed dependent
variable and ‘yhat’ for the predicted values. These include both
in-sample and out-of-sample values, as distinguished by the values of
|
coeff |
A list with the same cross-sectional elements as the input data, elements of which are the estimated coefficients if calculated by the chosen model. |
sigma |
A list with the same cross-sectional elements as the input data, elements of which are the estimated standard error of the estimate of the regression (the standard deviation of the dependent variable given the explanatory variables). |
aux |
List. A list of summary information about the yourcast analysis
used by |
params |
Vector. Smoothing parameters used in model. |
Federico Girosi girosi@rand.org; Elena Villalon evillalon@iq.harvard.edu; Gary King king@harvard.edu
http://gking.harvard.edu/yourcast
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.