Skip to content

Commit

Permalink
check. package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Loualiche committed Mar 30, 2018
1 parent 73708db commit f19988a
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 43 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Package: FixedEffectjlr
Type: Package
Title: Fixed Effect Models in R
Title: A package for fast Fixed Effect Models in R
Version: 0.1.0
Date: 2018-03-22
Authors@R: person("Erik", "Loualiche", email = "[email protected]", role = c("aut", "cre"))
Description: Implements a R wrapper for FixedEffectModels julia package
Description: Implements a R wrapper for FixedEffectModels julia package.
This lies heavily on both the JuliaCall package and the tools developed by Matthieu Gomez.
License: MIT + file LICENSE
BugReports: https://github.com/eloualiche/FixedEffectjlr/issues
Encoding: UTF-8
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export(FixedEffect_nse)
export(FixedEffect_setup)
import(JuliaCall)
import(data.table)
importFrom(stats,as.formula)
importFrom(stats,terms)
importFrom(stringr,str_length)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_split)
9 changes: 6 additions & 3 deletions R/FixedEffectIV.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
#' @param fe expression of fixed effects id1 + id2:id3
#' @param vcov error types, expression either robust or cluster(id1)
#' @param weights expression of weights
#' @param vcov Specification for the error
#' @param save_res Do we save the residuals
#' @param print Do we print the results (default is yes)
#'
#' @return The return value will be a list which contains two elements at this point
#' results: includes most of the observation from the julia call
#' summary: includes information that is of importance to write a table
#'
#' @examples See vignettes and readme
#' @examples
#' # See vignettes and readme
#'
#' @export
#####################################################################################################################
Expand Down Expand Up @@ -116,8 +117,10 @@ FixedEffectIV_nse <- function(

# Run the regression
julia_command(julia_regcall)
julia_command("reg_res")

if (print == T){
julia_command("reg_res")
}


}
12 changes: 8 additions & 4 deletions R/FixedEffectInteract.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
#' @param fe expression of fixed effects id1 + id2:id3
#' @param weights expression of weights
#' @param vcov Specification for the error
#' @param save_res Save the results of the model
#'
#' @return The return value will be a list which contains two elements at this point
#' results: includes most of the observation from the julia call
#' summary: includes information that is of importance to write a table
#'
#' @examples See vignettes and readme
#' Short example
#' > df = Ecdat::Cigar
#' > FixedEffectInteract(df, "sales", "price", "state+year", 2, "state", vcov = "robust")
#' @examples
#' # See vignettes and readme
#' # Short example
#' \dontrun{
#' df = Ecdat::Cigar
#' FixedEffectInteract(df, "sales", "price", "state+year", 2, "state", vcov = "robust")
#' }
#'
#' @export
#####################################################################################################################
Expand Down
20 changes: 13 additions & 7 deletions R/FixedEffectModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#' @param weights Regression weights
#' @param vcov Specification for the error
#' @param save_res Do we save the residuals
#' @param print Do we save the results
#'
#' @return The return value will be a list which contains two elements at this point
#' results: includes most of the observation from the julia call
#' summary: includes information that is of importance to write a table
#'
#' @examples See vignettes and readme
#' @examples
#' # See vignettes and readme
#'
#' @export
#####################################################################################################################
Expand Down Expand Up @@ -204,20 +206,24 @@ FixedEffect <- function(dt,

#' Use FixedEffectModels.jl to run large fixed effect models in julia on multiple models
#'
#' \code{FixedEffect_models} returns the results of a linear fixed effect regression
#' \code{FixedEffect_nse} returns the results of a linear fixed effect regression
#'
#' @param dt dataset of interest
#' @param formula formula of the y ~ x1 + x2 type
#' @param fe expression of fixed effects id1 + id2:id3
#' @param weights expression of weights
#' @param vcov error types, expression either robust or cluster(id1)
#' @param ... Variables that we pass by to FixedEffect function like print and save_res
#'
#' @return The return value will be a list which contains two elements at this point
#' results: includes most of the observation from the julia call
#' summary: includes information that is of importance to write a table
#'
#' @examples See vignettes and readme
#' @examples
#' # See vignettes and readme
#' \dontrun{
#' FixedEffect_nse(y ~ x1 + x2, id1 + id2, cluster(id1), save = T)
#' }
#'
#' @export
#####################################################################################################################
Expand Down Expand Up @@ -268,21 +274,21 @@ FixedEffect_nse <- function(dt,
#' @param fe String, a vector of Fixed effects
#' @param weights Vector of regression weights (not yet coded)
#' @param vcov Vector of specification for the error
#' @param save_res Do we save the residuals (not yet coded)
#'
#' @return The return value will be a list which contains two elements at this point
#' results: includes most of the observation from the julia call
#' summary: includes information that is of importance to write a table
#'
#' @examples See vignettes and readme
#'
#' @examples
#' # See vignettes and readme
#' \dontrun{
#' lhs <- c("log_ewemt", "f1_log_ewemt")
#' rhs <- c("MP + retail_index + retail_index_MP",
#' "MP + discount_rate + discount_rate_MP")
#' fe <- c("date_y",
#' "date_y:fed_district + quarter:fed_district + industry_code_num:quarter")
#' vcov <- c("robust", "cluster(date_y)")
#'
#' }
#' @export
#####################################################################################################################
FixedEffect_models <- function(
Expand Down
14 changes: 11 additions & 3 deletions R/FixedEffectjlr.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#' A package for asset pricing analysis
#' FixedEffectjlr a package for Fixed Effect Models
#'
#' FixedEffectjlr uses juliacall and `FixedEffectModels.jl` to perform
#' fast high dimensional fixed effect regressions within R
#'
#'
#' @docType package
#' @name FixedEffectjlr
#'
#' @import data.table
#' @import JuliaCall
Expand All @@ -10,5 +13,10 @@
#' @importFrom stringr str_split
#' @importFrom stringr str_length
#'
NULL
#' @importFrom stats as.formula
#' @importFrom stats terms
#'
"_PACKAGE"



4 changes: 3 additions & 1 deletion man/FixedEffect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/FixedEffectIV_nse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions man/FixedEffectInteract.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions man/FixedEffect_models.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions man/FixedEffect_nse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/FixedEffectjlr-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions man/FixedEffectjlr.Rd

This file was deleted.

1 change: 1 addition & 0 deletions tests/testthat/test-StandardLM.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
context("Standard Linear Model")

library(Ecdat)
df = Ecdat::Cigar

test_that("run the Linear Model example", {
Expand Down

0 comments on commit f19988a

Please sign in to comment.