﻿
Chapter34. Nonparametricmethods
310
i
y
i
ˆy
i
.
Robustnessweights,
k
,aredeﬁnedby
k
Be
k
=6s
wheresisthemedianoftheje
i
jandBisthebisquarefunction,
Bx
(
x
2
2
forjxj<1
0
forjxj1
Thepolynomialregressionisthenre-runusingweight
k
w
k
x
i
atx
k
;y
k
.
Theloess()functioningretltakesuptoﬁveargumentsasfollows:theyseries,thexseries,the
argumentsareoptional: iftheyareomittedthedefaultvaluesared1,0:5andnorobust
speciﬁed,threequartersofthedatapointswillbeusedineachlocalregression,androbustnessis
turnedon:
series yh = loess(y, x, 2, 0.75, 1)
sinewavecomponentoverlaidwithnoiseuniformlydistributedon 1;1. Loessisthenusedto
retrieveagoodapproximationtothesinefunction.TheresultinggraphisshowninFigure34.1.
Example34.1:Loessscript
nulldata 120
series x = index
scalar n = $nobs series y = sin(2*pi*x/n) ) + + uniform(-1, 1) series yh = loess(y, x, , 2, , 0.75, 0) gnuplot y yh h x x --output=display --with-lines=yh -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 0 20 40 60 80 100 120 x loess fit Figure34.1:Loess: retrievingasinewave C# convert pdf to jpg - Convert PDF to JPEG images in C#.net, ASP.NET MVC, WinForms, WPF project How to convert PDF to JPEG using C#.NET PDF to JPEG conversion / converter library control SDK change pdf into jpg; convert pdf image to jpg C# convert pdf to jpg - VB.NET PDF Convert to Jpeg SDK: Convert PDF to JPEG images in vb.net, ASP.NET MVC, WinForms, WPF project Online Tutorial for PDF to JPEG (JPG) Conversion in VB.NET Image Application .pdf to .jpg converter online; change pdf to jpg format Chapter34. Nonparametricmethods 311 34.2 TheNadaraya–Watsonestimator TheNadaraya–Watsonnonparametric estimator (Nadaraya1964Watson1964) is an estimator for theconditional l meanofa variableY, availableinasampleof sizen, for r agivenvalueof a conditioningvariableX,andisdeﬁnedas mX P n j1 y j K h X x j P n j1 K h X x j whereK h istheso-calledkernelfunction, whichisusuallysomesimpletransformofadensity functionthatdependsonascalarcalledthebandwidth.Theonegretlusesisgivenby K h xexp x 2 2h ! for jxj<   and zero otherwise. . The e scalar  is used to prevent t numericalproblems when the kernelfunctionisevaluatedtoofarawayfromzeroandiscalledthetrimparameter. Example34.2: Nadaraya–Watsonexample # Nonparametric c regression example: : husband’s age e on wife’s age open mroz87.gdt # initial l value for the e bandwidth scalar h =$nobs^(-0.2)
# three e increasingly smooth estimates
series m0 = nadarwat(HA, , WA, , h)
series m1 = nadarwat(HA, , WA, , h * 5)
series m2 = nadarwat(HA, , WA, , h * 10)
# produce e the e graph
dataset sortby WA
gnuplot HA m0 0 m1 1 m2 WA --output=display --with-lines=m0,m1,m2
Example34.2producesthegraphshowninFigure34.2(aftersomeslightediting).
smaller values s makethemfunction follow they
i
values moreclosely, , so that t thefunction
appearsmore“jagged”. Infact,ash!1,mx
i
!
¯
Y;onthecontrary,ifh!0,observationsfor
whichx
i
6arenottakenintoaccountatallwhencomputingmX.
Also,thestatisticalpropertiesofmvarywithh: itsvariancecanbeshowntobedecreasingin
h,whileitssquaredbiasisincreasinginh.Itcanbeshownthatchoosingh1=minimizesthe
RMSE,sothatvalueiscustomarilytakenasareferencepoint.
Notethatthekernelfunction hasits tails “trimmed”. . Thescalar , which h controls thelevel at
whichtrimmingoccursissetbydefaultat4h;thissetting,however,maybechangedviatheset
command. Forexample,
sets   10h. This s mayat times producemoresensible e results s in regions of withsparse
support; however, youshouldbeawarethatinthosesamecases machineprecision(divisionby
numericalzero)mayrenderyourresultsspurious.Thedefaultisrelativelysafe,butexperimenting
withlargervaluesmaybeasensiblestrategyinsomecases.
Online Convert Jpeg to PDF file. Best free online export Jpg image
So, feel free to convert them too with our tool. Easy converting! If you want to turn PDF file into image file format in C# application, then RasterEdge
convert pdf to 300 dpi jpg; convert pdf to jpg converter
C# Create PDF from images Library to convert Jpeg, png images to
Best and professional C# image to PDF converter SDK for Visual Studio .NET. Batch convert PDF documents from multiple image formats, including Jpg, Png, Bmp, Gif
convert pdf to jpg 300 dpi; convert .pdf to .jpg
Chapter34. Nonparametricmethods
312
30
35
40
45
50
55
60
30
35
40
45
50
55
60
HA
WA
m0
m1
m2
Acommonvariant of theNadaraya–Watsonestimator r is theso-called“leave-one-out”estimator:
thisisavariantoftheestimatorthatdoesnotusethei-thobservationforevaluatingmx
i
. This
Informulae,theleave-one-outestimatoris
mx
i
P
j6i
y
j
K
h
x
i
x
j
P
j6i
K
h
x
i
x
j
Inordertohavegretlcomputetheleave-one-outestimator,justreversethesignofh:ifwechanged
example34.2bysubstituting
scalar h h = $nobs^(-0.2) with scalar h h = -($nobs^(-0.2))
therestoftheexamplewouldhavestayedunchanged,theonlydiﬀerencebeingtheusageofthe
leave-one-outestimator.
Althoughcouldbe, in principle, anyvalue, in thetypicalusageofthis estimator you wantto
computemXforequaltooneormorevaluesactuallyobservedinyoursample,thatismx
i
.
IfyouneedapointestimateofmXforsomevalueofwhichisnotpresentamongthevalid
datasetinwhichyismissingandxcontainsthevaluesyouwantmxevaluatedat.Forexample,
thefollowingscriptevaluatesmxatregularintervalsbetween-2.0and2.0:
nulldata 120
set seed d 120496
# first t part t of the e sample: : actual data
smpl 1 100
Online Convert PDF to Jpeg images. Best free online PDF JPEG
it as easy as possible to convert your PDF XDoc.PDF for .NET) supports converting PDF document to in .NET developing platforms using simple C# programming code
convert pdf to jpg file; changing file from pdf to jpg
C# Image Convert: How to Convert Adobe PDF to Jpeg, Png, Bmp, &
C# sample code for PDF to jpg image conversion. This demo code convert PDF file all pages to jpg images. // Define input and output files path.
batch pdf to jpg online; convert pdf image to jpg image
Chapter34. Nonparametricmethods
313
x = normal()
y = x^2 2 + + sin(x) + + normal()
# second d part t of the sample: fake x data
smpl 101 1 120
x = (obs-110) / 5
# compute the Nadaraya-Watson n estimate
# with bandwidth equal to 0.4 4 (note e that
# 100^(-0.2) = 0.398)
smpl full
m = nadarwat(y, x, , 0.4)
# show m(x) for the e fake e x values only
smpl 101 1 120
print x x m m -o
andrunningitproduces
x
m
101
-1.8
1.165934
102
-1.6
0.730221
103
-1.4
0.314705
104
-1.2
0.026057
105
-1.0
-0.131999
106
-0.8
-0.215445
107
-0.6
-0.269257
108
-0.4
-0.304451
109
-0.2
-0.306448
110
0.0
-0.238766
111
0.2
-0.038837
112
0.4
0.354660
113
0.6
0.908178
114
0.8
1.485178
115
1.0
2.000003
116
1.2
2.460100
117
1.4
2.905176
118
1.6
3.380874
119
1.8
3.927682
120
2.0
4.538364
C# Image Convert: How to Convert Tiff Image to Jpeg, Png, Bmp, &
RasterEdge.XDoc.Office.Inner.Office03.dll. RasterEdge.XDoc.PDF.dll. RasterEdge.XDoc. PowerPoint.dll. RasterEdge.XDoc.TIFF.dll. C# Image Convert: Tiff to Png.
reader pdf to jpeg; change pdf to jpg file
C# PDF Convert to Tiff SDK: Convert PDF to tiff images in C#.net
Supports for changing image size. Also supports convert PDF files to jpg, jpeg images. C# class source codes and online demos are provided for .NET.
convert pdf to jpg for online; changing pdf file to jpg
PartIII
Technicaldetails
314
C# TIFF: C#.NET Code to Convert JPEG Images to TIFF
Use C# Code to Convert Jpeg to Tiff. Firstly, you may use following C# sample code to transform string[] imagePaths = { @"C:\demo1.jpg", @"C:\demo2.jpg", @"C
change pdf to jpg on; convert multiple page pdf to jpg
VB.NET PDF Convert to Images SDK: Convert PDF to png, gif images
Resize converted image files in VB.NET. Convert PDF to Jpg, Png, Bmp, Gif, Tiff and Bitmap in ASP.NET. Embed PDF to image converter in viewer.
change file from pdf to jpg; bulk pdf to jpg converter online
Chapter35
GretlandT
E
X
35.1 Introduction
T
E
X —initiallydevelopedbyDonaldKnuthofStanfordUniversityandsinceenhancedbyhundreds
ofcontributorsaroundtheworld — isthegoldstandardofscientiﬁctypesetting. . Gretlprovides
varioushooksthatenableyoutopreviewandprinteconometricresultsusingtheT
E
Xengine,and
tosaveoutputinaformsuitableforfurtherprocessingwithT
E
X.
Thischapterexplainstheﬁnerpointsofgretl’sT
E
X-relatedfunctionality.Thenextsectiondescribes
E
Xoutput; andsection35.4
givessomepointersoninstalling(andlearning)T
E
(Justtobeclear: T
E
Xisnotincludedwiththegretldistribution;itisaseparatepackage,including
severalprogramsandalargenumberofsupportingﬁles.)
Beforeproceeding,however,itmaybeusefultosetoutbrieﬂythestagesofproductionofaﬁnal
documentusingT
E
topreviewingatanyrate,gretlhandlesthemforyou. Buthavingsomegraspofwhatisgoingon
behindthescenceswillenableyoutounderstandyouroptionsbetter.
Theﬁrststep isthecreationofaplaintext“source”ﬁle, containing thetextor mathematics to
betypset, interspersedwithmark-upthatdeﬁnes howitshouldbeformatted. . Thesecondstep
istorunthesourcethroughaprocessingenginethatdoestheactualformatting. Typicallythisa
programcalledpdﬂatexthatgeneratesPDFoutput.
1
(Intimesgonebyitwasaprogramcalledlatex
thatgeneratedso-calledDVI(device-independent)output.)
Sogretlcallspdﬂatextoprocessthesourceﬁle. OnMSWindowsandMacOSX,gretlexpectsthe
operatingsystemto ﬁndthedefaultviewerforPDFoutput. . OnGNU/Linuxyoucanspecifyyour
35.2 T
E
Themodelwindow
ThefullestT
E
XsupportingretlisfoundintheGUImodel window. . This s has amenuitemtitled
“LaTeX”withsub-items“View”,“Copy”,“Save”and“Equationoptions”(seeFigure35.1).
Theﬁrstthreesub-itemshavebranchestitled“Tabular”and“Equation”.By“Tabular”wemeanthat
themodelisrepresentedintheformofatable;thisisthefullestandmostexplicitpresentationof
theresults. SeeTable35.1foranexample;thiswaspastedintothemanualafterusingthe“Copy,
Tabular”itemingretl(afewlineswereeditedoutforbrevity).
The“Equation”optionisfairlyself-explanatory—theresultsarewrittenacrossthepageinequation
format,asbelow:
˘
ENROLL0:241105
0:066022
0:223530
0:04597
CATHOL 0:00338200
0:0027196
PUPIL 0:152643
0:040706
WHITE
T51
¯
R
2
0:4462 F3;4714:431 1 ˆ0:038856
1
Expertswillbeawareofsomethingcalled“plainT
E
X”,whichisprocessedusingtheprogramtex.Thegreatmajority
ofT
E
Xusers,however,usetheL
A
T
E
Xmacros,initiallydevelopedbyLeslieLamport.gretldoesnotsupportplainT
E
X.
315
Chapter35. GretlandT
E
X
316
Figure35.1:LAT
E
Table35.1:ExampleofLAT
E
Xtabularoutput
Model1:OLSestimatesusingthe51observations1–51
Dependentvariable:ENROLL
Variable
Coeﬃcient
Std.Error
t-statistic
p-value
const
0:241105
0:0660225
3:6519
0:0007
CATHOL
0:223530
0:0459701
4:8625
0:0000
PUPIL
0:00338200
0:00271962
1:2436
0:2198
WHITE
0:152643
0:0407064
3:7499
0:0005
Meanofdependentvariable
0:0955686
S.D.ofdependentvariable
0:0522150
Sumofsquaredresiduals
0:0709594
Standarderrorofresiduals(ˆ)
0:0388558
0:479466
¯
R2
0:446241
F3;47
14:4306
Chapter35. GretlandT
E
X
317
(standarderrorsinparentheses)
Thedistinctionbetweenthe“Copy”and“Save”options(forbothtabularandequation)istwofold.
First,“Copy”putstheT
E
Xsourceontheclipboardwhilewith“Save”youarepromptedforthename
ofaﬁleintowhichthesourceshouldbesaved. Second, , with“Copy”thematerialis copiedas a
“fragment”whilewith“Save”itiswrittenasacompleteﬁle. Thepointisthatawell-formedT
E
X
andtagsthatsay\begin{document}and\end{document}.Thismaterialisincludedwhenyoudo
“Save”butnotwhenyoudo“Copy”,sinceinthelattercasetheexpectationisthatyouwillpaste
thedataintoanexistingT
E
Theitemsunder“Equationoptions”shouldbeself-explanatory: whenprintingthemodelinequa-
tionform,doyouwantstandarderrorsort-ratiosdisplayedinparenthesesundertheparameter
estimates?Thedefaultistoshowstandarderrors;ifyouwantt-ratios,selectthatitem.
Otherwindows
SeveralothersortsofoutputwindowsalsohaveT
E
Xpreview,copyandsaveenabled. Inthecaseof
windowshavingagraphicaltoolbar,lookfortheT
E
Xbutton. Figure35.2showsthisicon(second
fromtherightonthetoolbar)alongwiththedialogthatappearswhenyoupressthebutton.
Figure35.2:T
E
Xiconanddialog
Oneaspectofgretl’sT
E
Xsupportthatislikelytobeparticularlyusefulforpublicationpurposesis
theabilitytoproduceatypesetversionofthe“modeltable”(seesection3.4).Anexampleofthisis
showninTable35.2.
35.3 Fine-tuningtypesetoutput
There are three aspects to this: : adjusting g the e appearance of f the e output produced d by gretl in
L
A
T
E
tabprintcommand;andincorporatinggretl’soutputintoyourownT
E
Xﬁles.
PreviewingintheGUI
As regards preview mode, you u can control theappearanceof gretl’s output using a ﬁle named
gretlpre.tex,whichshouldbeplacedinyourgretluserdirectory(seetheGretl CommandRef-
erence). Ifsuchaﬁleisfound,itscontentswillbeusedasthe“preamble”totheT
E
Xsource. The
defaultvalueofthepreambleisasfollows:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
Chapter35. GretlandT
E
X
318
Table35.2:Exampleofmodeltableoutput
OLSestimates
Dependentvariable:ENROLL
Model1
Model2
Model3
const
0.2907
0.2411
0.08557
(0.07853)
(0.06602)
(0.05794)
CATHOL
0.2216

0.2235

0.2065

(0.04584)
(0.04597)
(0.05160)
PUPIL
0.003035
0.003382
0.001697
(0.002727)
(0.002720)
(0.003025)
WHITE
0.1482

0.1526

(0.04074)
(0.04071)
0.1551
(0.1342)
n
51
51
51
¯
R2
0.4502
0.4462
0.2956
96.09
95.36
88.69
Standarderrorsinparentheses
*indicatessigniﬁcanceatthe10percentlevel
**indicatessigniﬁcanceatthe5percentlevel
Chapter35. GretlandT
E
X
319
\usepackage{amsmath}
\usepackage{dcolumn,longtable}
\begin{document}
\thispagestyle{empty}
Notethattheamsmathanddcolumnpackagesarerequired.(Forsomesortsofoutputthelongtable
packageisalsoneeded.) Beyondthatyoucan,forinstance,changethetypesizeorthefontbyal-
teringthedocumentclassdeclarationorincludinganalternativefontpackage.
Inaddition, if you wishto typesetgretloutput inmorethanonelanguage, you canset upper-
languagepreambleﬁles.A“localized”preambleﬁleisidentiﬁedbyanameoftheformgretlpre_xx.tex,
wherexxisreplacedbytheﬁrsttwo letters ofthecurrentsettingoftheLANGenvironmentvari-
able. Forexample,ifyouarerunningtheprograminPolish,usingLANG=pl_PL,thengretlwilldo
thefollowingwhenwritingthepreambleforaT
E
Xsourceﬁle.
1. Lookforaﬁlenamedgretlpre_pl.texinthegretluserdirectory.Ifthisisnotfound,then
2. lookforaﬁlenamedgretlpre.texinthegretluserdirectory.Ifthisisnotfound,then
3. usethedefaultpreamble.
Conversely, supposeyouusuallyrungretlinalanguageother thanEnglish,andhaveasuitable
gretlpre.texﬁleinplaceforyournativelanguage.IfonsomeoccasionsyouwanttoproduceT
E
X
forthepreamblewhengretlisrunwithalanguagesettingof,say,en_US.
Command-lineoptions
Afterestimatingamodelviaascript—orinteractivelyviathegretlconsoleorusingthecommand-
lineprogramgretlcli—youcanusethecommandstabprint oreqnprintto printthemodelto
ﬁleintabular formator equation n formatrespectively. . Theseoptions s areexplained intheGretl
CommandReference.
Ifyouwishaltertheappearanceofgretl’stabularoutputformodelsinthecontextofthetabprint
command,youcanspecifyacustomrowformatusingthe--formatﬂag. Theformatstringmust
beenclosedindoublequotesandmustbetiedtotheﬂagwithanequalssign. Thepatternforthe
formatstring isasfollows. . Therearefourﬁelds,representingthecoeﬃcient, , standarderror, t-
ratioandp-valuerespectively. Theseﬁeldsshouldbeseparatedbyverticalbars;theymaycontain
aprintf-typespeciﬁcation for r the e formatting g ofthenumeric valueinquestion, or may beleft
blanktosuppresstheprintingofthatcolumn(subjecttotheconstraintthatyoucan’tleaveallthe
columnsblank).Hereareafewexamples:
--format="%.4f|%.4f|%.4f|%.4f"
--format="%.4f|%.4f|%.3f|"
--format="%.5f|%.4f||%.4f"
--format="%.8g|%.8g||%.4f"
Theﬁrstofthesespeciﬁcationsprintsthevaluesinallcolumnsusing4decimalplaces.Thesecond
suppressesthep-valueandprintsthet-ratioto3places. Thethirdomitsthet-ratio. Thelastone
againomitsthet,andprintsbothcoeﬃcientandstandarderrorto8signiﬁcantﬁgures.
Onceyousetacustomformatinthisway,itisrememberedandusedforthedurationofthegretl
session.Toreverttothedefaultformattingyoucanusethespecialvariant--format=default.
Furtherediting
Onceyouhavepastedgretl’sT
E
Xoutputintoyourowndocument,orsavedittoﬁleandopenedit
inaneditor,youcanofcoursemodifythematerialinanywishyouwish. Insomecases,machine-
generated T
E
X is s hard d to o understand, but gretl’s s output is s intended d to o be human-readableand