-
Notifications
You must be signed in to change notification settings - Fork 2
/
OtherFEModels.Rmd
63 lines (52 loc) · 2.25 KB
/
OtherFEModels.Rmd
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: "Other Fixed Effect Models using R and Julia's `FixedEffectModels`"
author: "Erik Loualiche"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
#output:
# md_document:
# variant: markdown_github
always_allow_html: yes
vignette: >
%\VignetteIndexEntry{IV and Interactive fixed effect models}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
First load the package
```r
library(FixedEffectjlr)
JULIA_HOME <- "/Applications/Julia-0.6.app/Contents/Resources/julia/bin/"
FixedEffect_setup(JULIA_HOME)
```
A silly example to illustrate the syntax:
```r
df <- Ecdat::Cigar
FixedEffectIV_nse(df, sales ~ ndi, price ~ pimin, state+year, weights = NULL, vcov = robust)
```
And run the standard example from [`InteractiveFixedEffectModels.jl`](https://github.com/matthieugomez/InteractiveFixedEffectModels.jl)
```r
df <- Ecdat::Cigar
FixedEffectInteract(df, "sales", "price", "state+year", 2, "state", vcov = "robust")
```
The output is a list with three components:
- `statistics` that includes all the relevant information from the regression to create a table
- `summary` that mimicks a `coeftest` object and can be used inside of stargazer
- `dt_augment` that includes the residuals and factor loadings (it saves the PCs by default for this function)
```r
ife <- FixedEffectInteract(df, "sales", "price", "state+year", 2, "state", vcov = "robust")
str(ife$statistics)
stargazer::stargazer(ife$summary)
ife$dt_augment[]
loadings1 factors1 loadings2 factors2 residuals state
1: 123.4569 -0.2474458 17.67403 0.27993746 -5.2228250 136.8897
2: 123.4569 -0.2646732 17.67403 0.22784788 -0.1649076 136.8897
3: 123.4569 -0.2576672 17.67403 0.21923759 2.2223407 136.8897
4: 123.4569 -0.3021446 17.67403 0.07257907 8.9285553 136.8897
5: 123.4569 -0.2563533 17.67403 0.01662833 3.4067214 136.8897
---
1376: 55.5659 0.1690440 -43.31349 0.16784489 -2.6102131 162.8116
1377: 55.5659 0.1700898 -43.31349 0.18365775 -2.4587907 162.8116
1378: 55.5659 0.2031630 -43.31349 0.19880231 -13.5040138 162.8116
1379: 55.5659 0.2218755 -43.31349 0.21521906 -2.6961542 162.8116
1380: 55.5659 0.2861259 -43.31349 0.25092751 8.9333349 162.8116
```