Skip to content

Instantly share code, notes, and snippets.

@trialsolution
trialsolution / definite_eigenv.gms
Created August 23, 2013 06:48
checks if a symmetric matrix is pos. definite (GAMS code using the default eigenvalues calculation utility)
$ontext
Test the positive definiteness of a symmetric matrix
Extension of ' eigenexample.gms' from the McCarl User Guide
$offtext
Set index /i1*i3/;
alias(index,index1);
@trialsolution
trialsolution / definite_cholesky.gms
Created August 23, 2013 06:47
checks if a symmetric matrix is pos. definite (GAMS code using the default cholesky decomposition utility)
$ontext
Test the positive definiteness of a symmetric matrix
Extension of the 'choleskyexample.gms' example from the McCarl User Guide
$offtext
Set index /i1*i2/;
@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"
@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.
$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 / 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
@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
$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 / 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"
@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