Skip to content
Snippets Groups Projects
Commit 9a7c5d35 authored by Feenstra, Ninke's avatar Feenstra, Ninke
Browse files

Updates

parent 9fc7fc99
Branches
No related tags found
No related merge requests found
# This is a script where I try new stuff and save stuff that I have learned.
# ========================================================================================
# Project: LearningR
# Subject: Ninke learns R
# Author: Ninke Feenstra
# Contact: ninke.feenstra@wur.nl
# ========================================================================================
# ========================================================================================
# SETUP ----------------------------------------------------------------------------------
# ========================================================================================
# Load pacman for p_load
if(!require(pacman)){
install.packages("pacman")
library(pacman)
} else {
library(pacman)
}
# Load Key packages
p_load("tidyverse","here","glue", "readxl", "Hmisc")
# Set path
source(here("working_paper/scripts/support/get_path.r"))
# ========================================================================================
# LOAD DATA ------------------------------------------------------------------------------
# ========================================================================================
# seed data
bin_raw <- read_excel(file.path(raw_path, glue("BINdata.xlsx")), sheet = "DWH-MA")
labels_raw <- read_excel(file.path(raw_path, glue("BINdata.xlsx")), sheet = "variabele")
# benchmark data
# ========================================================================================
# Tidying the data
# =======================================================================================
# create variable labels
labels_merge <- labels_raw |>
select(c('ID','ToelichtingNL'))
bin_labels <- merge(bin_raw, labels_merge)
bin_labels <- bin_labels |>
mutate(label= ifelse(is.na(ToelichtingNL),NaamNL,ToelichtingNL))
bin_labels <- bin_labels |>
mutate(label= paste(NaamNL2, label, sep = "_"))
bin_labels <- bin_labels |>
select(c(ID, label))
bin_labels <- bin_labels |>
distinct(.keep_all=TRUE)
labels <- bin_labels |>
pull(label,ID)
# I only select the columns from the survey data that I need
bin_select <- bin_raw |>
select ('bedrijfsnummer', 'ID', 'uitkomst')
bin_clean <- bin_select |>
pivot_wider(id_cols = bedrijfsnummer,names_from = ID, values_from = uitkomst)
# Adding the labels
label(bin_clean) <- as.list(labels[match(names(bin_clean), names(labels))])
---
title: "Spatial Microsimulation and European Agriculture"
author: "Ninke Feenstra"
date: "`r Sys.Date()`"
output:bookdown::pdf_document2:
citation_package: biblatex
bibliography: C:/MyData/mendeley/microsim.bib
---
```{r}
```
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Introduction
Under the CAP 2023-27 the European Commission has set 10 objectives for European Agriculture including: ensuring a fair income for farmers, supporting generational renewal and climate change action [@EC2021]. In order to meet these objectives, new policies must be developed. @Kremmydas2021 explain that the impact of agricultural policies is increasingly depending on farm characteristics as certain measures such as the young farmers scheme and greening payments are conditioned by certain farm characteristics. As existing macro level models such as CAPRI, AGMEMOD and MAGNET are not able to capture farm heterogeneity, they are unsuitable to analyse the effects of these new policies on farm level [@Ciaian2013]. Instead, micro-level models that take the heterogeneity of farms into account should be used.
The first farm level models were developed in the 1920’s and were mostly case studies of successful farms [@Klein1992]. Since then, the field of farm level modelling has developed further and dozens of models have been developed in the past years. While the majority of these models takes farm heterogeneity into account, only a quarter of these models are able to estimate the spatially diverse effect of policies [@Reidsma2018]. Farm level models that are able to estimate regional effects mostly do this by modelling policies onto a representative farm for each region [@Uthes2010]. While this approach is able to estimate spatial effects of policies, it does not take the full heterogeneity of the farm population into account.
One method that is able to capture both farm heterogeneity as well as spatial heterogeneity when estimating policies effects is spatial microsimulation. Spatial microsimulation is a technique where micro units such as households or farms are reweighed in order to create a synthetic group of micro units that is representative for a certain region. Depending on how the model is model is build up, it can be used for the following goals:
- Estimating both inter- and intra-regional variation
- Creating projections of future inter- and intra-regional variation
- Estimating the impact of policies on small areas [@Tanton2013].
The broader field of microsimulation has developed separately from the field of farm level modelling so the technique has only sparsely been applied to the agricultural sector [@Richardson2014]. Still the technique can provide useful insights for the agricultural sector as the sector depends on the environment and the weather which has resulted in a strong spatial heterogeneity.
The aim of this paper is to provide insights about the potential uses of spatial microsimulation in agricultural context. To achieve this I will first give an overview of the methods used for spatial microsimulation in section 2. Section 3 will give an overview of previous papers that apply spatial microsimulation, while section 4 concludes and gives recommendations for further research.
## Spatial Microsimulation
Throughout the years different methods have been developed to create spatial microsimulation models. These methods can first of all be divided into synthetic reconstruction and reweighting methods. Synthetic reconstruction methods aim to estimate and impute characteristics of individual units with a known geographic location, while reweighting methods create new weights for units without a known geographic location so that they are representative for a given region. Nowadays reweighting methods are seen as superior methods over synthetic reconstruction and as a result most spatial microsimulation models are developed using reweighting approaches [@Tanton2013]. As most models are nowadays being developed with reweighting techniques, I will only focus on these methods in this section.
### Iterative Proportional Fitting
Deterministic iterative proportional fitting (IPF) is one of the techniques that can be used to reweight micro units. This technique should not be confused with the probabilistic iterative proportional fitting that is used for synthetic reconstruction. The main equation behind IPF is:
$$ Nw_f=w_{if}*c_{hj}/s_{hj}$$
Here $Nw_f$ is the new weight for farm $f$ while $w_{if}$ is the original weight of farm f.
\ No newline at end of file
This diff is collapsed.
! warning: kpathsea: configuration file texmf.cnf not found in these directories: C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf/web2c;C:/Users/feens028/AppData/Roaming/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf/web2c.
! warning: kpathsea: configuration file texmf.cnf not found in these directories: C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf/web2c;C:/Users/feens028/AppData/Roaming/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf/web2c.
! warning: kpathsea: configuration file texmf.cnf not found in these directories: C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/win32/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/bin/texmf/web2c;C:/Users/feens028/AppData/Roaming/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/share/texmf/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf-local/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf-dist/web2c;C:/Users/feens028/AppData/Roaming/TinyTeX/texmf/web2c.
! ...feens028\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...feens028\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\feens028\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\feens028\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage[margin=1in]{geometry}
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={survey\_paper},
pdfauthor={Ninke Feenstra},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\title{survey\_paper}
\author{Ninke Feenstra}
\date{2023-03-10}
\begin{document}
\maketitle
\hypertarget{r-markdown}{%
\subsection{R Markdown}\label{r-markdown}}
This is an R Markdown document. Markdown is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents. For more details on
using R Markdown see \url{http://rmarkdown.rstudio.com}.
When you click the \textbf{Knit} button a document will be generated
that includes both content as well as the output of any embedded R code
chunks within the document. You can embed an R code chunk like this:
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{summary}\NormalTok{(cars)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
\end{verbatim}
\hypertarget{including-plots}{%
\subsection{Including Plots}\label{including-plots}}
You can also embed plots, for example:
\includegraphics{survey_paper_files/figure-latex/pressure-1.pdf}
Note that the \texttt{echo\ =\ FALSE} parameter was added to the code
chunk to prevent printing of the R code that generated the plot.
\end{document}
---
title: "Is_this_working"
output: html_document
date: "2023-01-30"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment