View source: R/SEM_likelihood.R
SEM_likelihood | R Documentation |
Likelihood for the SEM model
SEM_likelihood(
params,
data,
timestamp_col,
entity_col,
dep_var_col,
lin_related_regressors = NULL,
per_entity = FALSE,
exact_value = TRUE
)
params |
Parameters describing the model. Can be either a vector or a list with named parameters. See 'Details' |
data |
Data for the likelihood computations. Can be either a list of matrices or a dataframe. If the dataframe, additional parameters are required to build the matrices within the function. |
timestamp_col |
Column which determines time stamps. For now only natural numbers can be used. |
entity_col |
Column which determines entities (e.g. countries, people) |
dep_var_col |
Column with dependent variable |
lin_related_regressors |
Which subset of columns should be used as
regressors for the current model. In other words |
per_entity |
Whether to compute overall likelihood or a vector of likelihoods with per entity value |
exact_value |
Whether the exact value of the likelihood should be
computed ( |
The params
argument is a list that should contain the following
components:
alpha
scalar value which determines linear dependence on lagged
dependent variable
phi_0
scalar value which determines linear dependence on the value
of dependent variable at the lowest time stamp
err_var
scalar value which determines classical error component
(Sigma11 matrix, sigma_epsilon^2)
dep_vars
double vector of length equal to the number of time stamps
(i.e. time stamps greater than or equal to the second lowest time stamp)
beta
double vector which determines the linear dependence on
regressors different than the lagged dependent variable; The vector should
have length equal to the number of regressors.
phi_1
double vector which determines the linear dependence on
initial values of regressors different than the lagged dependent variable;
The vector should have length equal to the number of regressors.
phis
double vector which together with psis
determines upper
right and bottom left part of the covariance matrix; The vector should have
length equal to the number of regressors times number of time stamps minus 1,
i.e. regressors_n * (periods_n - 1)
psis
double vector which together with psis
determines upper
right and bottom left part of the covariance matrix; The vector should have
length equal to the number of regressors times number of time stamps minus 1
times number of time stamps divided by 2, i.e.
regressors_n * (periods_n - 1) * periods_n / 2
The value of the likelihood for SEM model (or a part of interest of the likelihood)
set.seed(1)
df <- data.frame(
entities = rep(1:4, 5),
times = rep(seq(1960, 2000, 10), each = 4),
dep_var = stats::rnorm(20), a = stats::rnorm(20), b = stats::rnorm(20)
)
df <-
feature_standardization(df, timestamp_col = times, entity_col = entities)
SEM_likelihood(0.5, df, times, entities, dep_var)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.