fRLR

An R package: Fitting Repeated Linear Regressions

https://github.com/szcf-weiya/frlr

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.6%) to scientific vocabulary

Keywords

gsl r regression
Last synced: 6 months ago · JSON representation

Repository

An R package: Fitting Repeated Linear Regressions

Basic Info
Statistics
  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Topics
gsl r regression
Created over 8 years ago · Last pushed over 2 years ago
Metadata Files
Readme License

README.md

fRLR

Introduction

This R package aims to fit Repeated Linear Regressions in which there are some same terms.

An Example

Suppose we want to fit a set of regressions which only differ in one variable. Specifically, denote the response variable as , and these regressions are as follows.

where are the same variables among these regressions.

Intuitively, we can finish this task by using a simple loop in R code.

model = vector(mode='list', length=n) for (i in 1:n) { ... model[[i]] = lm(y~x) }

However, it is not efficient in that situation. Due to the same variables, there are some same calculations among different regressions. In order to reduce the cost of computation, I write this fRLR package which avoiding to repeat the same calculations. See more details in my blog, where I present the whole mathematical formula.

Let me take a simulation example to show how to use this R package.

```

use fRLR package

library(fRLR) set.seed(123) X = matrix(rnorm(50), 10, 5) Y = rnorm(10) COV = matrix(rnorm(40), 10, 4) frlr1(X, Y, COV)

use simple loop

res = matrix(nrow = 0, ncol = 2) for (i in 1:ncol(X)) { mat = cbind(X[,i], COV) df = as.data.frame(mat) model = lm(Y~., data = df) tmp = c(i, summary(model)$coefficients[2, 4]) res = rbind(res, tmp) } ```

Then we can obtain the following results

To show the speed of my package, let me increase the number of regressions, and compare the time duration with simple-loop method.

``` library(fRLR) set.seed(123) n = 500 X = matrix(rnorm(10*n), 10, n) Y = rnorm(10) COV = matrix(rnorm(40), 10, 4)

idx1 = c(1, 2, 3, 4, 1, 1, 1, 2, 2, 3)

idx2 = c(2, 3, 4, 5, 3, 4, 5, 4, 5, 5)

id = combn(n, 2) idx1 = id[1, ] idx2 = id[2, ]

system.time(frlr2(X, idx1, idx2, Y, COV))

simpleLoop <- function() { res = matrix(nrow=0, ncol=4) for (i in 1:length(idx1)) { mat = cbind(X[, idx1[i]], X[,idx2[i]], COV) df = as.data.frame(mat) model = lm(Y~., data = df) tmp = c(idx1[i], idx2[i], summary(model)$coefficients[2,4], summary(model)$coefficients[3,4]) res = rbind(res, tmp) } }

system.time(simpleLoop()) ```

The results are as follows.

As you can see, fRLR can speed this task significantly.

Install Instructions

You'd better install this package on Linux or Mac, because they perfectly support the GNU scientific library (GSL). Of course, you can still this package on windows if you setup your GSL environment, and I opened a repository GSL where you can find solutions to install GSL on windows, although it might be cumbersome.

If GSL has been installed on your computer, you can install the package by the following command devtools::install_github('szcf-weiya/fRLR')

Owner

  • Login: szcf-weiya
  • Kind: user
  • Company: Yale University

Postdoc@Yale; Alumni@CUHK (Ph.D.), Alumni@ZJU (B.S.)

GitHub Events

Total
Last Year

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 49
  • Total Committers: 2
  • Avg Commits per committer: 24.5
  • Development Distribution Score (DDS): 0.061
Past Year
  • Commits: 3
  • Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
szcf-weiya 2****2@q****m 46
szcf-weiya s****a@g****m 3
Committer Domains (Top 20 + Academic)
qq.com: 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 4
  • Total pull requests: 0
  • Average time to close issues: 2 days
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • szcf-weiya (4)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 149 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
cran.r-project.org: fRLR

Fit Repeated Linear Regressions

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 149 Last month
Rankings
Dependent packages count: 29.8%
Average: 32.6%
Dependent repos count: 35.5%
Maintainers (1)
Last synced: 7 months ago

Dependencies

DESCRIPTION cran
  • Rcpp >= 0.12.12 imports
  • knitr * suggests
  • rmarkdown * suggests