<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/did-wages-detach-from-productivity-in-1973-an-investigation/"></div></div><div><a data-url="https://www.r-bloggers.com/did-wages-detach-from-productivity-in-1973-an-investigation/" data-counturl="https://www.r-bloggers.com/did-wages-detach-from-productivity-in-1973-an-investigation/" data-count="horizontal" data-text="Did Wages Detach from Productivity in 1973? An Investigation" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://ntguardian.wordpress.com/2016/09/12/wages-detach-productivity-1973/"> R – Curtis Miller's Personal Website</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><em>This is the third and final blog post in my series on income inequality (read the other two <a target="_blank" href="https://ntguardian.wordpress.com/2016/08/29/game-of-bank-bargains/">here </a>and <a target="_blank" href="https://ntguardian.wordpress.com/2016/09/05/money-is-power-the-consequences-of-economic-inequality/">here</a>). This post discusses the detachment of compensation from productivity that occurred around 1973. I look at the data and use R for exploring this break, along with why it may have occurred. R code is with the analysis, in the spirit of reproducible research.</em></p>
<p><span></span>This series on income inequality was originally inspired by <a target="_blank" href="http://www.eoionline.org/blog/x-marks-the-spot-where-inequality-took-root-dig-here/">this article by Stan Sorscher</a>. We see this chart in the article:</p>
<p><img><img alt="2q%3d%3d" class="wp-image-1038" src="https://i2.wp.com/ntguardian.files.wordpress.com/2016/09/2q3d3d.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p>I was stunned when I first saw Dr. Sorscher’s <sup><a target="_blank" href="https://ntguardian.wordpress.com/2016/09/12/wages-detach-productivity-1973/#fn-1017-1">1</a></sup> chart. It appears as if something <strong>big</strong> happened in 1973 to unhinge wages from productivity. The kink in the chart is the smoking gun. Workers from that point on are robbed of the fruit of their labor, yet the chart suggests that somehow this can be fixed, since something <em>did</em> this.</p>
<p>However, Dr. Sorscher claims that no such smoking gun exists. Instead of there being some economic explanation, he waxes on about the loss of shift of American values to a “greed is good” mentality, that the kink of 1973 reflects the point when this shift occurs, and ever since then, capitalists and policy makers simply found it easier and more acceptable to rob the working man of his wages. The fix? Shift the culture back to one where we cared about everyone.</p>
<p>I don’t necessarily disagree with the idea that a shift in the mentality of Americans has occured. Once, the United States was an egalitarian beacon that other nations sought to emulate. The Roosevelts did much to limit corporate power and establish a friendly environment for workers. Then Reagan escalated the Cold War and managed to link anything that would seem to inhibit the workings of free markets with <em>COMMUNISM</em> (<em>gasp</em>) and thus must be reviled. In the process of resisting Communism, we forgot the principles that made us the envy of the world and ensured the majority of Americans a decent living. And I hope someday we remember who we once were.</p>
<p>That said, I disagree with Dr. Sorscher. A kink like the one in 1973 suggests more than his explanation. First, values do not change overnight. Second, claiming a shift in values must be accompanied with some example, and if 1973 is the year the shift occured we should be able to find <em>some</em> event in 1973 that suggests the shift has occured. Finally, claiming that our problems are due to a change in <em>just</em> values is not actionable; values must translate to policy and practice in order to be of any effect, and if we are to fix the problem of stagnating wages and growing inequality, we must identify the policies and practices responsible for the problem in order to fix them.</p>
<p>Thus, I sought to replicate Dr. Sorscher’s results, but in doing so discovered some holes in his analysis, which suggest that perhaps this detachment of wages from productivity may not even have occured. We shall see why below.</p>
<p>(Throughout this post, I will be using R to analyze the datasets relevant to this topic, and the code will be intermixed through the text. For the R coders reading this post, enjoy. For the rest, there is a reason why I do this. I subscribe to the philosophy of <a target="_blank" href="https://en.wikipedia.org/wiki/Reproducibility#Reproducible_research">reproducible research</a>, which says results and code should be shown simultaneously for both checking and confirming results and also building upon them. If you don’t like code, ignore it. You may still find parts you like.)</p>
<h2>Getting the data</h2>
<p>Dr. Sorscher’s charts claim to use data from the <a target="_blank" href="http://www.bls.gov/">Bureau of Labor Statistics</a>, one of the most important sources for U.S. economic data. The series in his charts include major sector productivity and wages for workers in goods-producing industries. I did my best to find data matching that in his charts, but unfortunately I was able only to replicate the series on productivity, not the series for wages. That said, I do not feel it fair to use only workers in goods-producing industries and productivity in all major sectors, since this is an apples-to-oranges comparison. So I feel fine about the fact that I use real hourly wages for all major-sector workers rather than those in goods-producing industries.</p>
<p>Instead of just downloading the data directly from the BLS website, I decided to take advantage of the BLS data API and the R implementation of that API. See the code below for how to install the API from GitHub.</p>
<pre># devtools::install_github(&quot;mikeasilva/blsAPI&quot;)
# API for BLS website
library(blsAPI)
library(rjson)
library(dplyr)

# Because I want to concatenate strings like a python programmer, damnit!
`%s%` &lt;- function(x,y) {paste(x,y)}
`%s0%` &lt;- function(x,y) {paste0(x,y)}</pre>
<p>The version of the BLS API I am using restricts the number of years for which you can get data in any given call (why they do this is beyond me). So I get data in batches of five years and create a data frame containing the data set.</p>
<pre>
series_df &lt;- data.frame(&quot;quarter&quot; = list(),&quot;productivity&quot; = list(),&quot;compensation&quot; = list())
for (year in (1947 + 5 * (0:((2016 - 1947)/5)))) {
    payload &lt;- list(
        'seriesid' = c(&quot;PRS84006093&quot;,&quot;PRS84006153&quot;), # Series ID's
        # PRS84006093 is labor productivity (output per hour) in business sector
        # PRS84006153 is real hourly compensation in business sector
        &quot;startyear&quot; = year,
        &quot;endyear&quot; = min(year + 4, 2016),
        &quot;registrationKey&quot; = api_key
    )
    response &lt;- blsAPI(payload, 2) %>% fromJSON   # Parse response
    # Update data frame with new information
    series_df &lt;- bind_rows(series_df, bind_rows(
        # Make a data frame with each productivity value for a time point; this will be
        # a row that will be joined together into a complete data frame
        lapply(response$Results$series[[1]]$data, function(x)
            list(&quot;quarter&quot; = x$year %s0% x$period, &quot;productivity&quot; = x$value))
        # Join with compensation data
    ) %>% full_join(bind_rows(
        # Make a data frame with each compensation value for a time point; this will be
        # a row that will be joined together into a complete data frame
        lapply(response$Results$series[[2]]$data, function(x)
            list(&quot;quarter&quot; = x$year %s0% x$period, &quot;compensation&quot; = x$value))
    )))
    Sys.sleep(5)  # Wait 5 seconds before next request
}
series_df &lt;- arrange(series_df, quarter)

# Create a multivariate time series object
series_ts &lt;- ts(series_df[c(&quot;productivity&quot;, &quot;compensation&quot;)], start = c(1947,1),frequency = 4)
head(series_ts)
</pre>
<pre>##      productivity compensation
## [1,]       21.499       33.407
## [2,]       21.601       33.894
## [3,]       21.407       33.658
## [4,]       21.686       33.936
## [5,]       22.179       33.686
## [6,]       22.633       33.535
</pre>
<pre>plot(series_ts)
</pre>
<p><img alt="a8rv9sqhcmaaaaasuvork5cyii" class="wp-image-1039" src="https://i2.wp.com/ntguardian.files.wordpress.com/2016/09/a8rv9sqhcmaaaaasuvork5cyii.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>The data above is enough for me to recreate (as close as I can) Dr. Sorscher’s chart, but I will also want to look at the percentage change in these series between quarters. So I repeat the process with two other series, representing these percentage changes. (I would rather use the BLS data directly than compute this myself, to ensure some consistency.)</p>
<pre>
series_df_delta &lt;- data.frame(&quot;quarter&quot; = list(),&quot;productivity&quot; = list(),&quot;compensation&quot; = list())
for (year in (1947 + 5 * (0:((2016 - 1947)/5)))) {
    payload &lt;- list(
        'seriesid' = c(&quot;PRS84006092&quot;,&quot;PRS84006152&quot;), # Series ID's
        # PRS84006092 is % change in labor productivity (output per hour) in business sector since previous quarter
        # PRS84006152 is % change in real hourly compensation in business sector since previous quarter
        &quot;startyear&quot; = year,
        &quot;endyear&quot; = min(year + 4, 2016),
        &quot;registrationKey&quot; = api_key
    )
    response &lt;- blsAPI(payload, 2) %>% fromJSON   # Parse response
    # Update data frame with new information
    series_df_delta &lt;- bind_rows(series_df_delta, bind_rows(
        # Make a data frame with each productivity value for a time point; this will be
        # a row that will be joined together into a complete data frame
        lapply(response$Results$series[[1]]$data, function(x)
            list(&quot;quarter&quot; = x$year %s0% x$period, &quot;productivity&quot; = x$value))
        # Join with compensation data
    ) %>% full_join(bind_rows(
        # Make a data frame with each compensation value for a time point; this will be
        # a row that will be joined together into a complete data frame
        lapply(response$Results$series[[2]]$data, function(x)
            list(&quot;quarter&quot; = x$year %s0% x$period, &quot;compensation&quot; = x$value))
    )))
    Sys.sleep(5)  # Wait 5 seconds before next request
}
series_df_delta &lt;- arrange(series_df_delta, quarter)

# Create a multivariate time series object
series_ts_delta &lt;- ts(series_df_delta[c(&quot;productivity&quot;, &quot;compensation&quot;)], start = c(1947,1),frequency = 4)
head(series_ts_delta)
</pre>
<pre>##      productivity compensation
## [1,]          1.9          6.0
## [2,]         -3.5         -2.8
## [3,]          5.3          3.3
## [4,]          9.4         -2.9
## [5,]          8.4         -1.8
## [6,]         -1.9          4.1
</pre>
<pre>plot(series_ts_delta)
</pre>
<p><img alt="zxampmvvt2yaaaaasuvork5cyii" class="wp-image-1043" src="https://i0.wp.com/ntguardian.files.wordpress.com/2016/09/zxampmvvt2yaaaaasuvork5cyii.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>The data is an index, with 2009 constituting 100. The year 1973 is of special interest, so I reindex to make 1970 the value 100 (for the average) for both series, as done in Dr. Sorscher’s chart.</p>
<pre>
means_70 &lt;- apply(window(series_ts, start = c(1970,1), end = c(1970,4)),2,mean)
series_ts[,&quot;productivity&quot;] &lt;- series_ts[,&quot;productivity&quot;] / means_70[&quot;productivity&quot;] * 100
series_ts[,&quot;compensation&quot;] &lt;- series_ts[,&quot;compensation&quot;] / means_70[&quot;compensation&quot;] * 100
plot(series_ts)
</pre>
<p><img alt="wmnn6pw1ntinaaaaabjru5erkjggg" class="wp-image-1041" src="https://i0.wp.com/ntguardian.files.wordpress.com/2016/09/wmnn6pw1ntinaaaaabjru5erkjggg.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h2>Plotting the data</h2>
<p>The charts I made earlier are only preliminary. I use <strong>ggplot2</strong> to actually make a nice chart comparable to the one near the beginning of this post.</p>
<pre>
library(ggplot2)
library(ggthemes)   # Nice ggplot2 themes, like the Economist
library(reshape)

plot_df &lt;- melt(series_ts) %>% arrange(X1)
plot_df$X1 &lt;- rep(series_ts %>% time %>% as.vector, each = 2)
names(plot_df) &lt;- c(&quot;Year&quot;, &quot;Series&quot;, &quot;Index&quot;)
ggplot(plot_df, aes(x = Year, y = Index, group = Series)) +
    geom_line(aes(color = Series), size = 1.4) + 
    ggtitle(&quot;U.S. Business Sector Productivity and\nReal Compensation (1973 is 100)&quot;) +
    theme_economist_white() +
    scale_color_economist()
</pre>
<p><img alt="d4b1276zsqfzaaaaaelftksuqmcc" class="wp-image-1040" src="https://i1.wp.com/ntguardian.files.wordpress.com/2016/09/d4b1276zsqfzaaaaaelftksuqmcc.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>The break in my chart is not as dramatic in Dr. Sorscher’s, and I was unable to find a series for wages that does replicate that dramatic break. There is another problem, though: making 1970 the value 100 guarantees that the two charts will intersect there, which may distort the interpretation of the chart. Choosing that base year to be 100 may be distorting how we view the data. If we were to make 1947 (the beginning of the series) the index value 100, would the chart have the same dramatic break at 1973?</p>
<pre>
series_ts_47 &lt;- series_ts
series_ts_47[,&quot;productivity&quot;] &lt;- series_ts[,&quot;productivity&quot;] / series_ts[1,&quot;productivity&quot;] * 100
series_ts_47[,&quot;compensation&quot;] &lt;- series_ts[,&quot;compensation&quot;] / series_ts[1,&quot;compensation&quot;] * 100

plot_df_47 &lt;- melt(series_ts_47) %>% arrange(X1)
plot_df_47$X1 &lt;- rep(series_ts_47 %>% time %>% as.vector, each = 2)
names(plot_df_47) &lt;- c(&quot;Year&quot;, &quot;Series&quot;, &quot;Index&quot;)
ggplot(plot_df_47, aes(x = Year, y = Index, group = Series)) +
    geom_line(aes(color = Series), size = 1.4) + 
    ggtitle(&quot;U.S. Business Sector Productivity and\nReal Compensation (1947 is 100)&quot;) +
    theme_economist_white() +
    scale_color_economist()
</pre>
<p> </p>
<p><img alt="ebv0h8qt5hqaaaabjru5erkjggg" class="wp-image-1052" src="https://i1.wp.com/ntguardian.files.wordpress.com/2016/09/ebv0h8qt5hqaaaabjru5erkjggg.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>See the difference? It’s clear that the choice of base year was influencing perception of the chart and its data. There may still be a kink around 1973, but if it does exist, it does not appear quite so dramatic. Thus, we may need to rethink the problem and question:</p>
<ol>
<li>whether a change occured at all, and</li>
<li>whether that change occured in 1973.</li>
</ol>
<p>It’s here that I introduce change point analysis.</p>
<h2>Change point analysis and the CUSUM test</h2>
<p>Consider the model:</p>
<p><img title="X_t = \begin{cases}  \mu + \epsilon_t &amp; 1 \leq t &lt; t^{*} \\  \mu + \Delta + \epsilon_t &amp; t^{*} \leq t \leq T  \end{cases}" alt="X_t = \begin{cases}  \mu + \epsilon_t &amp; 1 \leq t &lt; t^{*} \\  \mu + \Delta + \epsilon_t &amp; t^{*} \leq t \leq T  \end{cases}" class="latex" src="https://s0.wp.com/latex.php?latex=X_t+%3D+%5Cbegin%7Bcases%7D++%5Cmu+%2B+%5Cepsilon_t+%26+1+%5Cleq+t+%3C+t%5E%7B%2A%7D+%5C%5C++%5Cmu+%2B+%5CDelta+%2B+%5Cepsilon_t+%26+t%5E%7B%2A%7D+%5Cleq+t+%5Cleq+T++%5Cend%7Bcases%7D&bg=ffffff&%23038;fg=444444&%23038;s=0"></p>
<p>where <img title="X_t" alt="X_t" class="latex" src="https://s0.wp.com/latex.php?latex=X_t&bg=ffffff&%23038;fg=444444&%23038;s=0"> represents our data, <img title="\mu" alt="\mu" class="latex" src="https://s0.wp.com/latex.php?latex=%5Cmu&bg=ffffff&%23038;fg=444444&%23038;s=0"> the mean up to the unknown change point <img title="t^{*}" alt="t^{*}" class="latex" src="https://s0.wp.com/latex.php?latex=t%5E%7B%2A%7D&bg=ffffff&%23038;fg=444444&%23038;s=0">, <img title="\mu + \Delta" alt="\mu + \Delta" class="latex" src="https://s0.wp.com/latex.php?latex=%5Cmu+%2B+%5CDelta&bg=ffffff&%23038;fg=444444&%23038;s=0"> the mean after the change, and <img title="\epsilon" alt="\epsilon" class="latex" src="https://s0.wp.com/latex.php?latex=%5Cepsilon&bg=ffffff&%23038;fg=444444&%23038;s=0"> a white noise term with mean 0. The data is indexed from <img title="t = 1" alt="t = 1" class="latex" src="https://s0.wp.com/latex.php?latex=t+%3D+1&bg=ffffff&%23038;fg=444444&%23038;s=0"> to <img title="t = T" alt="t = T" class="latex" src="https://s0.wp.com/latex.php?latex=t+%3D+T&bg=ffffff&%23038;fg=444444&%23038;s=0">, and is considered sequential.</p>
<p>In words, a series centers around a common mean up until an unknown point in time, when the series might suddenly change its mean.</p>
<p>We wish to test:</p>
<p><img title="H_{0}: \Delta = 0" alt="H_{0}: \Delta = 0" class="latex" src="https://s0.wp.com/latex.php?latex=H_%7B0%7D%3A+%5CDelta+%3D+0&bg=ffffff&%23038;fg=444444&%23038;s=0"><br>
<img title="H_{A}: \Delta \neq 0" alt="H_{A}: \Delta \neq 0" class="latex" src="https://s0.wp.com/latex.php?latex=H_%7BA%7D%3A+%5CDelta+%5Cneq+0&bg=ffffff&%23038;fg=444444&%23038;s=0"></p>
<p>In words, we test the null hypothesis that no change occurs against the alternative hypothesis that states that the mean does change, though we don’t know where this change occurs.</p>
<p>The problem we have been discussing calls for a test like this. We neither can claim to know whether a change occured nor when it did (if we did know, we could simply use a two-sample t-test). Fortunately, change point analysis is a well-studied problem.</p>
<p>To perform this test, I use the CUSUM statistic:</p>
<p><img title="A_T = T^{-\frac{1}{2}} \max_{1 \leq t \leq T} \hat{\sigma}_t^{-1} \left| \sum_{s = 1}^{t} X_s - \frac{t}{T}\sum_{s = 1}^{T} X_s \right|" alt="A_T = T^{-\frac{1}{2}} \max_{1 \leq t \leq T} \hat{\sigma}_t^{-1} \left| \sum_{s = 1}^{t} X_s - \frac{t}{T}\sum_{s = 1}^{T} X_s \right|" class="latex" src="https://s0.wp.com/latex.php?latex=A_T+%3D+T%5E%7B-%5Cfrac%7B1%7D%7B2%7D%7D+%5Cmax_%7B1+%5Cleq+t+%5Cleq+T%7D+%5Chat%7B%5Csigma%7D_t%5E%7B-1%7D+%5Cleft%7C+%5Csum_%7Bs+%3D+1%7D%5E%7Bt%7D+X_s+-+%5Cfrac%7Bt%7D%7BT%7D%5Csum_%7Bs+%3D+1%7D%5E%7BT%7D+X_s+%5Cright%7C&bg=ffffff&%23038;fg=444444&%23038;s=0"></p>
<p><img title="A_T" alt="A_T" class="latex" src="https://s0.wp.com/latex.php?latex=A_T&bg=ffffff&%23038;fg=444444&%23038;s=0"> is the CUSUM statistic, and <img title="\hat{\sigma}_t" alt="\hat{\sigma}_t" class="latex" src="https://s0.wp.com/latex.php?latex=%5Chat%7B%5Csigma%7D_t&bg=ffffff&%23038;fg=444444&%23038;s=0"> is an estimator for the long-run variance presuming that the change occured at <img title="t" alt="t" class="latex" src="https://s0.wp.com/latex.php?latex=t&bg=ffffff&%23038;fg=444444&%23038;s=0">. If we wish to estimate where the change occured, we can do so with:</p>
<p><img title="\hat{t^{*}} = \arg\max_{1 \leq t \leq T} \hat{\sigma}_t^{-1} \left| \sum_{s = 1}^{t} X_s - \frac{t}{T}\sum_{s = 1}^{T} X_s \right|" alt="\hat{t^{*}} = \arg\max_{1 \leq t \leq T} \hat{\sigma}_t^{-1} \left| \sum_{s = 1}^{t} X_s - \frac{t}{T}\sum_{s = 1}^{T} X_s \right|" class="latex" src="https://s0.wp.com/latex.php?latex=%5Chat%7Bt%5E%7B%2A%7D%7D+%3D+%5Carg%5Cmax_%7B1+%5Cleq+t+%5Cleq+T%7D+%5Chat%7B%5Csigma%7D_t%5E%7B-1%7D+%5Cleft%7C+%5Csum_%7Bs+%3D+1%7D%5E%7Bt%7D+X_s+-+%5Cfrac%7Bt%7D%7BT%7D%5Csum_%7Bs+%3D+1%7D%5E%7BT%7D+X_s+%5Cright%7C&bg=ffffff&%23038;fg=444444&%23038;s=0"></p>
<p>The limiting distribution of the CUSUM distribution is the distribution of <img title="\sup_{t\in[0,1]}|B(t)|" alt="\sup_{t\in[0,1]}|B(t)|" class="latex" src="https://s0.wp.com/latex.php?latex=%5Csup_%7Bt%5Cin%5B0%2C1%5D%7D%7CB%28t%29%7C&bg=ffffff&%23038;fg=444444&%23038;s=0">, and has the cumulative distribution function:</p>
<p><img title="F(x) = \frac{\sqrt{2\pi}}{x}\sum_{k=1}^\infty e^{-(2k-1)^2\pi^2/(8x^2)}" alt="F(x) = \frac{\sqrt{2\pi}}{x}\sum_{k=1}^\infty e^{-(2k-1)^2\pi^2/(8x^2)}" class="latex" src="https://s0.wp.com/latex.php?latex=F%28x%29+%3D+%5Cfrac%7B%5Csqrt%7B2%5Cpi%7D%7D%7Bx%7D%5Csum_%7Bk%3D1%7D%5E%5Cinfty+e%5E%7B-%282k-1%29%5E2%5Cpi%5E2%2F%288x%5E2%29%7D&bg=ffffff&%23038;fg=444444&%23038;s=0"></p>
<p>We thus reject the null hypothesis if <img title="1 - F(A_T)" alt="1 - F(A_T)" class="latex" src="https://s0.wp.com/latex.php?latex=1+-+F%28A_T%29&bg=ffffff&%23038;fg=444444&%23038;s=0"> is small.</p>
<p>The functions below allow for implementing the CUSUM test for change in mean.</p>
<pre>
#include &lt;Rcpp.h>
using namespace Rcpp;

// Function to be wrapped; to be used only in statVn; see a description
// there

// [[Rcpp::export]]
NumericVector statVn_cpp(NumericVector dat, double kn, double tau) {
    double n = dat.size();
    // Get total sum and sum of squares; this will be the &quot;upper sum&quot;
    // (i.e. the sum above k)
    double s_upper = 0, s_square_upper = 0;
    // The &quot;lower sums&quot; (i.e. those below k)
    double s_lower = 0, s_square_lower = 0;
    // Get lower sums
    // Go to kn - 1 to prevent double-counting in main
    // loop
    for (int i = 0; i &lt; kn - 1; ++i) {
        s_lower += dat[i];
        s_square_lower += dat[i] * dat[i];
    }
    // Get upper sum
    for (int i = kn - 1; i &lt; n; ++i) {
        s_upper += dat[i];
        s_square_upper += dat[i] * dat[i];
    }
    // The maximum, which will be returned
    double M = 0;
    // A candidate for the new maximum, used in a loop+
    double M_candidate;
    // Get the complete upper sum
    double s_total = s_upper + s_lower;
    // Estimate for change location
    int est = n;
                    
    // Compute the test statistic
    for (int k = kn; k &lt;= (n - kn); ++k) {
        // Update s and s_square for both lower and upper
        s_lower += dat[k-1];
        s_square_lower += dat[k-1] * dat[k-1];
        s_upper -= dat[k-1];
        s_square_upper -= dat[k-1] * dat[k-1];
                        
        // Get estimate of sd for this k
        double sdk = std::sqrt((s_square_lower - s_lower * s_lower / k +
            s_square_upper - s_upper * s_upper / (n - k))/n);
        M_candidate = std::abs(s_lower - (k / n) * s_total) / sdk /
                        std::pow(k / n * (n - k) / n, tau);
        // Choose new maximum
        if (M_candidate > M) {
            M = M_candidate;
            est = k;
        }
    }
    // Final step; the maximum M should be normalized
    M /= std::sqrt(n);
                
    return NumericVector::create(M, est);
}
</pre>
<pre>
statVn &lt;- function(dat, kn = function(n) {1}, tau = 0, estimate = FALSE) {
    ## Computes the Vn statistic
    ##
    ## :param dat: vector; The data vector
    ## :param kn: function; A function that corresponds to the k_n
    ##      function in the (trimmed) CUSUM variant; by default, is
    ##      a function returning 0 (no trimming)
    ##  :param tau: numeric; The weighting parameter for the
    ##      weighted CUSUM statistc; by default, is 0
    ##  :param estimate: integer; Whether to return the estimated
    ##      location of the change point
    ##
    ## :return: numeric; The resulting test statistic
    ##
    ## This function (written in C++) computes the CUSUM statistic, Vn,
    ## and returns the resulting statistic. Changing the parameters kn
    ## and tau allow for weighted and trimmed variants of the CUSUM
    ## statistic.
    
    # Here is equivalent (slow) R code
    # n = length(dat)
    # return(n^(-1/2)*max(sapply(
    #     floor(max(kn(n),1)):min(n - floor(kn(n)),n-1), function(k)
    #         (k/n*(1 - k/n))^(-tau)/
    #         sqrt((sum((dat[1:k] -
    #            mean(dat[1:k]))^2)+sum((dat[(k+1):n] -
    #            mean(dat[(k+1):n]))^2))/n)*
    #         abs(sum(dat[1:k]) - k/n*sum(dat))
    # )))
    
    res &lt;- statVn_cpp(dat, kn(length(dat)), tau)
    names(res) &lt;- c(&quot;statistic&quot;, &quot;estimate&quot;)
    res[2] &lt;- as.integer(res[2])
    if (estimate) {
        return(res)
    } else {
        return(res[[1]])
    }
}

pKolmogorov &lt;- function(q, summands = 500) {
    ## A function for computing the distribution function of sup|B(t)|
    ##
    ## q: numeric; The quantile to compute the probability for
    ## summands: integer; The number of summands to include
    ##    in the sum
    ## (return): numeric; The probability associatecd with
    ##    the quantile.
    ##
    ## This function computes P(K &lt; q), where K is
    ## sup_(0&lt;t&lt;1)|B(t)|. The formula for computing this
    ## is
    ## sqrt(2pi)/x sum_(i=1)^(infty) exp(-(2i-1)^2pi^2/
    ## (8x^2))
    
    return(sqrt(2*pi)*sapply(q, function(x) { if (x > 0) {
        return(sum(exp(-(2*(1:summands)-1)^2*pi^2/(8*x^2)))/x)
    } else {
        return(0)
    }}))
}

CUSUM.test &lt;- function(x) {
    ## Cleanly performs the CUSUM test
    ##
    ## :param x: numeric; Data to test for changepoint
    ##
    ## :return: htest; List of class htest containing
    ##      test description and results.
    ##
    ## Performs a CUSUM test for change in mean.
    
    testobj &lt;- list()
    testobj$method &lt;- &quot;CUSUM Test for Change in Mean&quot;
    testobj$data.name &lt;- deparse(substitute(x))
    
    res &lt;- statVn(x, estimate = TRUE)
    stat &lt;- res[[1]]
    est &lt;- res[[2]]
    attr(stat, &quot;names&quot;) &lt;- &quot;A&quot;
    attr(est, &quot;names&quot;) &lt;- &quot;t*&quot;
    testobj$p.value &lt;- 1 - pKolmogorov(res[1])
    testobj$estimate &lt;- est
    testobj$statistic &lt;- stat
    
    class(testobj) &lt;- &quot;htest&quot;
    return(testobj)
}
</pre>
<h2>Results</h2>
<p>Since the data trends, we apply the CUSUM test for change in mean to the percentage change between quarters. Thus, we are testing whether the rate of increase of productivity and compensation changes during the period in question. The results of the test are below:</p>
<pre>apply(series_ts_delta, 2, CUSUM.test)
</pre>
<pre>## $productivity
##
##  CUSUM Test for Change in Mean
##
## data:  newX[, i]
## A = 1.7258, p-value = 0.005178
## sample estimates:
##  t*
## 104
##
##
## $compensation
##
##  CUSUM Test for Change in Mean
##
## data:  newX[, i]
## A = 2.154, p-value = 0.0001867
## sample estimates:
##  t*
## 104
</pre>
<pre>time(series_ts_delta)[104]
</pre>
<pre>## [1] 1972.75
</pre>
<p>It seems that the best estimate for the location of the change is Q3 1972, so we can say that the change occured around 1973. That said, notice that <em>both</em> productivity <em>and</em> compensation changed at that time, not just compensation.</p>
<p>I now estimate the growth rates of both series before and after the change</p>
<pre>apply(series_ts_delta[1:103,], 2, mean)
</pre>
<pre>## productivity compensation
##     3.311650     2.900971
</pre>
<pre>apply(series_ts_delta[-c(1:103),], 2, mean)
</pre>
<pre>## productivity compensation
##     1.847126     1.016667
</pre>
<p>Productivity growth dropped from 3.3% a quarter to 1.8% a quarter, and compensation (wage) growth dropped from 2.9% a quarter to 1% a quarter. A large drop for both series.</p>
<p>We can check for other change points by considering the data sets broken at the change point to be two separate data sets, and then reapply the test:</p>
<pre>apply(series_ts_delta[1:103,], 2, CUSUM.test) # Changes before 1973?
</pre>
<pre>## $productivity
##
##  CUSUM Test for Change in Mean
##
## data:  newX[, i]
## A = 0.50499, p-value = 0.9607
## sample estimates:
## t*
## 18
##
##
## $compensation
##
##  CUSUM Test for Change in Mean
##
## data:  newX[, i]
## A = 0.67167, p-value = 0.7577
## sample estimates:
## t*
## 52
</pre>
<pre>apply(series_ts_delta[-c(1:103),], 2, CUSUM.test) # Changes after 1973?
</pre>
<pre>## $productivity
##
##  CUSUM Test for Change in Mean
##
## data:  newX[, i]
## A = 0.88028, p-value = 0.4205
## sample estimates:
##  t*
## 148
##
##
## $compensation
##
##  CUSUM Test for Change in Mean
##
## data:  newX[, i]
## A = 0.5727, p-value = 0.8982
## sample estimates:
## t*
## 91
</pre>
<p>There is no evidence for other change points. 1973 is special.</p>
<p>It looks as if productivity growth dropped by half and compensation growth dropped to a third, but can we say that they detached, as Dr. Sorscher claims? To investigate this, I look at the series of <em>differences</em> between productivity growth and compensation growth.</p>
<pre>
CUSUM.test(series_ts_delta[,&quot;productivity&quot;] - series_ts_delta[,&quot;compensation&quot;])
</pre>
<pre>
##
##  CUSUM Test for Change in Mean
##
## data:  series_ts_delta[,&quot;productivity&quot;] - series_ts_delta[,&quot;compensation&quot;]
## A = 0.56933, p-value = 0.9021
## sample estimates:
## t*
## 92
</pre>
<p>The CUSUM test fails to reject the null hypothesis of no change, with no room for ambiguity. It does not appear that the two series detached.</p>
<h2>Concluding discussion</h2>
<p>Here is the new and improved chart with the location of the change highlighted by a red line.</p>
<pre>
ggplot(plot_df_47, aes(x = Year, y = Index, group = Series)) +
    geom_line(aes(color = Series), size = 1.4) + 
    ggtitle(&quot;U.S. Business Sector Productivity and\nReal Compensation (1947 is 100)&quot;) +
    theme_economist_white() +
    scale_color_economist() +
    geom_vline(xintercept = time(series_ts_delta)[104], color = &quot;red&quot;)
</pre>
<p><img alt="bpeqa7fuupiaaaaaelftksuqmcc" class="wp-image-1051" src="https://i2.wp.com/ntguardian.files.wordpress.com/2016/09/bpeqa7fuupiaaaaaelftksuqmcc.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>It’s difficult to see, but <em>both</em> series have changed after 1973, and the above analysis suggests they are both growing slower. Productivity growth was <em>already</em> growing faster than compensation, and even if the 1973 break had not occured, we would still likely see a large gap between the series at the end of the chart. A Marxist would tell you this is consistent with how capitalism operates; the capitalist class does not fully compensate its workers, never has, and never will. There will always be a discrepancy between productivity and compensation for as long as capitalism is our economic system.</p>
<p>That said, why did the break of 1973 (or Q3 1972, if you prefer) occur? Let’s first answer: did the break occur because of a drop in productivity growth, or because of a drop in compensation growth? Now there is a conundrum that I will not be able to answer in a blog post. There is, in all honesty, no way to tell.</p>
<p>Can we point to an event that might cause a break in either? Well, Richard Nixon was elected President that year. He was a Republican, so he must have done something to do with it. But not only did Nixon have to deal with a Democratically-run Congress throughout his administration, Nixon was an older generation of Republicans and a political era when ideology hardly defined political allegiance. Nixon wanted to end the war in Vietnam, opened relations with China, and, aside from wanting to delegate more decision-making power to the states, did not have an economic policy we would associate with Republicans today. In fact, Nixon supported the Equal Rights Amendment (intended to make gender equality a Constitutionally-guaranteed right) and created the Environmental Protection Agency so hated by Republicans today (along with other environmental reforms). Watergate had nothing to do with the economy; we can’t pin the blame on him.</p>
<p>What about GATT? 1973 saw a new round of GATT negotiations, the Tokyo round, that further liberalized trade, dropping nations tariffs. This might be closer to the cause, but I’m not convinced.</p>
<p>How about the wave of deregulation that began in the 1970s? Unfortunately, this started in the late 1970s, and didn’t escalate to full-blown dismantlement of regulatory structures until Ronald Regan took office. In fact, Regan is the best evidence of the shift Dr. Sorscher claims tood place, though this happens much later than Dr. Sorscher claim.</p>
<p>In truth, I don’t have an answer as to why this break occured in 1973. It could have been GATT, the conclusion of the Vietnam War, deregulation, or a number of other causes. That said, I do consider this an interesting question, hopefully one that will someday be answered with satisfaction. And perhaps in answering it we will find a solution to the growing inequality that continues to plague us.</p>
<div>
<hr>
<ol>
<li>
Dr. Sorscher has a PhD from UC Berkeley in biophysics, and is a board member of the Economic Opportunity Institute, for whom he wrote his article. <a target="_blank" href="https://ntguardian.wordpress.com/2016/09/12/wages-detach-productivity-1973/#fnref-1017-1">↩</a>
</li>
</ol>
</div>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ntguardian.wordpress.com/1017/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/ntguardian.wordpress.com/1017/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/did-wages-detach-from-productivity-in-1973-an-investigation/"></div></div><div><a data-url="https://www.r-bloggers.com/did-wages-detach-from-productivity-in-1973-an-investigation/" data-counturl="https://www.r-bloggers.com/did-wages-detach-from-productivity-in-1973-an-investigation/" data-count="vertical" data-text="Did Wages Detach from Productivity in 1973? An Investigation" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://ntguardian.wordpress.com/2016/09/12/wages-detach-productivity-1973/"> R – Curtis Miller's Personal Website</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/5B-BqSNbKmI"></a></div>