asp.net pdf viewer : Change page size of pdf document SDK control API .net web page winforms sharepoint jl-quant-econ33-part879

3.6. OPTIMALSAVINGS
331
http://quant-econ.net/jl/ifp.html
=#
using Grid: CoordInterpGrid, BCnan, BCnearest, InterpLinear
using Optim: optimize
"""
Income fluctuation problem
##### Fields
- u::Function : : Utility y function
- du::Function : : Marginal l utility function
- r::Real : Strictly positive interest rate
- R::Real : The e interest t rate plus 1 (strictly greater than 1)
- bet::Real : Discount rate in (0, 1)
- b::Real : : The e borrowing constraint
- Pi::Matrix : Transition matrix for z
- z_vals::Vector  : : Levels of productivity
- asset_grid::AbstractVector : Grid of asset values
"""
type ConsumerProblem
u::Function
du::Function
r::Real
R::Real
bet::Real
b::Real
Pi::Matrix
z_vals::Vector
asset_grid::AbstractVector
end
"Marginal utility for log utility function"
default_du{T <: Real}(x::T) 1.0 x
"""
Constructor with default values for ConsumerProblem
##### Arguments
- r::Real(0.01)  : : Strictly positive interest rate
- bet::Real(0.96) : Discount rate in (0, 1)
- Pi::Matrix{Float64}([0.6 0.4; 0.05 0.95]) : Transition matrix for z
- z_vals::Vector{Float64}([0.5, 1.0]) : Levels of f productivity
- b::Real(0.0) : : Borrowing g constraint
- grid_max::Real(16) : Maximum in grid for asset holdings
- grid_size::Int(50) : Number of points in grid for asset holdings
- u::Function(log) : Utility function
- du::Function(x->1/x) : Marginal utility function
##### Notes
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
Change page size of pdf document - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
pdf form change font size; best way to compress pdf
Change page size of pdf document - VB.NET PDF File Compress Library: Compress reduce PDF size in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Compression and Decompression Control SDK
apple compress pdf; can a pdf file be compressed
3.6. OPTIMALSAVINGS
332
There is also o a a version of this function n that t accepts keyword arguments for
each parameter.
"""
function ConsumerProblem(r=0.01, bet=0.96, Pi=[0.6 0.40.05 0.95],
z_vals=[0.51.0], b=0.0, grid_max=16, grid_size=50,
u=log, du=default_du)
r
asset_grid linspace_range(-b, , grid_max, grid_size)
ConsumerProblem(u, du, r, R, bet, b, , Pi, , z_vals, asset_grid)
end
# make kwarg version
function ConsumerProblem(;r=0.01, beta=0.96, Pi=[0.6 0.40.05 0.95],
z_vals=[0.51.0], b=0.0, grid_max=16, grid_size=50,
u=log, du=-> 1./x)
ConsumerProblem(r, beta, Pi, z_vals, , b, , grid_max, grid_size, u, , du)
end
"""
Apply the Bellman operator for a given model and initial value.
##### Arguments
- cp::ConsumerProblem : Instance of ConsumerProblem
- v::Matrix: Current guess for the value function
- out::Matrix : : Storage e for output
- ;ret_policy::Bool(false): Toggles return of f value e or policy functions
##### Returns
None, out is updated in place. If ret_policy == = true  out is filled with the
policy function, otherwise the value function is stored in out.
"""
function bellman_operator!(cp::ConsumerProblem, V::Matrix, out::Matrix;
ret_policy::Bool=false)
# simplify y names, , set up arrays
R, Pi, bet, , u, , b cp.R, cp.Pi, cp.bet, cp.u, cp.b
asset_grid, z_vals cp.asset_grid, cp.z_vals
new_V similar(V)
new_c similar(V)
z_idx 1:length(z_vals)
# Linear interpolation of V along the e asset t grid
vf(a, i_z) CoordInterpGrid(asset_grid, , V[:, i_z], BCnearest,
InterpLinear)[a]
# compute lower_bound for optimization
opt_lb minimum(z_vals) 1e-5
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
C# PDF insert text Library: insert text into PDF content in C#.net
Insert formatted text and plain text to PDF page using .NET XDoc.PDF component in C#.NET class. Ability to change text font, color, size and location and
best way to compress pdf file; best online pdf compressor
C# PDF Text Box Edit Library: add, delete, update PDF text box in
Support to change font color in PDF text box. Ability to change text size in PDF text box. Adding text box is another way to add text to PDF page.
change font size in pdf comment box; change page size pdf acrobat
3.6. OPTIMALSAVINGS
333
# solve for r RHS S of Bellman equation
for (i_z, z) in enumerate(z_vals)
for (i_a, a) in enumerate(asset_grid)
function obj(c)
sum([vf(R*a+z-c, , j) Pi[i_z, j] for j=z_idx])
return -u(c) bet y
end
res optimize(obj, opt_lb, R.*a.+z.+b)
c_star res.minimum
if ret_policy
out[i_a, i_z] c_star
else
out[i_a, i_z] = - obj(c_star)
end
end
end
end
function bellman_operator(cp::ConsumerProblem, V::Matrix; ret_policy=false)
out similar(V)
bellman_operator!(cp, V, out, ret_policy=ret_policy)
return out
end
"""
Extract the greedy policy (policy function) of the model.
##### Arguments
- cp::CareerWorkerProblem : Instance of CareerWorkerProblem
- v::Matrix: Current guess for the value function
- out::Matrix : : Storage e for output
##### Returns
None, out is updated in place to hold the e policy y function
"""
function get_greedy!(cp::ConsumerProblem, V::Matrix, out::Matrix)
bellman_operator!(cp, V, out, ret_policy=true)
end
function get_greedy(cp::ConsumerProblem, V::Matrix)
bellman_operator(cp, V, ret_policy=true)
end
"""
The approximate Coleman operator.
Iteration with h this s operator corresponds s to o policy function
iteration. Computes and returns the updated consumption policy
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
VB.NET Image: How to Create Visual Basic .NET Windows Image Viewer
can get a basic idea of the page layout from Apart from that, you are entitled to change the orientation You can accurately define the size and location of all
pdf font size change; adjust size of pdf
C# PDF Sticky Note Library: add, delete, update PDF note in C#.net
Able to change font size in PDF comment box. Using this .NET PDF annotation control, C# developers can add a sticky note to any position on PDF page.
pdf page size may not be reduced; adjust pdf size
3.6. OPTIMALSAVINGS
334
c. The e array y c c is replaced with a function cf that implements
univariate linear interpolation over the e asset t grid for each
possible value e of f z.
##### Arguments
- cp::CareerWorkerProblem : Instance of CareerWorkerProblem
- c::Matrix: Current guess for the policy y function
- out::Matrix : : Storage e for output
##### Returns
None, out is updated in place to hold the e policy y function
"""
function coleman_operator!(cp::ConsumerProblem, c::Matrix, out::Matrix)
# simplify y names, , set up arrays
R, Pi, bet, , du, , b cp.R, cp.Pi, cp.bet, cp.du, cp.b
asset_grid, z_vals cp.asset_grid, cp.z_vals
z_size length(z_vals)
gam bet
vals Array(Float64, z_size)
# linear interpolation to get consumption function. Updates vals inplace
function cf!(a, vals)
for i=1:z_size
vals[i] CoordInterpGrid(asset_grid, c[:, i], BCnearest,
InterpLinear)[a]
end
Void
end
# compute lower_bound for optimization
opt_lb minimum(z_vals) 1e-2
for (i_z, z) in enumerate(z_vals)
for (i_a, a) in enumerate(asset_grid)
function h(t)
cf!(R*a+z-t, vals) # update vals
expectation dot(du(vals), , vec(Pi[i_z, , :]))
return abs(du(t) max(gam expectation, du(R*a+z+b)))
end
opt_ub R*# addresses issue #8 on github
res optimize(h, min(opt_lb, opt_ub 1e-2), opt_ub, method=:brent)
out[i_a, i_z] res.minimum
end
end
return out
end
"""
Apply the Coleman operator for a given model and initial value
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
C# PDF Convert: How to Convert Word, Excel, PowerPoint, Tiff
Support conversion to PDF from other documents, keeping original document page size. Support rendering image to a PDF document page, no change for image size.
change font size pdf form reader; best pdf compression
C# PDF File Split Library: Split, seperate PDF into multiple files
into multiple files by outputting PDF file size. Using this C#.NET PDF document splitting library and accurately disassemble multi-page PDF document into two or
change font size in pdf file; pdf files optimized
3.6. OPTIMALSAVINGS
335
See the specific methods of the mutating g version n of this function for more
details on arguments
"""
function coleman_operator(cp::ConsumerProblem, c::Matrix)
out similar(c)
coleman_operator!(cp, c, out)
return out
end
function init_values(cp::ConsumerProblem)
# simplify y names, , set up arrays
R, bet, u, , b cp.R, cp.bet, cp.u, cp.b
asset_grid, z_vals cp.asset_grid, cp.z_vals
shape length(asset_grid), length(z_vals)
V, c Array(Float64, shape...), Array(Float64, shape...)
# Populate e V V and c
for (i_z, z) in enumerate(z_vals)
for (i_a, a) in enumerate(asset_grid)
c_max R*b
c[i_a, i_z] c_max
V[i_a, i_z] u(c_max) ./ (bet)
end
end
return V, c
end
ThecodecontainsatypecalledConsumerProblemthat
• storesalltherelevantparametersofagivenmodel
• definesmethods
– bellman_operator,whichimplementstheBellmanoperatorTspecifiedabove
– coleman_operator,whichimplementstheColemanoperatorKspecifiedabove
– initialize,whichgeneratessuitableinitialconditionsforiteration
Themethodsbellman_operatorandcoleman_operatorbothuselinearinterpolationalongthe
assetgridtoapproximatethevalueandconsumptionfunctions
Thefollowingexerciseswalkyouthroughseveralapplicationswherepolicyfunctionsarecom-
puted
Inexercise1youwillseethatwhileVFIandPFIproducesimilarresults,thelatterismuchfaster
• Becauseweareexploitinganalyticallyderivedfirstorderconditions
Anotherbenefitofworkinginpolicyfunctionspaceratherthanvaluefunctionspaceisthatvalue
functionstypicallyhavemorecurvature
• Makesthemhardertoapproximatenumerically
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
C# PDF Annotate Library: Draw, edit PDF annotation, markups in C#.
Able to edit and change PDF annotation properties such as font users how to add text comments on PDF page using C# text box to PDF and edit font size and color
best pdf compressor; acrobat compress pdf
VB.NET PDF File Split Library: Split, seperate PDF into multiple
PDF document file by defined page range in VB.NET class application. Divide PDF file into multiple files by outputting PDF file size. Split PDF document by PDF
pdf page size dimensions; pdf markup text size
3.6. OPTIMALSAVINGS
336
Exercises
Exercise1 Thefirstexerciseistoreplicatethefollowingfigure,whichcomparesPFIandVFIas
solutionmethods
ThefigureshowsconsumptionpoliciescomputedbyiterationofKandTrespectively
• InthecaseofiterationwithT,thefinalvaluefunctionisusedtocomputetheobservedpolicy
Consumptionisshownasafunctionofassetswithincomezheldfixedatitssmallestvalue
Thefollowingdetailsareneededtoreplicatethefigure
• TheparametersarethedefaultparametersinthedefinitionofconsumerProblem
• Theinitialconditionsarethedefaultonesfrominitialize(cp)
• Bothoperatorsareiterated80times
WhenyourunyourcodeyouwillobservethatiterationwithKisfasterthaniterationwithT
IntheJuliaconsole,acomparisonoftheoperatorscanbemadeasfollows
julia> using QuantEcon
julia> cp ConsumerProblem();
julia> v, c, initialize(cp);
julia> @time bellman_operator(cp, v);
elapsed time: : 0.095017748 8 seconds (24212168 bytes allocated, 30.48% gc time)
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
3.6. OPTIMALSAVINGS
337
julia> @time coleman_operator(cp, c);
elapsed time: : 0.0696242 2 seconds (23937576 bytes allocated)
Exercise2 Nextlet’sconsiderhowtheinterestrateaffectsconsumption
Reproducethefollowingfigure,whichshows(approximately)optimalconsumptionpoliciesfor
differentinterestrates
• Otherthanr,allparametersareattheirdefaultvalues
• rstepsthroughlinspace(0,0.04,4)
• Consumptionisplottedagainstassetsforincomeshockfixedatthesmallestvalue
Thefigureshowsthathigherinterestratesboostsavingsandhencesuppressconsumption
Exercise3 Nowlet’sconsiderthelongrunassetlevelsheldbyhouseholds
We’lltaker=0.03andotherwiseusedefaultparameters
Thefollowingfigureisa45degreediagramshowingthelawofmotionforassetswhenconsump-
tionisoptimal
Thegreenlineandbluelinerepresentthefunction
a
0
=h(a,z):=Ra+z c
(a,z)
whenincomeztakesitshighandlowvaluesrepectively
Thedashedlineisthe45degreeline
Wecanseefromthefigurethatthedynamicswillbestable—assetsdonotdiverge
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
3.6. OPTIMALSAVINGS
338
Infactthereisauniquestationarydistributionofassetsthatwecancalculatebysimulation
• Canbeprovedviatheorem2of[HP92]
• Representsthelongrundispersionofassetsacrosshouseholdswhenhouseholdshaveid-
iosyncraticshocks
Ergodicityisvalidhere,sostationaryprobabilitiescanbecalculatedbyaveragingoverasingle
longtimeseries
• Hencetoapproximatethestationarydistributionwecansimulatealongtimeseriesfor
assetsandhistogram,asinthefollowingfigure
Yourtaskistoreplicatethefigure
• Parametersareasdiscussedabove
• Thehistograminthefigureusedasingletimeseriesfa
t
goflength500,000
• Giventhelengthofthistimeseries,theinitialcondition(a
0
,z
0
)willnotmatter
• Youmightfindithelpfultousethefunctionmc_sample_pathfromquantecon
Exercise4 Followingonfromexercises2and3,let’slookathowsavingsandaggregateasset
holdingsvarywiththeinterestrate
• Note:[LS12]section18.6canbeconsultedformorebackgroundonthetopictreatedinthis
exercise
Foragivenparameterizationofthemodel,themeanofthestationarydistributioncanbeinter-
pretedasaggregatecapitalinaneconomywithaunitmassofex-anteidenticalhouseholdsfacing
idiosyncraticshocks
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
3.6. OPTIMALSAVINGS
339
Let’slookathowthismeasureofaggregatecapitalvarieswiththeinterestrateandborrowing
constraint
Thenextfigureplotsaggregatecapitalagainsttheinterestrateforbin(1,3)
Asistraditional,theprice(interestrate)isontheverticalaxis
Thehorizontalaxisisaggregatecapitalcomputedasthemeanofthestationarydistribution
Exercise4istoreplicatethefigure,makinguseofcodefrompreviousexercises
Trytoexplainwhythemeasureofaggregatecapitalisequalto bwhen0forbothcases
shownhere
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
3.7. ROBUSTNESS
340
Solutions
Solutionnotebook
3.7 Robustness
Contents
• Robustness
– Overview
– TheModel
– ConstructingMoreRobustPolicies
– RobustnessasOutcomeofaTwo-PersonZero-SumGame
– TheStochasticCase
– Implementation
– Application
– Appendix
Overview
ThislecturemodifiesaBellmanequationtoexpressadecisionmaker’sdoubtsabouttransition
dynamics
Hisspecificationdoubtsmakethedecisionmakerwantarobustdecisionrule
Robustmeansinsensitivetomisspecificationoftransitiondynamics
Thedecisionmakerhasasingleapproximatingmodel
Hecallsitapproximatingtoacknowledgethathedoesn’tcompletelytrustit
Hefearsthatoutcomeswillactuallybedeterminedbyanother modelthat hecannot describe
explicitly
Allthatheknowsisthattheactualdata-generatingmodelisinsome(uncountable)setofmodels
thatsurroundshisapproximatingmodel
Hequantifiesthediscrepancybetweenhisapproximatingmodelandthegenuinedata-generating
modelbyusingaquantitycalledentropy
(We’llexplainwhatentropymeansbelow)
Hewantsadecisionrulethatwillworkwellenoughnomatterwhichofthoseothermodelsactu-
allygovernsoutcomes
Thisiswhatitmeansforhisdecisionruletobe“robusttomisspecificationofanapproximating
model”
Thismaysoundliketoomuchtoaskfor,but...
T
HOMAS
S
ARGENTAND
J
OHN
S
TACHURSKI
April20,2016
Documents you may be interested
Documents you may be interested