Skip to content

Instantly share code, notes, and snippets.

@trialsolution
trialsolution / polar_rose.R
Created January 1, 2011 16:55
drawing "polar roses" curves in polar coordinate system
require(ggplot2)
#data points
p <- data.frame(t=seq(-2*pi, 2*pi, 0.1))
#1.. drawing polar rose
c <- ggplot(p, aes(x=t, y=cos(3*t)))
c + geom_line() + coord_polar()
#2.. another one with sine
@trialsolution
trialsolution / ev.gms
Created October 31, 2012 11:59
EV frontier analysis for a simple farm management problem
$ontext
PROBLEM STATMENT
EV analysis from Hazell-Norton
AIM: draw the EV-frontier for the following farm planning problem
MODEL 1. EXPECTED PROFIT MAXIMIZATION (farm with fixed land, 4 crops, fixed labour and a rotational constraint)
@trialsolution
trialsolution / ev2.gms
Created November 2, 2012 12:19
utility maximization on the EV frontier
$ontext
PROBLEM STATMENT
EV analysis from Hazell-Norton
ctnd. from ev.gms
Extension: find the optimal farm decision based on EUH; having the EV-frontier and assuming a utility function
@trialsolution
trialsolution / fitting.R
Created November 2, 2012 12:31
fits a linear function to a set of points on the EV-frontier
library(gdxrrw)
library(ggplot2)
# path to the gams installation
igdx("n:/soft/gams/gams23.8_64")
# data input
gdxName <- "EV"
symName <- "EV_frontier"
$title A Macro to Compute Exponential Growth Rates
$ontext
originally posted by T. Rutherford on the gams mailing list
http://www.mpsge.org/exprate.html
extended by me with a nested macro solution (probably easier to follow)
$offtext
$ontext
@trialsolution
trialsolution / calibrated_share_form.gms
Created March 26, 2013 12:33
A worked example for calibrated CES utility functions; from http://www.mpsge.org/calibration.pdf
*=============================================================================
* File : calibrated_share_form.gms
* Author : mihalyh
* Version : 1.0
* Date : 26.03.2013 12:42:25
* Changed : 26.03.2013 13:22:49
* Changed by: mihalyh
* Remarks :
$ontext
Calibrating CES utility functions
@trialsolution
trialsolution / freund_1956.gms
Created April 16, 2013 12:27
GAMS implementation of the textbook example for farm planning model Published in Moss "Risk, uncertainty and the agricultural firm", originally from the article of Freund (1956) in Econometrica
$ontext
Freund showed that the expected utility of a normally distributed gamble given
negative exponential preferences could be written as:
E(U(x)) = mu(x) - rho/2 * sigma^2(x)
where mu and sigma are the mean and standard deviation of the normally distributed gamble
$ontext
Email:
"Dear GAMS Users,
Do you have some examples or code files for panel data estimation in GAMS? I was thinking to combine two indices - individual and time, into one index and run OLS, but I could not get any idea of combining two sets into one.
I guess there is some smart way to do panel data estimation.
@trialsolution
trialsolution / panel_R_link.gms
Created June 3, 2013 08:34
GAMS script that calls the plm package in R to do some panel data econometrics.
@trialsolution
trialsolution / definite.gms
Created August 23, 2013 06:46
checks positive definiteness of a matirx (GAMS and R combined solution)
$ontext
"Is there some GAMS template around to determine the definiteness of a given
matrix? (At the moment, I need it for a 5x5 matrix, but the dimension will
eventually be higher.)
Or is it advisable to switch to another math package for solving this?
Stefan"