Skip to content

Commit 5f5199d

Browse files
committed
Adding infrastructure for CRAN et al.
1 parent 4762323 commit 5f5199d

6 files changed

Lines changed: 251 additions & 2 deletions

File tree

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
^panel\-simulations\.R$
1111
^diagnostics\.R$
1212
^data\-raw$
13+
^cran-comments\.md$
14+
^CONDUCT\.md$

CONDUCT.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at long.1377@osu.edu. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct/
72+
73+
[homepage]: https://www.contributor-covenant.org

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: panelr
22
Title: Regression Models and Utilities for Repeated Measures and Panel Data
3-
Version: 0.1.0
4-
Authors@R: person("Jacob A.", "Long", email = "long.1377@osu.edu", role = c("aut", "cre"))
3+
Version: 0.1.1
4+
Authors@R: person("Jacob A.", "Long", email = "long.1377@osu.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-1582-6214"))
55
Description: This package implements several methods for creating regression
66
models that take advantage of the unique aspects of
77
panel data. It automates the "within-between" (also known as

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# panelr 0.1.1
2+
3+
* Added a `NEWS.md` file to track changes to the package.
4+
* Added infrastructure for CRAN submission.
5+
* Improved documentation and added references.
6+
* Added README.
7+
8+
# panelr 0.1.0
9+
10+
* Got things working such that it can be shared outside the maintainer's own
11+
computers.
12+
* Added WageData example, documentation, etc.
13+
* Unit testing and automated tests through Travis and Appveyor.
14+

README.Rmd

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
output: github_document
3+
---
4+
5+
<!-- README.md is generated from README.Rmd. Please edit that file -->
6+
7+
```{r, echo = FALSE}
8+
knitr::opts_chunk$set(
9+
collapse = TRUE,
10+
comment = "#>",
11+
fig.path = "README-"
12+
)
13+
```
14+
15+
[![Travis-CI Build Status](https://travis-ci.org/jacob-long/panelr.svg?branch=master)](https://travis-ci.org/jacob-long/panelr)[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/jacob-long/panelr?branch=master&svg=true)](https://ci.appveyor.com/project/jacob-long/panelr)[![Coverage Status](https://img.shields.io/codecov/c/github/jacob-long/panelr/master.svg)](https://codecov.io/github/jacob-long/panelr?branch=master)
16+
17+
18+
# panelr
19+
20+
This is an R package designed to aid in the analysis of panel data,
21+
designs in which the same group of respondents/entities are contacted/measured
22+
multiple times. `panelr` provides some useful infrastructure, like a
23+
`panel_data` object class, as well as automating some emerging methods for
24+
analyses of these data.
25+
26+
It automates the "within-between" (also known as
27+
"between-within" and "hybrid") specification that combines the
28+
desirable aspects of both fixed effects and random effects econometric models
29+
and fits them using the lme4 package in the backend. Bayesian estimation of
30+
these models is supported by interfacing with the brms package.
31+
32+
## Installation
33+
34+
At the moment, `panelr` is only available through Github. A submission to
35+
CRAN is coming soon.
36+
37+
```{r eval = FALSE}
38+
install.packages("devtools")
39+
devtools::install_github("jacob-long/panelr")
40+
```
41+
42+
Note the several dependencies: `dplyr`, `tidyr`, `lme4`, `pbkrtest`, `jtools`,
43+
`magrittr`, `stringr`, and `rlang`. You will need `brms` (and its dependencies,
44+
like `rstan`) to do Bayesian estimation.
45+
46+
## Usage
47+
48+
### `panel_data` frames
49+
50+
While not strictly required, the best way to start is to declare your data
51+
as panel data. I'll load the example data `WageData` to demonstrate.
52+
53+
```{r}
54+
library(panelr)
55+
data("WageData")
56+
colnames(WageData)
57+
```
58+
59+
The two key variables here are `t` and `id`. `t` is the wave of the survey the
60+
row of the data refers to while `id` is the survey respondent. This is a
61+
perfectly balanced data set, so there are 7 observations for each of the 595
62+
respondents. We will use those two pieces of information to create a
63+
`panel_data` object.
64+
65+
```{r}
66+
wages <- panel_data(WageData, id = id, wave = t)
67+
```
68+
69+
We have to tell `panel_data()` which column refers to the unique identifiers
70+
for respondents/entities (the latter when you have something like countries
71+
or companies instead of people) and which column refers to the period/wave of
72+
data collection. If the waves are not numeric and indexed starting at 1,
73+
the function will attempt to coerce them to that kind of numbering scheme.
74+
75+
Note that the resulting `panel_data` object will always use the column names
76+
`id` and `wave`, so it will overwrite those columns if they already exist in the
77+
source data. `panel_data` frames are modified tibbles
78+
([`tibble` package](http://tibble.tidyverse.org/)) that are grouped by entity.
79+
80+
### `wbm` --- the within-between model
81+
82+
Anyone can fit a within-between model without the use of this package as it is
83+
just a particular specification of a multilevel model. With that said, it's
84+
something that will require some programming and could be rather prone to
85+
error. In the best case, it is cumbersome and inefficient to create the
86+
necessary variables.
87+
88+
`wbm` is the primary function that you'll use from this package and it fits
89+
within-between models for you, utilizing
90+
[`lme4`](https://cran.r-project.org/web/packages/lme4/index.html) as a
91+
backend.
92+
93+
A three-part model syntax is used that goes like this:
94+
95+
`dv ~ varying_variables | invariant_variables | cross_level_interactions`
96+
97+
It works like a typical formula otherwise. The bars just tell `panelr` how to
98+
treat the variables. Note also that you can specify random slopes using
99+
`lme4`-style syntax in the third part of the formula as well.
100+
101+
Lagged variables are supported as well through the `lag` function. Unlike base
102+
R, `panelr` lags the variables correctly --- wave 1 observations will have NA
103+
values for the lagged variable rather than taking the final wave value of the
104+
previous entity.
105+
106+
Here we will specify a model using the `wages` data. We will predict
107+
logged wages (`lwage`) using two time-varying variables --- lagged
108+
union membership (`union`) and contemporaneous weeks worked (`wks`) --- along
109+
with a time-invariant predictor, a binary indicator for black race (`blk`).
110+
For demonstrative purposes, we'll fit a random slope for `wks` and an
111+
interaction between `blk` and `lag(union)`.
112+
113+
```{r message = FALSE}
114+
model <- wbm(lwage ~ lag(union) + wks | blk | blk * lag(union) + (wks | id),
115+
data = wages)
116+
summary(model)
117+
```
118+
119+
Note that `imean` is an internal function that calculates the individual-level
120+
mean, which represents the between-subjects effects of the time-varying
121+
predictors. The within effects are the time-varying predictors at the occasion
122+
level with the individal-level mean subtracted. If you want the model specified
123+
such that the occasion level predictors do not have the mean subtracted, use
124+
the `model = "contextual"` argument. The "contextual" label refers to the way
125+
these terms are normally interpreted when it is specified that way.
126+
127+
128+
## Contributing
129+
130+
I'm happy to receive bug reports, suggestions, questions, and (most of all)
131+
contributions to fix problems and add features. I prefer you use the Github
132+
issues system over trying to reach out to me in other ways. Pull requests for
133+
contributions are encouraged.
134+
135+
Please note that this project is released with a
136+
[Contributor Code of Conduct](CONDUCT.md). By participating in this project you
137+
agree to abide by its terms.
138+
139+
## License
140+
141+
The source code of this package is licensed under the
142+
[MIT License](http://opensource.org/licenses/mit-license.php).

cran-comments.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Test environments
2+
* local OS X install, R 3.4.3
3+
* local Ubuntu 17.04 install, R 3.4.3
4+
* ubuntu 12.04 (devel and release; on travis-ci), R 3.4.3
5+
* Windows 2012 Server (devel and release; on Appveyor)
6+
7+
## R CMD check results
8+
9+
0 errors | 0 warnings | 1 note
10+
11+
* This is a new release.
12+
13+
## Reverse dependencies
14+
15+
This is a new release, so there are no reverse dependencies. I will be
16+
submitting separately the package `clfe`, which will depend on this package.
17+
Since I develop both, I have control over their compatibility and they are
18+
indeed compatible.

0 commit comments

Comments
 (0)