grmod: Interface for _gretl_ estimation commands

Description Usage Arguments Details Value Author(s) References Examples

Description

The function provides interface for gretl estimation commands using R data frames, or gretl native data files.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
grmod(mdl,data,top = character(0),bottom = character(0),
      input = list(matr = list(),char = character()),
      output=list(matr=character(), char=character(),
                  series = character())) 
      
# With gretl native data file; outputs coeff, vcov, etc
# mod <- grmod("arima 0 1 1; 0 1 1; lg --nc", "bjg.gdt")
# names(mod)

# With AirPassengers from datasets package
# grmod("arima 0 1 1; 0 1 1; log(AirPassengers) --nc",AirPassengers)

Arguments

mdl

quoted gretl estimation command, e.g. "ols y const x", or command block, see also Examples.

data

can be one of two types: (i) an R data.frame, ts, or mts object; (ii) quoted name of gretl data file, or name of a file gretl can open as data file.

top

quoted gretl script: it may contain e.g. code for preliminary data transformations, or unrestricted ols estimation before restrict block.

bottom

quoted gretl script: designed for post-estimation, e.g

"modtest --autocorr".

input

determines additional optional input, for example, the matrix of initial values for optimization (typically of likelihood maximization for arima, mle, nls, etc).

output

determines additional optional components of the output list, e.g. p-value for some diagnostic model test, see Value below and entry for output argument of run_grcli.

Details

In the current version of the package, all gretl estimation commands except for midasreg are processed.

Panel data

If data argument is a gretl data file with panel settings nothing special is needed. Otherwise, the first line of of top argument should be setobs id time_id --panel-vars (use actual names!).

Command blocks

Some of gretl estimation commands use several lines of code, e.g. restrict (with --full option), system, mle, gmm, etc.

restrict: mdl argument should consist of several lines encompassing all restrict block, see Examples below

Other command blocks: mdl argument should contain only the last line of the block (typically the first "word" of the last line is "end", e.g. end mle); all previous lines shold be included into top argument.

Value

a list containing imported output of correspondent gretl command output; if available $model bundle is captured, otherwise available dollar-prefixed accessors are transmitted. Scalars, series, column and row vectors are rendered as R numeric vectors. Matrices of other shapes are rendered as R matrix objects. As always a user can execute run_grcli("help $vcv"), etc.

Author(s)

Oleh Komashko

References

Cottrell, A., and Lucchetti, R. (2018) "Gretl User's Guide," http://ricardo.ecn.wfu.edu/pub//gretl/manual/en/gretl-guide.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set.seed(13)
dfr = data.frame(y = rnorm(20), x = rnorm(20))
grmod("ols y 0 x --simple-print",dfr)
grmod("ols diff(LRY) 0 diff(LRM)","denmark.gdt")


## Not run: 
## command block example
# unrestricted linear regression
tp <- "ols diff(LRY) 0 diff(LRM) IBO -q" 
# restrict block code:
md <- 
"restrict --full
b[2] + b[3] = 0.3
end restrict"
# estimation
mod1 <- grmod(md,"denmark.gdt",top=tp)
names(mod1)

## prelimanary data manipulation example
pr <- 
"list DEMOG = age educ female black married
list INCOME = finc25 finc35 finc50 finc75 finc100 finc101"
# estimate ordered probit
grmod("probit pctstck choice DEMOG INCOME wealth89 prftshr",
      "pension.gdt",top=pr,type="ordered")


## End(Not run)

Rgretl documentation built on May 2, 2019, 3:46 p.m.