Learn R Programming

tipsae (version 1.0.3)

export: Exporting Results of a Small Area Model Fitting

Description

The function export() allows for exporting model estimates in CSV format.

Usage

export(x, file, type = "all", ...)

Value

A CSV file is created in the working directory, or at the given path, exporting the estimates_fitsae object given as input.

Arguments

x

An object of class estimates_fitsae.

file

A character string indicating the path (if different from the working directory) and filename of the CSV to be created. It should end with .csv.

type

An option between "in", "out" and "all", indicating whether to export only in or out-of-sample areas or both.

...

Additional arguments of write.csv function from utils package can be indicated.

See Also

extract to produce the input object and write.csv.

Examples

Run this code
if (FALSE) {
library(tipsae)

# loading toy dataset
data("emilia_cs")

# fitting a model
fit_beta <- fit_sae(formula_fixed = hcr ~ x, data = emilia_cs, domains = "id",
                    type_disp = "var", disp_direct = "vars", domain_size = "n",
                    # MCMC setting to obtain a fast example. Remove next line for reliable results.
                    chains = 1, iter = 150, seed = 0)

# check model diagnostics
summ_beta <- summary(fit_beta)

# extract model estimates
HB_estimates <- extract(summ_beta)

# export model estimates
export(HB_estimates, file = "results.csv", type = "all")
}


Run the code above in your browser using DataLab