Comments (1)
I also thought about this. Right now the function I developed (not published yet) allows creating budget constraint as in the image below, but not the corresponding indifference curves. The problem is that I can't add the indifference curve from a line in an automatic manner, but add a tanget to a indifference curve, so I'm not sure if this functionality should be added within the indifference
function.
budget(rect1, rect2, x = c(3, 5), labels = c("A", "B"))
What I've tried so far is the following:
# Data
curve2 <- data.frame(Hmisc::bezier(c(1, 3, 9),
c(9, 3, 1)))
x <- curve2$x
y <- curve2$y
plot(x, y)
spl <- smooth.spline(y ~ x)
lines(spl, col = 2)
newx <- 4
pred0 <- predict(spl, x = newx, deriv = 0)
pred1 <- predict(spl, x = newx, deriv = 1)
yint <- pred0$y - (pred1$y * newx)
xint <- -yint / pred1$y
ggplot(curve2, aes(x = x, y = y)) +
geom_line(data = data.frame(x = x, y = yint + pred1$y * x), color = "red", lwd = 2) +
geom_line(lwd = 2) +
geom_point(data = data.frame(x = pred0$x, y = pred0$y), size = 3, color = "green")
The previous code can be used to add the tangent of a curve. What do you think? If you have any other suggestions or ideas please let me know.
from econocharts.
Related Issues (10)
- Passing curves to supply() and demand() causes error
- Edgeworth Box? HOT 2
- Demand curve type='line' creates supply instead. HOT 1
- Value function in Prospect Theory HOT 5
- Neoclassical labor supply HOT 7
- Allow for demand taxes HOT 1
- Allow subsidies in tax_graph()
- Add infinitely elastic (inelastic) supply and demand curves.
- Add satiation indifference curves (also related, central bank preferences)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from econocharts.