2
$\begingroup$

I have calculated my own Solow model with energy as an input factor. I'm already pretty sure that the equations are correct but the problem I have are the results from the loop I build for the equations - it just produces NaN. For background P[1] influences k[1] and y[1]. Also k[1] influences y[1]. And in P[1] there is a shock modeled which will give different prices in each period but will diverge against five.

I think there is a error in the loop but I don't know where the problem is.




# Defining the variables
s <- 0.1
A <- 1
delta <- 0.2
Pe <- 20
gamma <- 0.25
alpha <- 0.5
k_bar <- 10
T <- 100  # Anzahl der Perioden
rho <- 0.9  # Autoregressionskoeffizient
P_bar <- 20  # Mittelwert des Preises
P_bar2 <- 5 

# Initiation for k* und y*
T <- 100
P <- numeric(T)
k <- numeric(T)
y <- numeric(T)

# Stating Values
P[1] <- P_bar
k[1] <- k_bar
y[1] <- A * k_bar^alpha * (Pe / (gamma * A * k_bar^alpha))^(gamma / (gamma - 1))

# Loop for k* und y*
for (t in 2:T) {
  P[t] <- rho * P[t - 1] + (1 - rho) * P_bar2
  k[t] <- (s * A / delta) * (P[t] / (gamma * A))^(gamma / (gamma - 1))^(1 / (1 - alpha * (1 + gamma / (gamma - 1))))
  y[t] <- A * k[t]^alpha * (P[t] / (gamma * A * k[t]^alpha))^(gamma / (gamma - 1))
}


# Results
print(y)


The Results form R:

[1] 1.077217 NaN NaN NaN NaN NaN NaN NaN NaN NaN [11] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [21] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [31] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [41] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [51] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [61] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [71] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [81] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN [91] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

$\endgroup$
2
  • 3
    $\begingroup$ Your expression for k[t] is causing errors, because gamma / (gamma - 1) is negative and the power of a negative number does not exist when the power is not an integer. Are you sure that there are two powers in k[t]. $\endgroup$
    – Bertrand
    Commented Jan 26 at 20:37
  • $\begingroup$ Hi EBger, it would be helpful if you provided us the equations you're trying to implement. $\endgroup$ Commented Jan 28 at 13:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.