Skip to content

Commit 7f28175

Browse files
committed
Add CPS 1985 dataset
1 parent a45a016 commit 7f28175

21 files changed

Lines changed: 2242 additions & 0 deletions

File tree

lib/node_modules/@stdlib/datasets/cps-wages-1985/LICENSE

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2018 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# CPS Wages Data
22+
23+
> Data of a random sample of 534 workers from the Current Population Survey (CPS) from 1985.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var cps = require( '@stdlib/datasets/cps-wages-1985' );
37+
```
38+
39+
#### cps()
40+
41+
Returns data of a random sample of 534 workers from the Current Population Survey (CPS) from 1985, including their wages and and other characteristics.
42+
43+
```javascript
44+
var data = cps();
45+
// returns [{...},{...},...]
46+
```
47+
48+
Each `array` element has the following eleven fields:
49+
50+
- **education**: number of years of education.
51+
52+
- **south**: indicator variable for southern region (1 = person lives in the
53+
South, 0 = person does not live in the South).
54+
55+
- **gender**: indicator for the gender of the person (1 = female, 0 = male).
56+
57+
- **experience**: number of years of work experience.
58+
59+
- **union**: indicator variable for union membership (1 = union member, 0 = not
60+
a union member).
61+
62+
- **wage**: wage (in dollars per hour).
63+
64+
- **age**: age (in years).
65+
66+
- **race**: ethnicity/race ('White', 'Hispanic', and 'Other').
67+
68+
- **occupation**: occupational category ('Management', 'Sales', 'Clerical',
69+
'Service', 'Professional', and 'Other').
70+
71+
- **sector**: sector ('Other', 'Manufacturing', or 'Construction').
72+
73+
- **married**: marital Status (0 = unmarried, 1 = married).
74+
75+
</section>
76+
77+
<!-- /.usage -->
78+
79+
<section class="examples">
80+
81+
## Examples
82+
83+
<!-- eslint no-undef: "error" -->
84+
85+
```javascript
86+
var Plot = require( '@stdlib/plot' );
87+
var dataset = require( '@stdlib/datasets/cps-wages-1985' );
88+
89+
var data;
90+
var plot;
91+
var opts;
92+
var x;
93+
var y;
94+
var i;
95+
96+
data = dataset();
97+
98+
// Extract housing data...
99+
x = [];
100+
y = [];
101+
for ( i = 0; i < data.length; i++ ) {
102+
x.push( data[ i ].age );
103+
y.push( data[ i ].wage );
104+
}
105+
106+
// Create a plot instance:
107+
opts = {
108+
'lineStyle': 'none',
109+
'symbols': 'closed-circle'
110+
};
111+
plot = new Plot( [ x ], [ y ], opts );
112+
```
113+
114+
</section>
115+
116+
<!-- /.examples -->
117+
118+
* * *
119+
120+
<section class="cli">
121+
122+
## CLI
123+
124+
<section class="usage">
125+
126+
### Usage
127+
128+
```text
129+
Usage: cps-wages-1985 [options]
130+
131+
Options:
132+
133+
-h, --help Print this message.
134+
-V, --version Print the package version.
135+
--format fmt Output format: 'csv' or 'ndjson'.
136+
```
137+
138+
</section>
139+
140+
<!-- /.usage -->
141+
142+
<section class="notes">
143+
144+
### Notes
145+
146+
- The CLI supports two output formats: comma-separated values ([CSV][csv]) and newline-delimited JSON ([NDJSON][ndjson]). The default output format is [CSV][csv].
147+
148+
</section>
149+
150+
<!-- /.notes -->
151+
152+
<section class="examples">
153+
154+
### Examples
155+
156+
```bash
157+
$ cps-wages-1985
158+
education,south,gender,experience,union,wage,age,race,occupation,sector,married
159+
8,0,female,21,1,5.1,35,hispanic,other,manufacturing,0
160+
9,0,female,42,1,4.95,57,white,other,manufacturing,0
161+
12,0,male,1,1,6.67,19,white,other,manufacturing,1
162+
12,0,male,4,1,4,22,white,other,other,1
163+
12,0,male,17,1,7.5,35,white,other,other,0
164+
...
165+
```
166+
167+
</section>
168+
169+
<!-- /.examples -->
170+
171+
</section>
172+
173+
<!-- /.cli -->
174+
175+
<section class="references">
176+
177+
## References
178+
179+
- Berndt, ER. The Practice of Econometrics. 1991. NY: Addison-Wesley.
180+
181+
</section>
182+
183+
<!-- /.references -->
184+
185+
<!-- <license> -->
186+
187+
* * *
188+
189+
## License
190+
191+
The data files (databases) are licensed under an [Open Data Commons Public Domain Dedication & License 1.0][pddl-1.0] and their contents are licensed under [Creative Commons Zero v1.0 Universal][cc0]. The software is licensed under [Apache License, Version 2.0][apache-license].
192+
193+
<!-- </license> -->
194+
195+
<section class="links">
196+
197+
[csv]: https://tools.ietf.org/html/rfc4180
198+
199+
[ndjson]: http://specs.frictionlessdata.io/ndjson/
200+
201+
[pddl-1.0]: http://opendatacommons.org/licenses/pddl/1.0/
202+
203+
[cc0]: https://creativecommons.org/publicdomain/zero/1.0
204+
205+
[apache-license]: https://www.apache.org/licenses/LICENSE-2.0
206+
207+
</section>
208+
209+
<!-- /.links -->
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isObjectArray = require( '@stdlib/assert/is-plain-object-array' );
25+
var pkg = require( './../package.json' ).name;
26+
var cps = require( './../lib/browser.js' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg+'::browser', function benchmark( b ) {
32+
var data;
33+
var i;
34+
b.tic();
35+
for ( i = 0; i < b.iterations; i++ ) {
36+
data = cps();
37+
if ( data.length === 0 ) {
38+
b.fail( 'should have a length greater than 0' );
39+
}
40+
}
41+
b.toc();
42+
if ( !isObjectArray( data ) ) {
43+
b.fail( 'should return an object array' );
44+
}
45+
b.pass( 'benchmark finished' );
46+
b.end();
47+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
25+
var isObjectArray = require( '@stdlib/assert/is-plain-object-array' );
26+
var pkg = require( './../package.json' ).name;
27+
var cps = require( './../lib' );
28+
29+
30+
// VARIABLES //
31+
32+
var opts = {
33+
'skip': IS_BROWSER
34+
};
35+
36+
37+
// MAIN //
38+
39+
bench( pkg, opts, function benchmark( b ) {
40+
var data;
41+
var i;
42+
b.tic();
43+
for ( i = 0; i < b.iterations; i++ ) {
44+
data = cps();
45+
if ( data.length === 0 ) {
46+
b.fail( 'should have a length greater than 0' );
47+
}
48+
}
49+
b.toc();
50+
if ( !isObjectArray( data ) ) {
51+
b.fail( 'should return an object array' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
});

0 commit comments

Comments
 (0)