Question:
Where can I find a calculator for constrained optimization of general form of algebraic equation?

I'm working with a fairly complex equation and I need to carry out constrained optimization of the same. The first order differential equations are very messy to solve by hand and hence I thought to use online calculators. Problem with calculators like wolfram is that I cannot choose the variables with respect to which optimization needs to be done. If I use numbers in place of other variables it would defy the purpose. Are there any calculators available online for the problem I have? I am open to use coding based software like Matlab.

For example:
Maximize  𝑎𝑥𝑏−𝑥

w.r.t  𝑥

s.t.  𝑥>0,𝑎>1,0<𝑏<1

The original problem is multivariable and much more complex. I don't want to optimize with specific values for a,b.

Explanation: We need to check the reference sheet of the Maximize function of calculators to understand the usage.

$\begingroup$

You can set the decision variables in Wolfram Alpha. E.g.,

> maximize [{x*q-q^2+a} , {q}]

maximizes the function  $x*q-q^2+a$  w.r.t. the variable  $q$  .
For further details read the [ reference sheet of the Maximize function
](https://reference.wolfram.com/language/ref/Maximize.html) .


Question:
Can Difference-in-Difference be used when the treatment effects get smaller with time since treatment?

Recently, there is an emerging line of the study said that the traditional two-way fixed effect(TWFE) is failed in a lot of case because of the heterogeneous effects of laws over time, follow some paper Goodman-Bacon (2019), Chaisemartin, 2020.

Especially, Goodman, 2019 did a great job to decompose the single post-treatment dummy. In his note, he answered the question "Is DD wrong":

Not in general. The DD research design—comparing outcomes for groups whose treatment status changes to groups whose treatment status does not change—still can be a good idea. The DD specification—estimating the coefficient a single post-treatment dummy—is a bad idea when your treatment effects vary over time (get bigger with time since treatment). In this case, just summarize your findings in a different way—event-study or a linear trend-break, for instance.

My question here is, if I expect and argue that the treatment effects get smaller with time since treatment, so whether DD specification now is a bad idea?

Explanation: The central question is to check inference procedures for treatment effect parameters using Difference-in-Differences with multiple time periods.

$\begingroup$

It depends on a few things. First, if you expect treatment effects change over
time, then you want to estimate an event-study style DD specification.

If you have a single treatment timing (all treatment starts at the same time),
then an event-study will unbiasedly estimate the treatment path. If you have
variation in treatment timing, you want to use a modern method, e.g. [
Callaway and Sant'Anna (2020)
](https://pedrohcgs.github.io/files/Callaway_SantAnna_2020.pdf) , [ Gardner
(2021) ](https://jrgcmu.github.io/2sdd_current.pdf) , or [ Sun and Abraham
(2020) ](http://economics.mit.edu/files/14964)


Question:
Including an endogenous covariate in a regression model as a control to estimate the effect of another variable of interest

I am interested in the effect of an independent variable 𝑥
 on a dependent variable 𝑦
, like so

𝑦=𝛽0+𝛽1𝑥+𝑒

where 𝑒
 is the error term. Now 𝑥
 includes two effects 𝑧1
 and 𝑧2
. For simplicity, let say 𝑥=𝑧1+𝑧2
. If I include 𝑧1
 in the model, like this

𝑦=𝛽0+𝛽1𝑥+𝛽2𝑧1+𝑒

Does that mean that 𝛽1
 is predominantly capturing the effect of 𝑧2
?

Explanation: This is related to Frisch–Waugh–Lovell theorem, which is applied when the regression we are concerned with is expressed in terms of two separate sets of predictor variables.

$\begingroup$

> If I include  $z_1$  in the model, like this:  $$ > y = \beta_0 + \beta_1 x
> + \beta_2 z_1 + e, > $$  Does that mean that  $\beta_1$  is predominantly
> capturing the effect of  $z_2$  ?

Yes. This can be seen using the [ Frish-Waugh-Lovell theorem
](https://en.wikipedia.org/wiki/Frisch%E2%80%93Waugh%E2%80%93Lovell_theorem) :

If you regress:  $$ y = \beta_0 + \beta_1 x + \beta_2 z_1 + e, $$  then
$\beta_1$  will be the same as the corresponding coefficient of a modified
regression:  $$ \hat y = \gamma_0 + \beta_1 \hat x + \hat e \tag{1} $$  where
$\hat x$  is the residual from regressing  $x$  on  $z_1$  and the same for
$\hat y$  . Now if we regress  $x$  on  $z_1$  then the residual is equal to:
$$ M_{z_1} x, $$  where  $M_{z_1} = 1 - z_1(z_1'z_1)^{-1}z_1'$  is the
annihilator matrix. If  $x = z_1 + z_2$  then:  $$ M_{z_1} x = (1 -
z_1(z_1'z_1)z_1')(z_1 + z_2) = M_{z_1}z_2 $$  As such, substituting in  $(1$
), we have:  $$ \hat y = \gamma_0 + \beta_1 \hat z_2 + \hat e, $$  where
$\hat z_2$  is now the residual from regressing  $z_2$  on  $z_1$  . Using the
Frish-Waugh-Lovell theorem, in the reverse direction, this gives that
$\beta_1$  is also equal to the coefficient in the following regression:  $$ y
= \delta_0 + \beta_1 z_2 + \delta_2 z_1 + \varepsilon. $$  In other words,
$\beta_1$  will also be equal to the coefficient for  $z_2$  for a regression
of  $y$  on both  $z_2$  and  $z_1$  . Notice, however, that in general
$\beta_2 \ne \delta_2$  (so the coefficients for  $z_1$  will not be equal in
the two regressions).

Another way to see this is by immediately substituting  $x = z_1 + z_2$  into
the regression  $(1)$  then:  $$ \begin{align*} y &= \beta_0 + \beta_1(z_1 +
z_2) + \beta_2 z_1 + e,\\\ &= \beta_0 + \beta_1 z_2 + (\beta_1 + \beta_2) z_1
+ e. \end{align*} $$  So the coefficient on  $z_2$  in the new regression is
identical to the coefficient on  $x$  in the original one  $(\beta_1)$  ,
while the coefficient on  $z_1$  in the new regression is the sum of the
coefficients on  $x$  and  $z_1$  in the original regression  $(\beta_1 +
\beta_2)$  .

> And a follow up question is: if  $z_1$  is correlated with the error term,
> will including it in the model bias the estimate of  $\beta_1$  ?

The opposite is true. Including  $z_1$  into the regression will make the
estimate of  $\beta_1$  unbiased. Consider the following data generating
process:  $$ y = \beta_0 + \beta_1 x + e, \tag{2} $$  and assume that  $e$  is
correlated with  $z_1$  . Then we can write:  $$ e = \gamma z_1 + \varepsilon.
$$  where  $\varepsilon$  is now uncorrelated with  $z_1$  . (and where
$\gamma = \mathbb{E}(e z_1)/\mathbb{E}((z_1)^2) \ne 0$  . Assume for
simplicity that  $e$  is uncorrelated with  $z_2$  .

Then the estimate of  $\beta_1$  will be biased as the orthogonality condition
$\mathbb{E}(e x) = 0$  is not satisfied. Indeed:  $$ \begin{align*}
\mathbb{E}(ex) &= \mathbb{E}(e z_2) + \mathbb{E}(\gamma z_1 z_1) +
\mathbb{E}(\varepsilon z_1),\\\ &= \mathbb{E}(\gamma (z_1)^2) \ne 0
\end{align*} $$  If we include  $z_1$  into the regression. Then substituting
$e = \gamma z_1 + \varepsilon$  , into  $(2)$  we can write:  $$ y = \beta_0 +
\beta_1 x + \gamma z_1 + \varepsilon. $$  And  $\mathbb{E}(\varepsilon) =
\mathbb{E}(\varepsilon x) = \mathbb{E}(\varepsilon z_1) = 0$  . So by
including  $z_1$  into the regression, we can guarantee the residual
$\varepsilon$  to be uncorrelated with all covariates. This means that
$\beta_1$  is identified and its estimate will be unbiased.


Question:
What is the purpose of taxes if central banks can fund deficit spending?

Somewhat straight forward. If the federal reserve can print money to buy treasuries to fund deficit spending, what is the purpose of taxes? Sure, taxes reduce the amount of deficit that needs to be picked up by the Fed, but if, as ive seen argued, money “printing” doesn’t necessarily lead to inflation whats the point of levying taxes? Why doesn’t the fed just procure all of the money itself if it could theoretically do so without adverse affects?

Explanation: It is related to the monetary theory that predicts a strong long-run correlation between money growth and inflation.

$\begingroup$

Because Fed or any central bank cannot fund 100% of a budget without any
adverse effect. I do not know where you heard such argument but it is
blatantly false.

First, it is virtually unanimously agreed by top policy economists that
government cannot fund arbitrary amount of real spending (i.e. spending on
real goods and services). This question was actually put forward in [ a poll
](https://www.igmchicago.org/surveys/modern-monetary-theory/) among the top
Ivy league US economists by IGM and there was almost unanimous agreement that
government cannot do that (in fact there was no one who even agreed that it
could just few responses with no opinion, with low confidence, since the poll
scores that as well).

[ ![enter image description here](https://i.sstatic.net/lnWbn.png)
](https://i.sstatic.net/lnWbn.png)

Second, money supply increase does not _necessarily_ cause inflation because
other variables might push inflation into different direction. For example,
increase in money supply can be offset by velocity of money or change in real
output etc. However, money supply increase, _ceteris paribus_ , _does_ cause
inflation.

Numerous studies including [ Frain (2004)
](https://www.esr.ie/ESR_papers/vol35_3/Vol%2035_3Frain.pdf) or [ DeGrauve &
Polan (2005)
](https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1467-9442.2005.00406.x)
show that there is causal relationship between inflation and money supply.

You can also see that just by plotting money supply growth against inflation.
In the figure below on a left you can see the relationship between money
supply growth and inflation in the US over several years, on a right you can
see cross-sectional plot of money supply growth and inflation across various
countries. The images of course only show correlation, but causality is
further corroborated by empirical studies as those cited above (the charts are
taken from Mankiw Macroeconomics 8ed pp 107-108).

[ ![enter image description here](https://i.sstatic.net/rR4aUm.png)
](https://i.sstatic.net/rR4aUm.png) [ ![enter image description
here](https://i.sstatic.net/rJPhpm.png) ](https://i.sstatic.net/rJPhpm.png)

There is very little doubt in empirical research that there is relationship
between money growth and inflation. There are still questions on how strong
the relationship is, and how stable the relationship is over time, which is
discussed in the studies cited above, but either evidence points toward causal
relationship.

However, this does not mean government cannot monetarily finance _some_ of its
real spending, as despite of the above government can still earn seignorage on
issuing money, and it can take some time before inflation kicks in as the
relationship described above is not necessarily immediate but can work with
lags. As a consequences taxes are necessarily to fund all other real spending
that cannot be funded monetarily.


Question:
What are some negative/positive aspects from globalization in regard to developed countries?

I have read many articles on how globalization is helping developing countries, as more and more companies from developed countries have been moving their production oversees. However, as hard as I tried, I couldn't find a lot of articles talking about the opposite site of the story - How globalization affects developed countries.

Most of the articles I found were focused on the fact that moving production oversees will increase the unemployment and decrease the GDP. However, are there any other aspects (positive or negative)? Would love to learn more about this topic and if you have a good article that dives into this I would be really grateful if you can provide me with a link to it.

Explanation: Another aspect of globalization is related to international tourism, CO2 emissions and climate change.

$\begingroup$

I did a search in Google Scholar and it seems that most papers mainly digs
into the benefits of less-developed countries regarding globalization.

But there are a couple of dimensions here that you can have a look:

**Globalization helps to reduce carbon emissions from international tourism**
in the developed country following [ Daniel,2020
](https://link.springer.com/article/10.1007/s11356-019-07372-4)

**Impact of Globalization on some macro indicators** of developed countries of
[ Lenka,2013 ](http://ojs.spiruharet.ro/index.php/jedep/article/view/34)

**Developed-developing country partnerships** : Benefits to developed
countries? from [ Syed, 2012
](https://link.springer.com/article/10.1186/1744-8603-8-17)

The **Globalization of the Software Industry** : **Perspectives and
Opportunities for Developed and Developing Countries** from [ Arora, 2005
](https://www.journals.uchicago.edu/doi/abs/10.1086/ipe.5.25056169)

And last but not least, a great publication last year from [ Gozgor,2020
](https://www.sciencedirect.com/science/article/pii/S030142152030121X) that
prove that a higher level of economic g **lobalization promotes renewable
energy** in developed countries

I went through 6 pages from Google Scholar, and my keyword is " **[
globalization developed countries
](https://scholar.google.com.vn/scholar?start=0&q=globalization%20developed%20countries&hl=vi&as_sdt=0,5)
** " in case you want to replicate my search.


Question:
Why standard errors in country-level variables are higher than that in firm-level variables?

From this dicussion, the commentor said

Lastly, firm fixed effects may absorb more variation and likely reduced the size of their standard errors.

In practice, I also mainly see that the standard error for country-level mainly higher than that of firm-level variables. I am wondering if there is any mathematical or intuitive way to explain this phenomenon.

Explanation: We can check equations/calculation between firm-level and country-level GDP.

$\begingroup$

Consider a global panel model where there are many firms M >> N, the number of
countries. If we are expansive about what we mean by firms to include small
businesses, sole-proprietorships, and freelancers, then all domestic economic
aggregates are going to be the sum of the firm level aggregates (employment is
the sum of domestic firm employment, national output is the sum of domestic
firm employment, and so on). Aggregate variability of these statistics is
going to be less than the firm level variability. In [ THE GRANULAR ORIGINS OF
AGGREGATE FLUCTUATIONS BY XAVIER GABAIX
](http://pages.stern.nyu.edu/%7Exgabaix/papers/granular.pdf) , he shows that
if firms are identical and have the output variance  $\sigma^2$  (variance as
percent deviations from the mean), then the GDP standard deviation (of
percentage deviations from the mean) is
$$\sigma_{gdp}=\frac{\sigma}{\sqrt{n}} $$

This going to make GDP much less variable than the average firm and
approximately zero. An insight of his wonderful paper is that variability in
firm size matters a great deal, and in practice:
$$\sigma_{gdp}=\frac{\sigma}{\log{n}} $$  This is much, much larger, but still
$\sigma_{gdp} << \sigma$  .

Of course, you asked about the standard errors and not the standard
deviations. Recall that the basic calculation of the standard error of the
mean calculated from independent and identically distributed random variables
is:  $$ SE = \frac{\sigma}{\sqrt{T}}$$  , where T is the number of
observations. While things get much more complicated as we allow for
heteroskedasticity, serial correlation, clustering, and the like, the basic
idea remains that you need more observations to shrink the standard errors.
Since we established that  $\sigma_{gdp} << \sigma$  , if we observe firms and
nations the same number of times (T) and the observations are IID:

$$SE_{gdp}=\frac{\sigma_{gdp}}{\sqrt{T}} << \frac{\sigma}{\sqrt{T}} = SE_{i}$$

That's my argument for why (generally) the standard errors at the national
level should not be larger than at the firm level. I'm 99% sure you can cook
up examples that flip this result with the right covariance structure.
Nevertheless, it does not have to be the case that standard errors of country
level variables are larger than firm level ones, and in the simplest case, the
opposite is true.