510 QUARTERLY JOURNAL OF ECONOMICS
where is the achievement level of student in school is a
Y i j, S
ij ij
vector of school characteristics, is a vector representing the
F ij e
family background of the student, and is a stochastic error
ij
component. In principle, and include information cumulated
S F
ij ij
over the student’s life; for example, classroom size and teacher
qualications for each year the student attended school. The
entire history of family background variables and school resources
may contribute to students’ achievement in a given year. In
addition, children’s unobserved inherent ability may contribute to
their achievement. In any actual application we will generally
lack data on some relevant school, family, or student characteris-
tics. These omitted variables will then appear in the error term. If
the omitted variables are correlated with the included variables,
then the estimated parameters will be biased.
If a school characteristic such as class size is determined by
random assignment, however, it will be independent of the
omitted variables. Thus, with random assignment, a simple
comparison of mean achievement between children in small and
large classes provides an unbiased estimate of the effect of class
size on achievement.
We begin analyzing the STAR data by estimating the follow-
ing regression equation for students in each grade level:
5 b 1 b 1 b 1 b 1 a 1 e
(2) ,
Y SMALL REG/A X
0 1 2 3
ics cs cs ics s ics
where is the average percentile score on the SAT test of
Y
ics
student in class at school is a dummy variable
i c s, SMALL cs
indicating whether the student was assigned to a small class that
year, is a dummy variable indicating whether the student
REG/A cs
was assigned to a regular-size class with an aide that year, and X ics
is a vector of observed student and teacher covariates (e.g.,
gender). The independence between class-size assignment and
other variables is only valid within schools, because randomiza-
tion was done within schools. Consequently, a separate dummy
a
variable is included for each school to absorb the school effects, .
s
The equation is estimated by ordinary least squares (OLS). In
e
calculating the standard errors, however, the error term is
ics
e
modeled in a components-of-variance framework. Specically, ics
e 5 1 e
is assumed to consist of two components: µ , where µ
8
ics cs ics cs
is a class-specic random component that is common to all
e
members of the same class, and is an idiosyncratic error term.
8
ics
The class-specic component µ may exist because of unobserved
cs
Compliance types
NO
• This is defined in terms of potential outcomes (W (1) and
• i
W (0)), but we only observe:
i W = Z [W (1)] + (1 Z )[W (0)]
i i i i i
which implies that the observed compliance types are not
identified: Z = 0 Z = 1
i i
Complier Never taker Defier Never taker
W = 0 / /
i Defier Always taker Complier Always Taker
W = 1 / /
i tue
d CioQctedlh
paouhces
UA
Paedetoruineo aieenton
tprapato dueuba
Ls2 oted
ce
wot o
W shocus re
Pce
Qince
J
ehorcary keepiy
depdeaH
2
Ceh (onnprautr
24
24
sla hke
NOeed o eeiiuselCAee
RocleRyoe
What is a (Linear) SSIV?
A weighted sum of a common set of shocks , with weights reflecting
heterogeneous exposure shares : P
z = s g
n
` `n
n
The shocks vary at a different “level” than the shares
• n = 1, . . . , N
, where we also observe an outcome & treatment
` = 1, . . . , L y x
` `
We want to use to estimate parameter of the model
z β y = βx + ε
` ` ` `
Could be a “structural” equation or a potential outcomes model
• Could be misspecified, with heterogeneous treatment effects
• β `
Could be a “reduced form” analysis, with
• x = z
` `
Could have other included controls
• w `
Key question: under what assumptions does this SSIV strategy “work”?
SSIV Examples shares shocks
X 0
Instrument for model
z = s g y = βx + γ w + ε
n
` `n ` ` ` `
n
Bartik (1991); Blanchard and Katz (1992):
= inverse local labor supply elasticity
• β and = employment and wage growth in region
• x y `
` `
Need a labor demand shifter as an IV
•
SSIV Examples shares shocks
X 0
Instrument for model
z = s g y = βx + γ w + ε
n
` `n ` ` ` `
n
Bartik (1991); Blanchard and Katz (1992):
= inverse local labor supply elasticity
• β and = employment and wage growth in region
• x y `
` `
Need a labor demand shifter as an IV
• = national growth of industry
• g n
n = lagged employment shares (of industry in a region)
• s `n
= predicted employment growth due to national industry trends
• z `
SSIV Examples shares shocks
X 0
Instrument for model
z = s g y = βx + γ w + ε
n
` `n ` ` ` `
n
Autor, Dorn, and Hanson (2013, ADH):
= growth of import competition in region
• x `
` = growth of manuf. employment, unemployment, etc.
• y ` = growth of China exports in manufacturing industry to 8 other
• g n
n
(i.e. non-U.S.) countries
= 10-year lagged employment shares (over total employment)
• s `n
= predicted growth of import competition
• z `
SSIV Examples shares shocks
X 0
Instrument for model
z = s g y = βx + γ w + ε
n
` `n ` ` ` `
n
“Enclave instrument”, e.g. Card (2009)
= inverse elasticity of substitution between native and immigrant
• β
labor of some skill level (need a relative labor supply instrument)
and = relative employment and wage in region
• x y `
` `
= national immigration growth from origin country
• g n
n = lagged shares of migrants from origin in region
• s n `
`n
= share of migrants predicted from enclaves & recent growth
• z `
SSIV Examples shares shocks
X 0
Instrument for model
z = s g y = βx + γ w + ε
n
` `n ` ` ` `
n
Hummels et al. (2014) on offshoring:
= effect of imports on wages
• β = imports by Danish firm = wages
• x `, y
` `
= changes in transport costs by (product, country)
• g n =
n = lagged import shares
• s `n
= predicted change in firm inputs via transport costs
• z ` Integrating ChatGPT Into Your Research
Ingar Haaland
Department of Economics, NHH Norwegian School of Economics
IFN Stockholm, January 31, 2024
What is ChatGPT?
• ChatGPT (Generative Pre-trained Transformer) is a state-of-the-art language model
developed by OpenAI for understanding and generating text.
• It predicts subsequent words in a given context to generate human-like text, making
it useful for a variety of applications such as writing assistance and coding.
• ChatGPT employs the Transformer architecture, a deep learning approach that allows
the model to understand patterns, context, and language structure from vast amounts
of text data.
• To improve its performance, ChatGPT is fine-tuned using Reinforcement Learning
from Human Feedback (RLHF), allowing the model to adapt its responses and
become more effective over time. 1 / 32
Why should you start using ChatGPT?
• It can boost your and
productivity creativity.
• By experimenting with ChatGPT, you can learn more about its strengths and
limitations.
• Over time, you will become better at “prompting” and ChatGPT will become better at
answering your prompts.
• Even if ChatGPT does not make you more productive today, it will make you more
productive tomorrow. 2 / 32
Use Cases of ChatGPT in Economic Research
• ChatGPT can be integrated into your research workflow for a variety of tasks,
including:
Idea generation and feedback on research ideas.
– Language-related tasks, such as generating complete text from crude summaries,
– translating Qualtrics surveys, and proofreading your paper.
Coding-related tasks, including creating figures and tables in R and Python, TikZ figures
– in L TEX, code debugging, and writing complex regular expressions.
A
Qualitative data analysis: Extracting insights and patterns from large amounts of text data
– and assisting in qualitative data analysis.
Qualitative data generation: Conduct qualitative interviews with human subjects.
– Survey design and analysis: Suggesting survey responses, performing sentiment analysis,
– annotating open-ended survey responses, etc.
Providing critical feedback on drafts, ideas, grant applications, etc.
– 3 / 32
Use case example: Translating a Qualtrics survey
Prompt: ChatGPT output:
I will now copy paste content from a CSV file. Sure, here are the Norwegian translations for the phrases:
The CSV files is a language file from Qualtrics that contains original English QID938 QuestionText,”To what extent do you consider ESG ratings when
instructions. I need these translated into Norwegian. buying stocks and stock mutual funds?”,”I hvilken grad tar du hensyn til
ESG-rangeringer når du kjøper aksjer og aksjefond?”
The CSV file has the following structure Choice1,”To a very large extent”,”I svært stor grad”
QID938 Choice2,”To a large extent”,”I stor grad”
QID938
PhraseID,EN,NO QID938 Choice3,”To some extent”,”Til en viss grad”
QID938 Choice4,”To a little extent”,”I liten grad”
For instance, it might say Choice5,”To no extent”,”Ingen grad”
QID938 QuestionText,”How concerned are you about climate
QID937
Q1,”What is your gender?”,”” change?”,”Hvor bekymret er du for klimaendringer?”
QID937 Choice1,”Extremely concerned”,”Ekstremt bekymret”
In this case, you would output something like QID937 Choice2,”Very concerned”,”Svært bekymret”
QID937 Choice3,”Somewhat concerned”,”Noe bekymret”
Q1,”What is your gender?”,”Hva er ditt kjønn?” QID937 Choice4,”Not very concerned”,”Ikke særlig bekymret”
QID937 Choice5,”Not at all concerned”,”Ikke bekymret i det hele tatt”
Here are the responses:
QuestionText,”To what extent do you consider ESG ratings when
QID938
buying stocks and stock mutual funds?”,””
QID938 Choice1,”To a very large extent”,””
QID938 Choice2,”To a large extent”,””
QID938 Choice3,”To some extent”,””
QID938 Choice4,”To a little extent”,””
QID938 Choice5,”To no extent”,””
QID937 QuestionText,”How concerned are you about climate change?”,””
QID937 Choice1,”Extremely concerned”,””
QID937 Choice2,”Very concerned”,””
QID937 Choice3,”Somewhat concerned”,””
QID937 Choice4,”Not very concerned”,””
QID937 Choice5,”Not at all concerned”,”” 4 / 32
Opportunities and limitations
• It is not difficult to create examples where GPT provides nonsensical responses or
makes simple mistakes.
• Continuous development and fine-tuning, along with advancements in AI research,
will lead to better performance and fewer errors in the future
• Try to adopt a “glass half full” attitude and make use of ChatGPT sooner rather than
later. 5 / 32
Overcoming ChatGPT Limitations
• The (free version) of ChatGPT faces many limitations, including its inability to search
the internet for information or integrate with other software without supplementary
tools.
• Possible solutions to address these limitations include:
Researchers can leverage apps like Wolfram Alpha to obtain
Apps and API Integration:
– external information or use a Python API integration to connect ChatGPT with other
software and unlock additional features.
Optimize data and prompts through preprocessing to minimize the
Data Preprocessing:
– need for external information and enhance the generated text’s quality.
Pay for ChatGPT Plus to get access to GPT-4, Internet search, and app
Plus subscription:
– integration. Use Microsoft Bing’s chat engine which is freely running on GPT-4
Alternative software:
– with internet accesss. 6 / 32
Hallucination: A Double-Edged Sword
• Hallucination is a common problem with language models, including ChatGPT,
where the generated text is not supported by the input context, sometimes resulting
in nonsensical or incorrect output.
• Hallucination can be both a strength and a weakness:
Instead of saying “I don’t know,” the model generates a response that seems
Strength:
– correct, showcasing creativity and the ability to produce novel answers.
Hallucination is a major problem in factual tasks, such as coding and literature
Weakness:
– reviews, where accuracy is critical. 7 / 32
Dealing with Hallucination
• Researchers can mitigate the effects of hallucination by:
Training the model on more relevant and
Fine-tuning the model with additional data.
– specific data helps generate more accurate and relevant text.
Designing prompts that elicit desired responses guides the
Using prompt engineering.
– language model
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.