Skip to contents

This function fits and provides summary statistics of a linear regression model fitted on the input and output values of a probabilistic analysis.

Usage

fit_lm_metamodel(
  df,
  y_var = NULL,
  x_vars = NULL,
  standardise = FALSE,
  partition = 1,
  seed_num = 1,
  validation = FALSE,
  show_intercept = FALSE,
  x_poly_2 = NULL,
  x_poly_3 = NULL,
  x_exp = NULL,
  x_log = NULL,
  x_inter = NULL
)

Arguments

df

a dataframe.

y_var

character. Name of the output variable in the dataframe. This will be the dependent variable of the metamodel.

x_vars

character or a vector for characters. Name of the input variable in the dataframe. This will be the independent variable of the metamodel.

standardise

logical. Determine whether the parameter of the linear regression should be standardised. Default is FALSE.

partition

numeric. Value between 0 and 1 to determine the proportion of the observations to use to fit the metamodel. Default is 1 (fitting the metamodel using all observations).

seed_num

numeric. Determine which seed number to use to split the dataframe in fitting an validation sets.

validation

logical. Determine whether R2 should be calculated on the validation set.

show_intercept

logical. Determine whether to show the intercept of the perfect prediction line (x = 0, y = 0). Default is FALSE.

x_poly_2

character. character or a vector for characters. Name of the input variable in the dataframe. These variables will be exponentiated by factor 2.

x_poly_3

character. character or a vector for characters. Name of the input variable in the dataframe. These variables will be exponentiated by factor 3.

x_exp

character. character or a vector for characters. Name of the input variable in the dataframe. The exponential of these variables will be included in the metamodel.

x_log

character. character or a vector for characters. Name of the input variable in the dataframe. The logarithm of these variables will be included in the metamodel.

x_inter

character. character or a vector for characters. Name of the input variables in the dataframe. This vector contains the variables for which the interaction should be considered. The interaction terms of two consecutive variables will be considered in the linear model; hence, the length of this vector should be even.

Value

A list with containing the fit of the model and validation estimates and plots when selected.

Details

Standardisation of the parameters is obtained by $$(x - u(x)) / sd(x)$$ where \(x\) is the variable value, \(u(x)\) the mean over the variable and \(sd(x)\) the standard deviation of \(x\). For more details, see Jalal et al. 2013.

Examples

# Fitting meta model with two variables using the probabilistic data
data(df_pa)
fit_lm_metamodel(df = df_pa,
                 y_var = "inc_qaly",
                 x_vars = c("p_pfsd", "p_pdd")
                 )
#> $fit
#> 
#> Call:
#> lm(formula = form, data = df)
#> 
#> Coefficients:
#> (Intercept)       p_pfsd        p_pdd  
#>      0.4494      -3.5036       0.8445  
#> 
#>