Description Usage Arguments Value Examples
View source: R/weighted_anchor_prediction.R
Perform a prediction for a Weighted Anchor Regression model
1 | weighted_anchor_prediction(names, coeff, x, anchor, gamma, target_variable)
|
names |
list of variable names corresponding to the coefficients in coeff |
coeff |
list of coefficients corresponding to the coefficients in names |
x |
is a dataframe containing the matrix x containing the independent variables |
anchor |
is a dataframe containing the matrix anchor containing the anchor variable |
gamma |
is the regularization parameter for the Anchor Regression |
target_variable |
is the target variable name contained in the x dataframe |
A list of predictions.
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 26 27 28 29 30 | # number of observed environments
environments <- 10
# populate list with generated data of x and anchor
data_x_list <- c()
data_anchor_list <- c()
for(e in 1:environments){
x <- as.data.frame(matrix(data = rnorm(100),nrow = 100,ncol = 10))
anchor <- as.data.frame(matrix(data = rnorm(200),nrow = 100,ncol = 2))
colnames(anchor) <- c('X1','X2')
data_x_list[[e]] <- x
data_anchor_list[[e]] <- anchor
}
# estimate model
gamma <- 2
target_variable <- 'V2'
weighted_anchor_model <- weighted_anchor_regression(data_x_list,
data_anchor_list,
gamma,
target_variable,
anchor_model_pre=NULL,
test_split=0.4,
lambda=0)
weighted_anchor_prediction(weighted_anchor_model$names,
weighted_anchor_model$coeff,
x,
anchor,
gamma,
target_variable)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.