<jupyter_start><jupyter_text>Mandatory assignment 2: Solow growth model with human capital* **Step 1: Package import:** The first part of the code in our project is the use of libraries with essential packages of panda, numpy and glob, which is essential for data structuring and especially arrays and pathnames and on top of that, we import statsmodel. We import the scipy package that provides various commonly used optimization algorithms. The sympy package is a Python library for symbolic computation.<jupyter_code>import pandas as pd
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed, interact_manual

import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.optimize import minimize
from scipy.optimize import fsolve
import sympy as sm
sm.init_printing(use_unicode=True)
from scipy import optimize
from scipy.stats import trim_mean, kurtosis
from scipy.stats.mstats import mode, gmean, hmean
from IPython.display import display, Latex, Markdown
from IPython.display import Image
import statsmodels.api as statm
import statsmodels.formula.api as smf
from sympy import symbols, Eq, solve
import turtle<jupyter_output><empty_output><jupyter_text>* **Step 2: Datapath and data processing:** The data in table 1 is from the second edition book "Introducing Advanced Macroeconomics: Growth and Business Cycles" by <NAME> and <NAME>.<jupyter_code>#Set datapath
datapath = "Dataset/"
data = pd.read_excel(datapath + "APPENDIX_TableA_SECOND_ED-7.xls")

#Remove unnecessary rows
data=data[14:-18]
#Remove unnecessary columns
data = data.iloc[:, :-3]

#Mark/select first row
new_header = data.iloc[0]
#All data below first row
data = data[1:] 
#Use all data below first row and set column names equal new_header
data.columns = new_header

data.rename(columns = {list(data)[0]:"Country"}, inplace=True)
print("Table 1: Data")
data.head()<jupyter_output>Table 1: Data<jupyter_text>We extend the dataset by combining it with data for land per worker and subsoil per worker, which we have downloaded from the World Bank data: Wealth estimates.<jupyter_code>datapath1 = "Dataset/"
#Import of natural resources from Excel file from the dataset folder
data1 = pd.read_excel(datapath1 + "Natural_resources_the_world_bank.xlsx")
#Merging the new natural resource data with the prior country data
data3 = pd.merge(data, data1, on="Code")
#Printing the first 50 rows including header sorted with the largest y03 values
print("Table 2: Final Data Table")
data3.head()
DataDescribe=data3
#From the dataset we delete unnecessary columns
DataDescribe = DataDescribe.drop(["Code", "In Sample of 65", "u", "isi", "Country_y"], 1)
#We do then delete the blank rows of growth in human capital
DataDescribe=DataDescribe[DataDescribe["sH"] != '   -']

#All data columns are defined as floats
DataDescribe["y03"] = DataDescribe.y03.astype(float)
DataDescribe["y60"] = DataDescribe.y60.astype(float)
DataDescribe["gy"] = DataDescribe.gy.astype(float)
DataDescribe["sK"] = DataDescribe.sK.astype(float)
DataDescribe["n"] = DataDescribe.n.astype(float)
DataDescribe["sH"] = DataDescribe.sH.astype(float)
DataDescribe["Land"] = DataDescribe.Land.astype(float)
DataDescribe["Subsoil"] = DataDescribe.Subsoil.astype(float)

#Print a descriptive table of maximum observation in y03
print("Table 3: The land with highest growth in income per worker")
max =DataDescribe[DataDescribe.y03 == DataDescribe.y03.max()]
display(max.head())

print("")
print("")

#Print a descriptive table of minimum observation in y03
print("Table 4: The land with the lowest growth in income per worker")
min =DataDescribe[DataDescribe.y03 == DataDescribe.y03.min()]
display(min.head())<jupyter_output>Table 3: The land with highest growth in income per worker<jupyter_text>* **Step 3: Part 1: The Augmented Solow model with Human Capital:**  We now set up our **augmented Solow model with human capital**, which is given by the parameters:1. $K_t$ is phusical capital* $H_t$ is human capital* $L_t$ is labor (with a growth rate on $n$)* $A_t$ is technology (growing with a rate of $g$)* $I^K_t=s_KY_t, 0<s_K<1$* $I^H_t=s_HY_t, 0<s_H<1$where $s_K+s_H<1$* $K_{t+1} =s_KY_t+(1-\delta)K_t$* $H_{t+1} =s_HY_t+(1-\delta)H_t$* $L_{t+1}=(1+n)L_t$* $A_{t+1}=(1+g)A_t$* $Y_t = K_t^\alpha H_t^\varphi(A_tL_t)^{(1-\alpha)}, 0<\alpha<1, 0<\varphi<1, \alpha+\varphi<1 $ is GDPWe still have the normal framework for a Solow model such that **Savings** is a constant fraction of GDP and the production function have a **constant return to scale**.Dividing the production function by $L_tA_t$ on both sides gives the production function per effective worker:11. $\tilde{y}_t = \tilde{k}_t^\alpha \tilde{h}_t^\varphi$ * **Step 4: Steady State predictions:**We are going to use equation 9 and 10 from above to model our two solow equations. We use the equation for physical capital per effective worker in the next period and the equation for human capital per effective worker in the next periode, given by:12. $\tilde{k}_{t+1} = (1/((1+n)(1+g)))(s_K\tilde{y}_t+(1-\delta)\tilde{k}_t)$13. $\tilde{h}_{t+1} = (1/((1+n)(1+g)))(s_H\tilde{y}_t+(1-\delta)\tilde{h}_t)$By inserting equation 11 in equation 12 and 13, we get:8. $\tilde{k}_{t+1} = (1/((1+n)(1+g)))(s_K\tilde{k}_t^\alpha \tilde{h}_t^\varphi+(1-\delta)\tilde{k}_t)$9. $\tilde{h}_{t+1} = (1/((1+n)(1+g)))(s_H\tilde{k}_t^\alpha \tilde{h}_t^\varphi+(1-\delta)\tilde{h}_t)$By using the two steady state conditions stating that $\tilde{k}_{t+1}=\tilde{k}_{t}=\tilde{k}^*$ and $\tilde{h}_{t+1}=\tilde{h}_{t}=\tilde{h}^*$, and withdrawing capital from both sides of eq. 8 and 9 we get the Solow equation which is stated below:<jupyter_code>import numpy as np
from scipy.optimize import minimize
import sympy as sm

#Define all variables and parameters as sympy symbols
a = sm.symbols("alpha")
phi = sm.symbols("varphi")
b = sm.symbols("beta")
g = sm.symbols("g")
n = sm.symbols("n")
n = sm.symbols("ng")
y = sm.symbols("y")
d = sm.symbols("delta")
k = sm.symbols("\\tilde{k}_t")
h = sm.symbols("\\tilde{h}_t")
ktildestar = sm.symbols("\\tilde{k}^*")
htildestar = sm.symbols("\\tilde{h}^*")

A = sm.symbols("A")
g_y = sm.symbols("g_y")
s_K = sm.symbols("s_K")
s_H = sm.symbols("s_H")
t = sm.symbols("t")

#Stating the Solow equations of capital and human capital with the sm equation function
SolowEq1 = sm.Eq(0,((1/((1+n)*(1+g)))*(s_K*(k**a * (h**phi))+(1-d)*k))-k)
SolowEq2 = sm.Eq(0,((1/((1+n)*(1+g)))*(s_H*(k**a * (h**phi))+(1-d)*h))-h)

#Printing the equations
SolowEq1, SolowEq2<jupyter_output><empty_output><jupyter_text>We use the above Solow equations and solve the system of two equations with two unknown variables, we get:<jupyter_code>#Define k h as symbols
k, h = symbols('k h')
eq1 = Eq(s_K*k**a*h**phi-(n+g+d+(n*g))*k)
eq2 = Eq(s_H*k**a*h**phi-(n+g+d+(n*g))*h)

#derive the value of k and h in steady state from the abovementioned equations in parameter values
SS = solve((eq1,eq2), (k, h))

#Printing the steady-state value for capital and human capital
ktildestar=SS[0][0]
htildestar=SS[0][1]

# Latex print of physical capital per effective worker
display(
        Markdown(
            r'The steady state value of physical capital per effective worker is $\ \tilde k^*= $ {}.'.format(
                sm.latex(ktildestar, mode='inline'))))

# Latex print of physical capital per effective worker
display(
    Markdown(
        r'The steady state value of human capital per effective worker is $\ \tilde h^*= $ {}.'.format(
            sm.latex(htildestar, mode='inline'))))<jupyter_output><empty_output><jupyter_text>From above we calculated the expressions for the steady-state value for physical capital per effective worker and human capital per effective worker. We insert the below parameter values in the steady-state expressions and get:<jupyter_code>#Stating the variables and function of SS with lambdify
SS1 = sm.lambdify((n, g, s_H, s_K, a, phi, d, h), SS)

#Including the parameters known from macro-theory
SSvalue=SS1(0.01, 0.02, 0.2, 0.2, 0.33, 0.33, 0.05, 0.20)

#Printing the numerical steady-state values
print(SSvalue)<jupyter_output>[(14.696788132394444, 14.696788132394442)]<jupyter_text>By using the analytical method we find the steady-state values for physical capital and human capital. We now show how to find the steady-state value by using the numerical method. Conducting a numerical solution instead of an analytical solution.<jupyter_code>#We define the parameters with their known values for later use (including the steady-state value of h)
n = 0.01
g = 0.02
s_H = 0.20
a = 0.33
phi = 0.33
d = 0.05
h = 14.696788132394442

# Defining the steady-state as a lambda function
SSN = lambda k: 0 - (1/((1+n)*(1+g)))*((s_H*k**a*h**phi-(n+g+d+n*g)*k))

# Using optimize.newton for a numerical solution to our steady-state of k
# optimize.newton find the value of k that make the lambda function equal to zero, the newton method use a given starting point x0.
result_SSN
result_SSN = optimize.newton(SSN,x0=10) 
np.round(result_SSN,3)
#We do then derive the numerical solution for h knowing the value of k
k= 14.696788132394438
 
# Defining the steady-state as a lambda function
SSN1 = lambda h: 0 - (1/((1+n)*(1+g)))*((s_H*k**a*h**phi-(n+g+d+n*g)*h))

# Using optimize.newton for a numerical solution to our steadystate of h
result_SSN1 = optimize.newton(SSN1,x0=100)
result_SSN1
np.round(result_SSN1,3)<jupyter_output><empty_output><jupyter_text>The numerical solution of the steady state value takes the Solow equations for both physical capital per effective worker and human capital per effective worker and calculating the steady-state values for capital by starting from an initial x0 value and finding the value that makes the Solow equation equal to zeroFrom the analytical solution we first found the Solow equation and then we found the solution to a system of two equations with two unknowns. In the numerical solution python calculate the steady state value numerically * **Step 5: A Graphical View of the Model:**The phase diagram illustrates a plot of the transitions equation of human capital and physical capital. The orange locus gives all combinations of $h_t$ and $k_t$ such that $h_t$ stays unchanged. Likewise, the blue locus gives all the combinations of $h_t$ and $k_t$ such that $k_t$ stays unchanged. From the graph, we see that the steady-state combination, $k^*$ and $h^*$, is where the curves intercept. This interception is exactly  where $k_t = 14.59$ and $h_t=14.69$ as we calculated above. Furthermore, this indicates that the steady-state fulfills the requirements for balanced growth. Moreover, we see that for every combination of $k_t$ and $h_t$ above the blue curve where $k_{t+1} - k_t > 0$ --> $k_t$ will be increasing and below it, $k_t$ must be decreasing. The other curve follows the same dynamics. To the right of the orange curve $h_{t+1} - h_t > 0$, which means that $h_t$ will be increasing over time while $h_t$ to the left of the orange curve will be decreasing.<jupyter_code># We define the parameter values 
n = 0.01
g = 0.02
s_K = 0.20
a = 0.33
phi =0.33
s_H =0.20
d =0.05

# Setting the axis range to 18
k = np.array(range(18))

# We state the functions used in the phase diagram
h1 = ((((n+g+d+n*g)/(s_K))**(1/phi))*k**((1-a)/phi))
h2 = (((s_H*k**a)/(n+g+d+n*g))**(1/(1-phi)))

#We plot the x-axis array of k and the functions of h1 and h2
plt.plot(k, h1, h2)
plt.xlabel('k')
plt.ylabel('h')
plt.title('Phase Diagram for the Augmented Solow Model with Human Capital') 
plt.show()<jupyter_output><empty_output><jupyter_text>From below we see the exact same plot as above. The only difference is, that we now allow the saving rate for physical capital to vary. By simulating the model with a higher savings rate for physical capital, we see that the locus where $k_t$ is unchanged and rotates outwards. The economic reason is that a higher savings rate of physical capital means that people are saving more of their income. This leads to a higher saving per worker, which means that capital per capita will increase. When capital per worker increases, income per worker increases as well.<jupyter_code>#Setting a optional s_K value and S_H value in the figure below
def phase_dia(s_K,s_H):
    
# Setting a vector with equal linespace
    x_vec = np.linspace(0,50,50)

#Defining the phase function of capital and the known variables and parameters
    def phasek(k, s_K, a, phi, n):
        return ((((n+0.02+0.05+n*0.02)/(s_K))**(1/phi))*k**((1-a)/phi))

#Defining the phase function of human capital and the the known variables and parameters
    def phaseh(k, s_H, a, phi, n):
        return (((s_H*k**a)/(n+0.02+0.05+n*0.02))**(1/(1-phi)))

#Figure size, labels, title and known parameters of phasek and phaseh
    fig = plt.figure(figsize=(20,5))
    phasek1=phasek(x_vec, s_K, a, phi, n)
    phaseh1=phaseh(x_vec, s_H, a, phi, n)

    plt.grid()
    plt.ylim((0,50))
    plt.xlim((0,50))
    plt.plot(phasek1, linestyle='solid') #man kunne også skrive solid i stedet for dashed
    plt.plot(phaseh1, linestyle='solid')
    plt.title('Phase Diagram for the Augmented Solow Model with Human Capital')
    plt.xlabel("Human capital per effective worker")
    plt.ylabel("Physical capital per effective worker");  # dotted red - en kortere måde at skrive det på
#Defining the value of s_K as a widget with a float slider bar with a max of one and default value of 0.2
widgets.interact(phase_dia,
    s_K=widgets.FloatSlider(description="$\\ s_K$", min=0.1, max=0.35, step=0.0000001, value=0.20),
    s_H=widgets.FloatSlider(description="$\\ s_H$", min=0.1, max=0.35, step=0.0000001, value=0.20),
                );<jupyter_output><empty_output><jupyter_text>* **Step 4: The Augmented Solow Model with Human Capital and Natural resources:** We now create a model to investigate the growth in income per worker. We now set up our **augmented Solow model with human capital and natural resources**, which is given by the parameters:1. $K_t$ is capital per worker* $L_t$ is labor (with a growth rate on $n$)* $A_t$ is technology (growing with a rate of $g$)* $X_t$ is the total amount of land and it does not carry a time subscript as land is in fixed supply* $R_t$ is the total remaining stock of an exhaustible resource, oil at time t* $E_t$ is the part of $R_t$ that is used as energy input during period t (where the exhaustible rate is $s_E$)* $Y_t = K_t^\alpha H_t^\varphi(A_tL_t)^\beta X^\kappa E_t^\epsilon$ is GDPWe still have the normal framework for a Solow model such that **Savings** is a constant fraction of GDP and the production function have a constant return to scale. Moreover, we are going to use the following equations to model our framework.8. $R_{t+1} = R_t - E_t$9. $ E_t = s_E R_t$, where $0<s_E<1$Dividing the production function by $L_t$ on both sides and using equation 9, this gives the production function per worker:10. $y_t = k_t^\alpha h_t^\varphi A_t^\beta (X/L_t)^\kappa ({s_E R_t}/L_t)^\epsilon $11. $y_t = k_t^\alpha h_t^\varphi A_t^\beta x_t^\kappa e_t^\epsilon $By taking logs on both sides we get:11. $ln(y_t) = \alpha ln(k_t) +\varphi ln(h_t)+ \beta ln(A_t)- \kappa (ln(L_t)-ln(L_{t-1}))+ \epsilon (((ln(R_t)-ln(R_{t-1}))-(ln(L_t)-ln(L_{t-1}))) = \alpha ln(k_t) +\varphi ln(h_t)+ \beta ln(A_t)- (\kappa+\epsilon) (ln(L_t)-ln(L_{t-1}))+ \epsilon (ln(R_t)-ln(R_{t-1})) $By combinig equation 8 and 9, we get that $ R_{t+1} = R_t - s_E R_t  (R_{t+1}/R_t) = s_E + 1 $, and use that $ln(R_t)-ln(R_{t-1})=-ln(s_E+1) =-s_E$, we get that:13. $ln(y_t) = \alpha ln(k_t) +\varphi ln(h_t)+ \beta ln(A_t)- (\kappa+\epsilon) n- \epsilon s_E $We now use the standard approximation that logs differences as a growth rate approximation. Therefore, calculate the time differences on both sides which gives:14. $ln(y_t)-ln(y_{t-1}) = \alpha (ln(k_t)-ln(k_{t-1})) +\varphi (ln(h_t)-ln(h_{t-1}))+ \beta (ln(A_t)-ln(A_{t-1}))- (\kappa+\epsilon) n- \epsilon s_E$We use the approximation that the growth rate for output per worker is $g_y$, the growth rate for technology is g, the growth rate for human capital per worker is $g_h$ and the growth rate in capital per worker is $g_k$. This gives us the following equation:15. $g_y = \alpha g_k +\varphi g_h+ \beta g- (\kappa+\epsilon) n- \epsilon s_E$ We know from the Solow model that the two capital/output ratios are constant in steady-state, which is why we use the approximation that both capital and human capital grow at the same rate as $y_t$: $g_y = g_k =g_h$. This gives us the following model:16. $g_y = \beta / {(1-\alpha-\varphi)} g - {(\kappa+\epsilon)n} / {(1-\alpha-\varphi)} - \epsilon / {(1-\alpha-\varphi)} s_E$We now use that the Solow model with human capital and natural resources exhibit a constant return to scale, which gives us:17. $g_y = \beta / {(\beta+\kappa+\epsilon)} g - {(\kappa+\epsilon)n} / {(\beta+\kappa+\epsilon)} - \epsilon / {(\beta+\kappa+\epsilon)} s_E$We now have our equation 17, which can tell us how large the growth rate in GDP each country hold depending on the parameters. Therefore, we will first find the parameter values before we continue by finding the growth rate for GDP for different values for growth rate for population and growth rate for technology. * **Step 4: Finding parameter values for all parameters that are included in our equation 17:** We use equation (37) from page 205 in the book "Introducing  Advanced Macroeconomics - Growth and Business Cycles" by <NAME> and <NAME> and augmenting it with human capital. We then get:18. $ln(y_t^*) = \beta / {(\beta+\kappa+\epsilon)} ln(A_t) + \epsilon / {(\beta+\kappa+\epsilon)} ln(s_E) + \alpha / {(\beta+\kappa+\epsilon)} [ln(s_K)-ln(n+0.062)]+ \varphi / {(\beta+\kappa+\epsilon)} [ln(s_H)-ln(n+0.062)] + \kappa / {(\beta+\kappa+\epsilon)} ln({X/L_t})+ \epsilon / {(\beta+\kappa+\epsilon)} ln({R_t/L_t}) $Which gives us the following regression equation:18. $ln(y_{00}^i) = \gamma_0 + \gamma_1 [ln(s^i_K)-ln(n^i+0.062)]+ \gamma_2 [ln(s^i_H)-ln(n^i+0.062)] + \gamma_3 ln({X/L^i})_{00}+  \gamma_4 ln({R^i/L^i})_{00} $<jupyter_code>#Linear estimation from the dataset imported in cell 2
#Restructuring the values into log format
logy60=np.log(DataDescribe["y60"])
logy03=np.log(DataDescribe["y03"])
logn1 =np.log(DataDescribe["n"]+0.075)
logsK1=np.log(DataDescribe["sK"]) - logn1
logsH1=np.log(DataDescribe["sH"]) - logn1
logland =np.log(DataDescribe["Land"])
logsubsoil =np.log(DataDescribe["Subsoil"]) 

# Fit regression model (using the natural log of one of the regressors) from the dataframe called datadescripe 
results = smf.ols("logy03 ~ logsK1 + logsH1 + logland + logsubsoil", data=DataDescribe).fit()

# Inspect the results of log(y03) with the regressors logsK1, logsH1, logland, logsubsoil
print("Table 5: OLS Results")
print(results.summary())<jupyter_output>Table 5: OLS Results
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 logy03   R-squared:                       0.747
Model:                            OLS   Adj. R-squared:                  0.731
Method:                 Least Squares   F-statistic:                     47.14
Date:                Sun, 26 May 2019   Prob (F-statistic):           2.08e-18
Time:                        22:45:34   Log-Likelihood:                -62.695
No. Observations:                  69   AIC:                             135.4
Df Residuals:                      64   BIC:                             146.6
Df Model:                           4                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std er[...]<jupyter_text>From the regression table above we see that the variables Land and Subsoil are insignificant, meaning we cannot use the coefficients for Land per Worker and Subsoil per Worker to estimate $ \epsilon $ and $ \kappa $. They have a P-value on 0.372 and 0.389 respectively. Therefore, we use the coefficients provided by <NAME> and <NAME> in the book "Introducing Advanced Macroeconomics Growth and Business Cycles" to estimate the growth drags below, the other coefficient is calculated below by using the expression from their book. Moreover, we have that $s_K$ and $s_H $depend positively on the growth in 2003 as we expected. We estimate the parameters:* $\alpha = \gamma_1/{(1+\gamma_1+\gamma_2+\gamma_3+\gamma_4)}$* $\varphi = \gamma_2/{(1+\gamma_1+\gamma_2+\gamma_3+\gamma_4)}$* $\kappa = \gamma_3/{(1+\gamma_1+\gamma_2+\gamma_3+\gamma_4)}$* $\epsilon = \gamma_4/{(1+\gamma_1+\gamma_2+\gamma_3+\gamma_4)}$By inserting the estimated values we get:* $\alpha = 0.3933/{(1+0.3933+0.8993+0.1283+0.0301)} = 0.16 $* $\varphi = 0.8993/{(1+0.3933+0.8993+0.1283+0.0301)} = 0.37 $* $\kappa = 0.1283/{(1+0.3933+0.8993+0.1283+0.0301)} = 0.05 $* $\epsilon = 0.0301/{(1+0.3933+0.8993+0.1283+0.0301)}= 0.01 $We assume that the shares for raw labor and human capital is equal to 0.6, meaning that $\beta = 0.23$We now continue our Model Project with the shares (the shares for land and oil are not significant so we continue with the shares from the book by <NAME> and <NAME>:* $\alpha = 0.2 $* $\varphi = 0.3 $* $\kappa = 0.1 $* $\epsilon = 0.1$* $\beta = 0.3$We insert the parameters in the growth eq.: * $g_y = 0.3/{(0.3+0.1+0.1)}g - {(0.2)n} / {(0.3+0.1+0.1)} - 0.1 / {(0.3+0.1+0.1)} 0.005$ * $g_y = 0.6g - 0.4n - 0.001$$g_y = \beta / {(\beta+\kappa+\epsilon)} g - {(\kappa+\epsilon)n} / {(\beta+\kappa+\epsilon)} - \epsilon / {(\beta+\kappa+\epsilon)} s_E$<jupyter_code>#Defining the symbols from sympy
b = sm.symbols("beta")
g = sm.symbols("g")
n = sm.symbols("n")
k = sm.symbols("kappa")
e = sm.symbols("epsilon")
g_y = sm.symbols("g_y")
s_K = sm.symbols("s_K")
s_H = sm.symbols("s_H")
s_E = sm.symbols("s_E")

#Stating the growth equation as a sympy equation 
growth = sm.Eq(0, (b/(b+k+e)*g)-(k+e)*n/(b+k+e)-e/(b+k+e)*s_E)
#Print the equation
growth<jupyter_output><empty_output><jupyter_text>The function above is shows all the combinations of growth in tecnology and grwoth in population that gives a growth in income per worker equal to zero. We use this function below to investigate at what level the  growth rate in technology has to be, to offset the growth drag from the population growth rate<jupyter_code>#Solve for the growth rate in technology
growth1 = sm.solve(growth, g)
#Print the solution of g
growth1<jupyter_output><empty_output><jupyter_text>Below we are plotting the above function, which shows the growth rate in technology as a function of the growth rate in the population and the externalities from the other variables.<jupyter_code>#Define the new symbols with sympy
b = sm.symbols("beta")
g = sm.symbols("g")
n = sm.symbols("n")
s_E = sm.symbols("s_E")
e = sm.symbols("epsilon")
k = sm.symbols("kappa")

#Define the plot settings with the variables of s_E, b, e, k.
def dia3(s_E, b, e, k):

#Define the growthh function with the variables and parameters n, e, s_E, b, k.
    def growthh(n, e, s_E, b, k):
        return ((e*n+e*s_E+k*n)/b)

#Setting a vector with equal linespace
    x_vec1 = np.linspace(0,50,50)


    #Setting the plotted function as the growthh function with the unknown variables of x_vec1, s_E, e, b and k
    growthh1=growthh(x_vec1, s_E, e, b, k)
    
    fig2 = plt.figure(figsize=(20,5))
    plt.grid()
    plt.ylim((0,0.1))
    plt.xlim((0,0.1))
    plt.plot(growthh1, linestyle='solid') #man kunne også skrive solid i stedet for dashed
    plt.title('Growth')
    plt.xlabel("Population growth rate")
    plt.ylabel("Growth rate in technology");

#The optional variables are then defined as float sliders with default values
widgets.interact(dia3, 
    s_E=widgets.FloatSlider(description="$\\ s_E$", min=0.1, max=0.2, step=0.0000001, value=0.03),
    b=widgets.FloatSlider(description="$ \\beta $", min=0.1, max=0.8, step=0.0000001, value=0.66),
    e=widgets.FloatSlider(description="$ \\epsilon  $", min=0.1, max=0.2, step=0.0000001, value=0.1),
    k=widgets.FloatSlider(description="$ \kappa $", min=0.1, max=0.2, step=0.0000001, value=0.1),
  
                );<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13699760666831723, 'fraction_numerical': 0.03474457373937443, 'mean_word_length': 4.267333188437296, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '634449', 'license': 'MIT', 'n_tokens_mistral': 8625, 'n_tokens_neox': 8108, 'n_words': 2861, 'path': 'modelproject/modelproject final.ipynb', 'repo_name': 'NumEconCopenhagen/projects-2019-ccl', 'size': '24346'}