Title: AGricultural PRoductivity in Space
Version: 2.0
Description: Functionalities to simulate space-time data and to estimate dynamic-spatial panel data models. Estimators implemented are the BCML (Elhorst (2010), <doi:10.1016/j.regsciurbeco.2010.03.003>), the MML (Elhorst (2010) <doi:10.1016/j.regsciurbeco.2010.03.003>) and the INLA Bayesian estimator (Lindgren and Rue, (2015) <doi:10.18637/jss.v063.i19>; Bivand, Gomez-Rubio and Rue, (2015) <doi:10.18637/jss.v063.i20>) adapted to panel data. The package contains functions to replicate the analyses of the scientific article entitled "Agricultural Productivity in Space" (Baldoni and Esposti (2021), <doi:10.1111/ajae.12155>)).
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Depends: R (≥ 2.10)
Imports: methods, Matrix, plyr, sp, spdep, spacetime, matrixcalc, maxLik
Suggests: INLA, terra
NeedsCompilation: no
Packaged: 2023-06-08 06:36:56 UTC; edoar
Author: Edoardo Baldoni ORCID iD [aut, cre]
Maintainer: Edoardo Baldoni <edoardo.baldoni@gmail.com>
Repository: CRAN
Date/Publication: 2023-06-08 07:32:54 UTC

BCML estimator

Description

This function estimates a space time linear model according to the specified formula. It implements the BCML (or BCLSDV) estimator as in Elhorst (2010) doi:10.1016/j.regsciurbeco.2010.03.003.

Usage

bcml(
  dataset,
  yearStart,
  yearEnd,
  var.agg = "Cod_Provincia",
  eq,
  spatial = NULL,
  estimation = "analytical",
  corrBIAS = TRUE,
  WMAT = NULL
)

Arguments

dataset

STFDF with the data

yearStart

First year considered in the estimation

yearEnd

Last Anno considered in the estimation

var.agg

Index of the spatial units

eq

Formula to be estimated. It excludes the spatial lag

spatial

Radius to define neighbors

estimation

Either 'analytical' or 'numerical'. If 'analytical' is specified the concentrated maximum likelihood is estimated and then the other parameters are obtained analytically. Otherwise, all parameters are obtained through numerical maximization of the log-likelihood function.

corrBIAS

Boolean. If TRUE, the bias correction is applied.

WMAT

The spatial weight matrix

Value

A list with two objects. The first object is the estimates table. The second object is the log-likelihood evaluated at its maximum

Examples


library(maxLik)
library(matrixcalc)

set.seed(123)
sd = sim_data_fe(dataset=regsamp,N=100,TT=8,
                 spatial = 80,Tau = -0.2,Rho = 0.4,
                 Beta = 2,sdDev = 2,startingT = 10,
                 LONGLAT = TRUE)
est_bcml = bcml(dataset = sd[[1]],yearStart = 3,yearEnd = 9,
                var.agg = 'Cod_Provincia',eq = Y~X1,
                  estimation = 'analytical',corrBIAS = TRUE,WMAT = sd[[2]])
est_bcml



Matrix of technological distance

Description

A matrix of agricultural technological distance of NUTS3. It is used to weight the geographical distance of NUTS3 regions.

Usage

distOte

Format

A 106x106 matrix


Space-time bayesian INLA estimator

Description

This function estimates a space time linear model using the bayesian INLA. It is a wrapper of the INLA::inla function (Lindgren and Rue (2015) doi:10.18637/jss.v063.i19; Bivand, Gomez-Rubio and Rue (2015) doi:10.18637/jss.v063.i20) adapted to panel data.

Usage

inla.st(
  formula,
  d,
  W,
  RHO,
  PHI,
  var.agg,
  normalization = FALSE,
  improve = TRUE,
  fhyper = NULL,
  probit = FALSE,
  ...
)

Arguments

formula

Formula of the model to be estimated

d

Data frame

W

Spatial matrix

RHO

Parameter of spatial dependence

PHI

Parameter of temporal dependence

var.agg

Indexes of the panel dimensions. The first argument is the spatial dimension, the second argument is the temporal dimension.

normalization

Boolean. If TRUE the data are normalized before estimation

improve

Please refer to the documentation of the INLA package

fhyper

Plase refer to the documentation of the INLA package

probit

Plase refer to the documentation of the INLA package

...

additional parameters. Please, refer to the documentation of the INLA package

Value

Returns a model of class "inla". Please, refer to the documentation of the INLA package for additional information

Examples


library(terra)
set.seed(123)
sd = sim_data_fe(dataset=regsamp,N=100,TT=8,spatial = 80,
                 Tau = -0.2,Rho = 0.4, Beta = 2,sdDev = 2,
                 startingT = 10,LONGLAT = TRUE)
est_inla = inla.st(formula = Y~-1+X1,d = sd[[1]]@data,
               W = sd[[2]],PHI=-0.2,RHO=0.4,
               var.agg=c('Cod_Provincia','Anno'),
               family='gaussian',
               improve=TRUE,
               normalization=FALSE,
               control.family = list(hyper = list(prec=list(initial=25,fixed=TRUE))),
               control.predictor = list(compute = TRUE),
               control.compute = list(dic = TRUE, cpo = TRUE),
               control.inla = list(print.joint.hyper = TRUE))
summary(est_inla)



Cropland grid of Northen Italy (20km x 20km squares)

Description

SpatialPolygonsDataFrame object with croplands of Northern Italy approximated with 20km x 20km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

map1

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Cropland grid of Northen Italy (40km x 40km squares)

Description

SpatialPolygonsDataFrame object with croplands of Northern Italy approximated with 40km x 40km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

map2

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Cropland grid of Northen Italy (60km x 60km squares)

Description

SpatialPolygonsDataFrame object with croplands of Northern Italy approximated with 60km x 60km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

map3

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Cropland grid of Northen Italy (100km x 100km squares)

Description

SpatialPolygonsDataFrame object with croplands of Northern Italy approximated with 100km x 100km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

map4

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


MML estimator

Description

This function estimates a space time linear model according to the specified formula using the ML estimator as in Elhorst (2010) doi:10.1016/j.regsciurbeco.2010.03.003. The estimator maximizes the full log-likelihood function in which the parameter of spatial dependence is constrained.

Usage

mml(Rho, ff, dataset, wmat, var.agg, m = 10)

Arguments

Rho

the constrained parameter of spatial dependence

ff

Formula of the linear model. It excludes the spatial lag

dataset

Data frame with the data

wmat

Spatial weight matrix

var.agg

Spatial index of the data frame

m

How many time periods have passed since the beginning of the space-time process

Value

The estimates tables

Examples



set.seed(123)
sd = sim_data_fe(dataset=regsamp,N=50,TT=6,
                spatial = 80,Tau = -0.2,Rho = 0.4,
                Beta = 2,sdDev = 2,startingT = 10,
                LONGLAT = TRUE);sd[[1]]$X2 = stats::rnorm(nrow(sd[[1]]@data))
est_mml = mml(dataset = sd[[1]]@data,Rho = 0.4,
              ff = Y~X1+X2,
              wmat = sd[[2]],var.agg = c('Anno','Cod_Provincia'),
              m = 10)
est_mml



Cropland grid of Italy (100km x 100km squares)

Description

SpatialPolygonsDataFrame object with croplands of Italy approximated with 100km x 100km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

r100km

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Cropland grid of Italy (20km x 20km squares)

Description

SpatialPolygonsDataFrame object with croplands of Italy approximated with 20km x 20km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

r20km

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Cropland grid of Italy (40km x 40km squares)

Description

SpatialPolygonsDataFrame object with croplands of Italy approximated with 40km x 40km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

r40km

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Cropland grid of Italy (60km x 60km squares)

Description

SpatialPolygonsDataFrame object with croplands of Italy approximated with 60km x 60km squared polygons. It is based on croplands data contained in the Corine Land Cover 2012 raster map.

Usage

r60km

Format

SpatialPolygonsDataFrame object

Source

https://land.copernicus.eu/pan-european/corine-land-cover/clc-2012


Coordinates of simulated farms in Northern Italy

Description

SpatialPointsDataFrame object with 1000 SpatialPoints to represent simulated farms in the simulation exercise

Usage

regsamp

Format

SpatialPointsDataFrame object


Merged NUTS3 for simulation exercise

Description

SpatialPolygons object with merged NUTS3 regions of Northern Italy used in the simulation exercise

Usage

sel_regioni

Format

SpatialPolygons object

Source

ISTAT


Simulate space-time stochastic process with fixed-effect

Description

This function simulates a space-time stochastic process according to the defined spatial structure and input paramters. It simulates data of a dynamic spatial lag model. It includes one exogenous variable and a fixed-effect correlated with the exogenous variable.

Usage

sim_data_fe(
  dataset,
  N,
  TT,
  spatial = 100,
  Tau = -0.14,
  Rho = 0.67,
  Beta = 1,
  sdDev = 5,
  startingT = 11,
  LONGLAT = TRUE
)

Arguments

dataset

SpatialObject with the spatial units for which the data will be simulated

N

How many spatial units will be used

TT

Time dimension of the simulated process

spatial

Radius that defines the scope of spatial dependence

Tau

Autocorrelation parameter

Rho

Spatial dependence parameter

Beta

Coefficient associated to the exogenous variable

sdDev

Standard Deviation of the (gaussian) error term

startingT

The number of time periods after which the simulated data will be recorded

LONGLAT

Boolean. If the projection is longlat

Value

A list with two objects. The first object is the STFDF with the simulated data. The second object is the spatial weight matrix

Examples


library(spacetime)
library(sp)
library(spdep)


set.seed(123)
sd = sim_data_fe(dataset=regsamp,N=100,TT=8,
                 spatial = 80,Tau = -0.2,Rho = 0.4,
                 Beta = 2,sdDev = 2,startingT = 10,
                 LONGLAT = TRUE)
stplot(sd[[1]][,,'Y'])
dev.new()
plot(sel_regioni)
points(coordinates(sd[[1]]@sp))
plot(mat2listw(sd[[2]]),coordinates(sd[[1]]@sp),add=TRUE,col=2)



Neighbors of NUTS3 of Sardinia

Description

A table containing the link of NUTS3 in Sardinia with NUTS3 of mainland Italy

Usage

tabSard

Format

A data frame with the links