algo_leverage: Algorithmic Leveraging

Description Usage Arguments Value Examples

View source: R/algo_leverage.R

Description

algo_leverage fits linear regression models on subsets of data sampled by both uniform and leverage sampling

Usage

1
algo_leverage(x, y, subset_size, num_sample = 500, method = "both")

Arguments

x

Predictor matrix x, with n rows and p columns

y

Response vector y, with n elements

subset_size

Size of subset(s) on which regression model(s) will be fit

num_sample

Number of subsets to take when method = 'both'

method

One of 'both', 'uniform', or 'leverage'. 'both' will produce summary outputs for both uniform and leverage sampling over num_sample subsets, while 'uniform' and 'leverage' output one draw of estimated Betas for uniform and leverage sampling, respectively.

Value

When method = 'both' and X has 1 column, boxplots will be produced showing the distribution of betas from models fit on samples drawn using both uniform and leverage sampling. When method = 'both' and X has more than 1 column, a line graph will compare the average values of each Beta for both uniform and leverage sampling. When method = 'uniform' or 'leverage', the model will be fit for one sample using uniform or leverage sampling, respectively, and the Beta values will be returned.

Examples

1
2
3
4
x = rt(500, 6)
y = -x + rnorm(500)
algo_leverage(x, y, subset_size = 100, num_sample = 500)
algo_leverage(x, y, 100, method = 'leverage')

stevebroll/stsci6520hw2 documentation built on Dec. 23, 2021, 5:32 a.m.