Im interested in programming a budget line or PPF which is responsive to changes in relative prices, and income effect.

I know the equation for the budget line is $$m\geq p_1x_1+p_2x_2$$ Lets say we have an Income of $m=100$ and prices $p_1=1$ and $p_2=2$.

How would I go about programming this into an excel spreadsheet or R?

  • 2
    $\begingroup$ Can you provide more details about the production theory you are thinking of? Is this an abstract theory, using $n$ inputs $x_i$, or is this about capital and labour? Which production function? Also, have you done something? I'm not sure asking for code is entirely on-topic. $\endgroup$
    – luchonacho
    Commented Apr 28, 2017 at 9:58
  • 1
    $\begingroup$ Agreed. All you've said is: "I want to program something about producer theory". That's absurdly general. $\endgroup$ Commented Apr 28, 2017 at 13:36
  • $\begingroup$ @luchonacho better? $\endgroup$
    – EconJohn
    Commented Apr 28, 2017 at 16:11
  • $\begingroup$ I would say so. But, in the end, all what you have is a function. You still have two unknowns and one equation. The system is undetermined. Do you want simply to create a graph of this, which moves according to your chosen parameterisation? If you could add more info to the question, it would be great. At the moment I don't think it's clear enough. $\endgroup$
    – luchonacho
    Commented Apr 28, 2017 at 16:16
  • $\begingroup$ Yeah, I just want a graph which changes by parameterisation. Im kinda just going back to basics as i want to apply my economic theory to real data sets. this is a start. $\endgroup$
    – EconJohn
    Commented Apr 28, 2017 at 16:38

2 Answers 2


Another R code that does it...

m <- 100
p <- c(1, 2) 
curve(m/p[2] - p[1]/p[2]*x, from = 0, to = m/p[1], lwd = 2,
      xlab = expression(x[1]),
      ylab = expression(x[2]))

enter image description here


If you want to draw a budget constrain which takes $m$, $p_1$ and $p_2$ as inputs, this is a R code that does it:

# Clear environment
remove(list = ls())

# Enter inputs

# Create plot
plot(c(0,(m/p1)*1.1), c(0,(m/p2)*1.1), type = "n", xlab = expression(x[1]), ylab = expression(x[2]), xaxs="i", yaxs="i")
abline(m/p2, -p1/p2, col = 1, lwd = 2)

You get:

enter image description here

The limit of axes adjust accordingly to the parameters, adding a 10% more to each axis crossing point.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.