Skip to contents

Downscaling of land-use (change) data

Usage

downscale(
  targets,
  start.areas,
  xmat = NULL,
  betas = NULL,
  areas.update.fun = areas.sum_to,
  xmat.coltypes = NULL,
  xmat.proj = NULL,
  xmat.dyn.fun = xmat.sum_to,
  priors = NULL,
  restrictions = NULL,
  options = downscale_control()
)

Arguments

targets

A dataframe with columns times, lu.from (optional), lu.to and value (all targets >= 0)

start.areas

A dataframe of areas with columns lu.from (optional), ns and value, with all areas >= 0 and with sum(areas) >= sum(targets)

xmat

A dataframe of explanatory variables with columns ns, ks and value. Defaults to NULL. Either xmat and betas or priors have to be provided for each combination of lu.from and lu.to in targets.

betas

A dataframe of coefficients with columns ks, lu.from (optional), lu.to & value. Defaults to NULL. Either xmat and betas or priors have to be provided for each combination of lu.from and lu.to in targets.

areas.update.fun

function providing update for dynamic xmat columns, must take as arguments res, curr.areas, priors, xmat.proj, must return dataframe with columns ns, ks & value defaults to areas.sum_to() which sums over lu.to

xmat.coltypes

ks vector, each can be either "static", "dynamic", or "projected"

xmat.proj

dataframe with columns times, ns, ks, must be present for each xmat.coltype specified as projected

xmat.dyn.fun

function providing update for dynamic xmat columns, must take as arguments res, curr.areas, priors, xmat.proj must return ns x ks(dynamic) columns

priors

A dataframe of priors with columns ns, lu.from (optional), lu.to (with priors >= 0); if betas were supplied prior_weights in downscale_control regulate how these are weighted.

restrictions

A dataframe with columns ns, lu.from (optional), lu.to and value. Values must be zero or one. If restrictions are one, the MNL function is set to zero

options

A list with solver options. Call downscale_control for default options and for more detail.

Value

A list containing

  • out.res Dataframe with columns times, ns, lu.from, lu.to & value (area allocation)

  • out.solver A list of the solver output

Details

Given p targets matches either the projections from an MNL-type model or exogenous priors.

Examples

require(dplyr)
#> Loading required package: dplyr
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
require(tidyr)
#> Loading required package: tidyr
require(tibble)
#> Loading required package: tibble
betas = NULL
for (jj in unique(argentina_luc$lu.from)) {
 Y = dplyr::filter(argentina_luc,lu.from == jj & Ts == 2000) %>%
   pivot_wider(names_from = lu.to)
 X = argentina_df$xmat %>% tidyr::pivot_wider(names_from = "ks") %>%
   dplyr::arrange(match(ns,Y$ns))
 Y = Y %>% dplyr::select(-c(lu.from,Ts,ns))
 X = X %>% dplyr::select(-c(ns))
 res1 <- mnlogit(as.matrix(X), as.matrix(Y),baseline = which(colnames(Y) == jj),
          niter = 3,nburn = 2)
 betas = betas %>% dplyr::bind_rows(
  apply(res1$postb, c(1, 2), mean) %>% 
  as.data.frame() %>% tibble::rownames_to_column("ks") %>% 
  pivot_longer(cols = -c(1),names_to = "lu.to") %>% 
  dplyr::mutate(lu.from = jj,.before="lu.to")
 )
}
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
ns = unique(argentina_df$lu_levels$ns)
priors = data.frame(ns = as.character(ns),lu.from="Cropland",lu.to="Forest",value = runif(length(ns)))
res1 = downscale(targets = argentina_FABLE %>% dplyr::filter(times == "2010"),
         start.areas = argentina_df$lu_levels,
         xmat = argentina_df$xmat,
         betas = betas %>% dplyr::filter(lu.from!="Cropland" | lu.to!="Forest"),
         priors = priors)