fatTrim: fatTrim: Supporting function to reduce the size of models

Description Usage Arguments Value Examples

View source: R/fatTrim.R

Description

fatTrim: Supporting function to reduce the size of models

Usage

1
fatTrim(cmx)

Arguments

cmx

A model object.

Value

A model object.

Examples

 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
31
32
33
34
35
36
37
38
39
set.seed(1)

##########################
##### Simulate Data ######
##########################

# create training dataset with 10 studies, 2 covariates
X <- matrix(rnorm(2000), ncol = 2)

# true beta coefficients
B <- c(5, 10, 15)

# outcome vector
y <- cbind(1, X) %*% B

# study names
study <- sample.int(10, 1000, replace = TRUE)
data <- data.frame( Study = study,
                    Y = y,
                    V1 = X[,1],
                    V2 = X[,2] )

##########################
##### Model Fitting #####
##########################

# Fit model with 1 Single-Study Learner (SSL): Linear Regression
mod1 <- lm(formula = Y ~., data = data)


############################################
##### Fat Trim to reduce model size #####
############################################

mod1.trim <- fatTrim(mod1)

# compare sizes
object.size(mod1)
object.size(mod1.trim)

studyStrap documentation built on Feb. 20, 2020, 5:08 p.m.