Coef
Coefficient vector. Coefficients are used to represent the parameters of equations and systems.
Coef Declaration
coef declare coefficient vector.
There are two ways to create a coef. First, enter the coef keyword, followed by a name to be given to the coefficient vector. The dimension of the coef may be provided in parentheses after the keyword:
coef alpha
coef(10) beta
If no dimension is provided, the resulting coef will contain a single element.
You may also combine a declaration with an assignment statement. If you do not provide an explicit assignment statement, a new coef vector will be initialized to zero.
See also
param for information on initializing coefficients, and the entries for each of the estimation objects (
Equation,
Logl,
Pool,
Sspace,
System, and
Var) for additional methods of accessing coefficients.
Coef Views
display display table, graph, or spool in object window.
sheet spreadsheet view of the coefficient.
stats descriptive statistics.
Coef Procs
clearhist clear the contents of the history attribute.
copy creates a copy of the coef.
export save as Excel 2007 XLSX, CSV, tab-delimited ASCII text, RTF, HTML, Enhanced Metafile, PDF, TEX, or MD file on disk.
fill fill the elements of the coefficient vector.
import imports data from a foreign file into the object.
olepush push updates to OLE linked objects in open applications.
read import data into coefficient vector.
resize resize the coef object.
setattr set the value of an object attribute.
setformat set the display format for the coefficient vector spreadsheet.
setindent set the indentation for the coefficient spreadsheet.
setjust set the horizontal justification for all cells in the spreadsheet view of the coef object.
setwidth set the column width for the coefficient spreadsheet.
showlabels displays the custom row and column labels of a coef spreadsheet.
write export data from coefficient vector.
Coef Graph Views
Graph creation views are discussed in detail in
“Graph Creation Command Summary”.
qqplot quantile-quantile graph.
Coef Data Members
@attr("arg") string containing the value of the arg attribute, where the argument is specified as a quoted string.
@collabels string containing the column label of the coef.
@description string containing the Coef object’s description (if available).
@detailedtype string describing the object type: “COEF”.
@displayname string containing the Coef object’s display name. If the Coef has no display name set, the name is returned.
@droprow(arg) Returns the Coef with the rows defined by arg removed. arg may be an integer, vector of integers, string, or svector of strings. Integer values correspond to rows and string values correspond to previously defined row labels.
@name string containing the Coef object’s name.
@remarks string containing the Coef object’s remarks (if available).
@row(arg) Returns the rows defined by arg. arg may be an integer, vector of integers, string, or svector of strings. Integer values correspond to rows and string values correspond to previously defined row labels.
@rowlabels string containing the row labels of the coef.
@rows number of rows in the coef.
@type string describing the object type: “COEF”.
@updatetime string representation of the time and date at which the Coef was last updated.
(i) i-th element of the coefficient vector. Simply append “(i)” to the coef name (without a “.”).
Coef Examples
The coefficient vector declaration:
coef(10) coef1=3
creates a 10 element coefficient vector COEF1, and initializes all values to 3.
Suppose
MAT1 is a

matrix, and
VEC1 is a 20 element vector. Then:
coef mycoef1=coef1
coef mycoef2=mat1
coef mycoef3=vec1
create, size, and initialize the coefficient vectors MYCOEF1, MYCOEF2 and MYCOEF3.
Coefficient elements may be referred to by an explicit index. For example:
vector(10) mm=beta(10)
scalar shape=beta(7)
fills the vector MM with the value of the tenth element of BETA, and assigns the seventh value of BETA to the scalar SHAPE.
Clear the column label in a coef object.
Syntax
coef_name.clearcollabels
Examples
c1.clearcollabels
clears the custom column label from the coef C1.
Cross-references
Clear the contents of the history attribute.
Removes the coef’s history attribute, as shown in the label view of the coef.
Syntax
coef_name.clearhist
Examples
c1.clearhist
c1.label
The first line removes the history from the coef C1, and the second line displays the label view of C1, including the now blank history field.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Clear the contents of the remarks attribute.
Removes the coef’s remarks attribute, as shown in the label view of the coef.
Syntax
coef_name.clearremarks
Examples
c1.clearremarks
c1.label
The first line removes the remarks from the coef C1, and the second line displays the label view of C1, including the now blank remarks field.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Clear the row labels in a coef object.
Syntax
coef_name.clearrowlabels
Examples
c1.clearrowlabels
clears the custom row labels from the coef C1.
Cross-references
Declare a coefficient (column) vector.
Syntax
coef(n) coef_name
Follow the coef keyword with the number of coefficients in parentheses, and a name for the object. If you omit the number of coefficients, EViews will create a vector of length 1.
Examples
coef(2) slope
ls lwage = c(1)+slope(1)*edu+slope(2)*edu^2
The first line declares a coef object of length 2 named SLOPE. The second line estimates a least squares regression and stores the estimated slope coefficients in SLOPE.
arch(2,2) sp500 c
coef beta = c
coef(6) beta
The first line estimates a GARCH(2,2) model using the default coef vector C (note that the “C” in an equation specification refers to the constant term, a series of ones.) The second line declares a coef object named BETA and copies the contents of C to BETA (the “C” in the assignment statement refers to the default coef vector). The third line resizes BETA to “chop off” all elements except the first six. Note that since EViews stores coefficients with equations for later use, you will generally not need to perform this operation to save your coefficient vectors.
Cross-references
Creates a copy of the coef.
Creates either a named or unnamed copy of the coef.
Syntax
coef_name.copy
coef_name.copy dest_name
Examples
c1.copy
creates an unnamed copy of the coef C1.
c1.copy c2
creates C2, a copy of the coef C1.
Cross-references
Display table, graph, or spool output in the coef object window.
Display the contents of a table, graph, or spool in the window of the coef object.
Syntax
coef_name.display object_name
Examples
coef1.display tab1
Display the contents of the table TAB1 in the window of the object COEF1.
Cross-references
Most often used in constructing an EViews Add-in. See
“Custom Object Output”.
Display name for a coefficient vector.
Attaches a display name to a coef object which may be used to label output in tables and graphs in place of the standard coef object name.
Syntax
coef_name.displayname display_name
Display names are case-sensitive, and may contain a variety of characters, such as spaces, that are not allowed in coef object names.
Examples
c1.displayname Hours Worked
c1.label
The first line attaches a display name “Hours Worked” to the coef object C1, and the second line displays the label view of C1, including its display name.
c1.displayname Means by State
plot c1
The first line attaches a display name “Means by State” to the coef C1. The line graph view of C1 will use the display name as the legend.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names. See also
Coef::label.
Export coef vector to disk as an Excel 2007 XLSX, CSV, tab-delimited ASCII text, RTF, HTML, Enhanced Metafile, LaTeX, PDF, or Markdown file.
Syntax
coef_name.export(options) [path\]file_name
Follow the keyword with a name for the file. file_name may include the file type extension, or the file type may be specified using the “t=” option.
If an explicit path is not specified, the file will be stored in the default directory set in the global options.
The base syntax for writing Excel 2007 files is:
coef_name.export(options) [path\]file_name [table_description]
where table_description contains:
• “range = arg”, where arg is top left cell of the destination Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name defined inside the Excel workbook to refer to a range or cell may specify the cells to read.
Options
t=file_type (default=“csv”) | Specifies the file type, where file_type may be: “excelxml” (Excel 2007 (xml)),“csv” (CSV - comma-separated), “rtf” (Rich-text format), “txt” (tab-delimited text), “html” (HTML - Hypertext Markup Language), “emf” (Enhanced Metafile), “pdf” (PDF - Portable Document Format), “tex” (LaTeX), or “md” (Markdown). Files will be saved with the “.xlsx”, “.csv”, “.rtf”, “.txt”, “.htm”, “.emf”, “.pdf”, “.tex”, or “.md” extensions, respectively. |
s=arg | Scale size, where arg is from 5 to 200, representing the percentage of the original table size (only valid for HTML or RTF files). |
n=string | Replace all cells that contain NA values with the specified string. “NA” is the default. |
h / -h | Include(/do not include) column and row headers. The default is to not include the headers |
prompt | Force the dialog to appear from within a program. |
PDF Options
landscape | Save in landscape mode (the default is to save in portrait mode). |
size=arg (default=“letter”) | Page size: “letter”, “legal”, “a4”, and “custom”. |
width=number (default=8.5) | Page width in inches if “size=custom”. |
height=number (default=11) | Page height in inches if “size=custom”. |
leftmargin=number (default=0.5) | Left margin width in inches. |
rightmargin=number (default = 0.5) | Right margin width in inches. |
topmargin=number (default=1) | Top margin width in inches. |
bottommargin= number (default = 1) | Bottom margin width in inches. |
LaTeX Options
texspec / -texspec | [Include / Do not include] the full LaTeX documentation specification in the LaTeX output. The default behavior is taken from the global default settings. |
Excel Options
mode=arg | Specify whether to create a new file, overwrite an existing file, or update an existing file. arg may be “create” (create new file only; error on attempt to overwrite) or “update” (update an existing file, only overwriting the area specified by the range= table_description). If the “mode=” option is not used, EViews will create a new file, unless the file already exists in which case it will overwrite it. Note that the “mode=update” option is only available for Excel in 1) Excel versions through 2003, if Excel is installed, and 2) Excel 2007 (xml). Note: Excel does not need to be installed for Excel 2007 writing. |
Excel 2007 Options
mode=arg | Specify whether to create a new file, overwrite an existing file, or update an existing file. arg may be “create” (create new file only; error on attempt to overwrite) or “update” (update an existing file, only overwriting the area specified by the range= table_description). If the “mode=” option is not used, EViews will create a new file, unless the file already exists in which case it will overwrite it. Note that the “mode=update” option is only available for Excel in 1) Excel versions through 2003, if Excel is installed, and 2) Excel 2007 (xml). Note: Excel does not need to be installed for Excel 2007 writing. |
cellfmt=arg | Specify whether to use EViews, pre-existing, or remove cell formatting (colors, font, number formatting when possible, column widths and row heights) for the written range. arg may be “eviews” (replace current formatting in the file with the same cell formatting in EViews), “preserve” (leave current cell formatting already in the Excel file), or “clear” (remove current formatting and do not replace). |
strlen=arg (default = 256) | Specify the maximum the number of characters written for cells containing text. Strings in cells which are longer the max, will be truncated. |
Examples
The command:
coef1.export myvector
exports data in COEF1 to a CSV file named “myvector.CSV” in the default directory.
coef1.export(h,t=csv, n="NaN") myvector
saves the contents of COEF1 along with the column and row headers to a CSV file named “myvector.CSV” and writes all NA values as “NaN”.
coef1.export(h,t=html, s=50) myvector
writes the data of COEF1 along with the column and row headers to a HTML file named “myvector.HTM” at half of the original size.
coef1.export(n=".", r=B) myvector
exports the data in the second column to a CSV file named “myvector.CSV”, and writes all NA values as “.”.
coef1.export(t=excelxml, cellfmt=clear, mode=update) myvector range=Country!b5
writes the data in COEF1 to the “Country” sheet at cell B5 in the preexisting “myvector.XLSX” Excel file. All cell formatting is cleared.
Cross-references
Fill a coef object with specified values.
Syntax
coef_name.fill(options) n1[, n2, n3 …]
Follow the keyword with a list of values to place in the specified object. Each value should be separated by a comma.
Running out of values before the coef vector is completely filled is not an error; the remaining cells or observations will not be modified unless the “l” option is specified. However, if you list more values than the coef vector can hold, EViews will not modify any observations and will return an error message.
Options
l | Loop repeatedly over the list of values as many times as it takes to fill the coef vector. |
o=integer (default=1) | Fill the coef vector from the specified element. Default is the first element. |
Examples
The following example declares a four element coefficient vector MC, initially filled with zeros. The second line fills MC with the specified values and the third line replaces from row 3 to the last row with –1.
coef(4) mc
mc.fill 0.1, 0.2, 0.5, 0.5
mc.fill(o=3,l) -1
Note that the last argument in the fill command above is the letter “l”.
Cross-references
See
“Fill assignment” for further discussion of the fill procedure.
Imports data from a foreign file into the coef object.
Syntax
coef_name.import([type=]) source_description import_specification
• source_description should contain a description of the file from which the data is to be imported. The specification of the description is usually just the path and file name of the file, however you can also specify more precise information. See
wfopen for more details on the specification of
source_description.
• The optional “type=” option may be used to specify a source type. For the most part, you should not need to specify a “type=” option as EViews will automatically determine the type from the filename. The following table summaries the various source formats and along with the corresponding “type=” keywords:
| |
Excel (through 2003) | “excel” |
Excel 2007 (xml) | “excelxml” |
HTML | “html” |
Text / ASCII | “text” |
• import_specification can be used to provide additional information about the file to be read. The details of import_specification will depend upon the type of file being imported.
Excel Files
The syntax for reading Excel files is:
coef_name.import(type=excel[xml]) source_description [table_description] [variables_description]
The following table_description elements may be used when reading Excel data:
• “range = arg”, where arg is a range of cells to read from the Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name which has been defined inside the excel workbook to refer to a range or cell may be used to specify the cells to read.
• “byrow”, transpose the incoming data. This option allows you to read files where the series are contained in rows (one row per series) rather than columns.
The optional variables_description may be formed using the elements:
• “colhead=int”, number of table rows to be treated as column headers.
• “na="arg1"”, text used to represent observations that are missing from the file. The text should be enclosed on double quotes.
• “scan=[int| all]”, number of rows of the table to scan during automatic format detection (“scan=all” scans the entire file).
• “firstobs=int”, first observation to be imported from the data (default is 1). This option may be used to start reading rows from partway through the table.
• “lastobs = int”, last observation to be read from the data (default is last observation of the file). This option may be used to read only part of the file, which may be useful for testing.
Excel Examples
coef_obj.import "c:\data files\data.xls"
loads the active sheet of “data.XLSX” into the VEC_NAME vector object.
coef_obj.import "c:\data files\data.xls" range="GDP data"
reads the data contained in the “GDP data” sheet of “data.XLS” into the COEF_OBJ object.
HTML Files
The syntax for reading HTML pages is:
coef_name.import(type=html) source_description [table_description] [variables_description]
The following table_description elements may be used when reading an HTML file or page:
• “table = arg”, where arg specifies which HTML table to read in an HTML file/page containing multiple tables.
When specifying arg, you should remember that tables are named automatically following the pattern “Table01”, “Table02”, “Table03”, etc. If no table name is specified, the largest table found in the file will be chosen by default. Note that the table numbering may include trivial tables that are part of the HTML content of the file, but would not normally be considered as data tables by a person viewing the page.
• “skip = int”, where int is the number of rows to discard from the top of the HTML table.
• “byrow”, transpose the incoming data. This option allows you to import files where the series are contained in rows (one row per series) rather than columns.
The optional variables_description may be formed using the elements:
• “colhead=int”, number of table rows to be treated as column headers.
• “na="arg1"”, text used to represent observations that are missing from the file. The text should be enclosed on double quotes.
• “scan=[int|all]”, number of rows of the table to scan during automatic format detection (“scan=all” scans the entire file).
• “firstobs=int”, first observation to be imported from the table of data (default is 1). This option may be used to start reading rows from partway through the table.
• “lastobs = int”, last observation to be read from the table of data (default is last observation of the file). This option may be used to read only part of the file, which may be useful for testing.
HTML Examples
coef_obj.import "c:\data.html"
loads into the COEF_OBJ the data located in the HTML file “Data.HTML” located on the C:\ drive
coef_obj.import(type=html) "http://www.tradingroom.com.au/apps/mkt/forex.ac" colhead=3
loads into a coef object called COEF_OBJ the data with the given URL located on the website site “http://www.tradingroom.com.au”. The column header is set to three rows.
Text and Binary Files
The syntax for reading text or binary files is:
coef_name.import(type=arg) source_description [table_description] [variables_description]
If a table_description is not provided, EViews will attempt to read the file as a free-format text file. The following table_description elements may be used when reading a text or binary file:
• “ftype = [ascii|binary]” specifies whether numbers and dates in the file are stored in a human readable text (ASCII), or machine readable (Binary) form.
• “rectype = [crlf|fixed|streamed]” describes the record structure of the file:
“crlf”, each row in the output table is formed using a fixed number of lines from the file (where lines are separated by carriage return/line feed sequences). This is the default setting.
“fixed”, each row in the output table is formed using a fixed number of characters from the file (specified in “reclen= arg”). This setting is typically used for files that contain no line breaks.
“streamed”, each row in the output table is formed by reading a fixed number of fields, skipping across lines if necessary. This option is typically used for files that contain line breaks, but where the line breaks are not relevant to how rows from the data should be formed.
• “reclines =int”, number of lines to use in forming each row when “rectype=crlf” (default is 1).
• “reclen=int”, number of bytes to use in forming each row when “rectype=fixed”.
• “recfields=int”, number of fields to use in forming each row when “rectype=streamed”.
• “skip=int”, number of lines (if rectype is “crlf”) or bytes (if rectype is not “crlf”) to discard from the top of the file.
• “comment=string“, where string is a double-quoted string, specifies one or more characters to treat as a comment indicator. When a comment indicator is found, everything on the line to the right of where the comment indicator starts is ignored.
• “emptylines=[keep|drop]”, specifies whether empty lines should be ignored (“drop”), or treated as valid lines (“keep”) containing missing values. The default is to ignore empty lines.
• “tabwidth=int”, specifies the number of characters between tab stops when tabs are being replaced by spaces (default=8). Note that tabs are automatically replaced by spaces whenever they are not being treated as a field delimiter.
• “fieldtype=[delim|fixed|streamed|undivided]”, specifies the structure of fields within a record:
“Delim”, fields are separated by one or more delimiter characters
“Fixed”, each field is a fixed number of characters
“Streamed”, fields are read from left to right, with each field starting immediately after the previous field ends.
“Undivided”, read entire record as a single series.
• “quotes=[single|double|both|none]”, specifies the character used for quoting fields, where “single” is the apostrophe, “double” is the double quote character, and “both” means that either single or double quotes are allowed (default is “both”). Characters contained within quotes are never treated as delimiters.
• “singlequote“, same as “quotes = single”.
• “delim=[comma|tab|space|dblspace|white|dblwhite]”, specifies the character(s) to treat as a delimiter. “White” means that either a tab or a space is a valid delimiter. You may also use the abbreviation “d=” in place of “delim=”.
• “custom="arg1"”, specifies custom delimiter characters in the double quoted string. Use the character “t” for tab, “s” for space and “a” for any character.
• “mult=[on|off]”, to treat multiple delimiters as one. Default value is “on” if “delim” is “space”, “dblspace”, “white”, or “dblwhite”, and “off” otherwise.
• “endian = [big|little]”, selects the endianness of numeric fields contained in binary files.
• “string = [nullterm|nullpad|spacepad]”, specifies how strings are stored in binary files. If “nullterm”, strings shorter than the field width are terminated with a single zero character. If “nullpad”, strings shorter than the field width are followed by extra zero characters up to the field width. If “spacepad”, strings shorter than the field width are followed by extra space characters up to the field width.
• “byrow”, transpose the incoming data. This option allows you to import files where the series are contained in rows (one row per series) rather than columns.
• “lastcol”, include implied last column. For lines that end with a delimiter, this option adds an additional column. When importing a CSV file, lines which have the delimiter as the last character (for example: “name, description, date”), EViews normally determines the line to have 3 columns. With the above option, EViews will determine the line to have 4 columns. Note this is not the same as a line containing “name, description, date”. In this case, EViews will always determine the line to have 3 columns regardless if the option is set.
A central component of the table_description element is the format statement. You may specify the data format using the following table descriptors:
• Fortran Format:
fformat=([n1]Type[Width][.Precision], [n2]Type[Width][.Precision], ...)
where Type specifies the underlying data type, and may be one of the following,
I - integer
F - fixed precision
E - scientific
A - alphanumeric
X - skip
and n1, n2, ... are the number of times to read using the descriptor (default=1). More complicated Fortran compatible variations on this format are possible.
• Column Range Format:
rformat="[n1]Type[Width][.Precision], [n2]Type[Width][.Precision], ...)"
where optional type is “$” for string or “#” for number, and n1, n2, n3, n4, etc. are the range of columns containing the data.
• C printf/scanf Format:
cformat="fmt"
where fmt follows standard C language (printf/scanf) format rules.
The optional variables_description may be formed using the elements:
• “colhead=int”, number of table rows to be treated as column headers.
• “na="arg1"”, text used to represent observations that are missing from the file. The text should be enclosed on double quotes.
• “scan=[int|all]”, number of rows of the table to scan during automatic format detection (“scan=all” scans the entire file).
• “firstobs=int”, first observation to be imported from the table of data (default is 1). This option may be used to start reading rows from partway through the table.
• “lastobs = int”, last observation to be read from the table of data (default is last observation of the file). This option may be used to read only part of the file, which may be useful for testing.
Text and Binary File Examples (.txt, .csv, etc.)
coef_obj.import c:\data.csv skip=5
reads “Data.CSV” into a coef_obj, skipping the first 5 rows.
coef_obj.import(type=text) c:\date.txt delim=comma
loads the comma delimited data “Date.TXT” into the COEF_OBJ matrix object.
Cross-references
Display or change the label view of the coefficient vector, including the last modified date and display name (if any).
As a procedure, label changes the fields in the coef object label.
Syntax
coef_name.label
coef_name.label(options) text
Options
To modify the label, you should specify one of the following options along with optional text. If there is no text provided, the specified field will be cleared:
c | Clears all text fields in the label. |
d | Sets the description field to text. |
s | Sets the source field to text. |
u | Sets the units field to text. |
r | Appends text to the remarks field as an additional line. |
p | Print the label view. |
Examples
The following lines replace the remarks field of the coefficient vector C1 with “Results from EQ3”:
c1.label(r)
c1.label(r) Results from EQ3
Cross-references
See
“Labeling Objects” for a discussion of labels.
Push updates to OLE linked objects in open applications.
Syntax
coef_name.olepush
Cross-references
See
“Object Linking and Embedding (OLE)” for a discussion of using OLE with EViews.
Import data from a foreign disk file into a coefficient vector.
May be used to import data into an existing workfile from a text, Excel, or Lotus file on disk.
Syntax
coef_name.read(options) [path\]file_name
You must supply the name of the source file. If you do not include the optional path specification, EViews will look for the file in the default directory. Path specifications may point to local or network drives. If the path specification contains a space, you should enclose the entire expression in double quotation marks.
Options
prompt | Force the dialog to appear from within a program. |
File type options
t=dat, txt | ASCII (plain text) files. |
t=wk1, wk3 | Lotus spreadsheet files. |
t=xls | Excel spreadsheet files. |
If you do not specify the “t” option, EViews uses the file name extension to determine the file type. If you specify the “t” option, the file name extension will not be used to determine the file type.
Options for ASCII text files
na=text | Specify text for NAs. Default is “NA”. |
d=t | Treat tab as delimiter (note: you may specify multiple delimiter options). The default is “d=c” only. |
d=c | Treat comma as delimiter. |
d=s | Treat space as delimiter. |
d=a | Treat alpha numeric characters as delimiter. |
custom = symbol | Specify symbol/character to treat as delimiter. |
mult | Treat multiple delimiters as one. |
rect (default) / norect | [Treat / Do not treat] file layout as rectangular. |
skipcol = integer | Number of columns to skip. Must be used with the “rect” option. |
skiprow = integer | Number of rows to skip. Must be used with the “rect” option. |
comment= symbol | Specify character/symbol to treat as comment sign. Everything to the right of the comment sign is ignored. Must be used with the “rect” option. |
singlequote | Strings are in single quotes, not double quotes. |
dropstrings | Do not treat strings as NA; simply drop them. |
negparen | Treat numbers in parentheses as negative numbers. |
allowcomma | Allow commas in numbers (note that using commas as a delimiter takes precedence over this option). |
Options for spreadsheet (Lotus, Excel) files
letter_number (default=“b2”) | Coordinate of the upper-left cell containing data. |
s=sheet_name | Sheet name for Excel 5–8 Workbooks. |
Examples
c1.read(t=dat,na=.) a:\mydat.raw
reads data into coefficient vector C1 from an ASCII file MYDAT.RAW in the A: drive. The missing value NA is coded as a “.” (dot or period).
c1.read(s=sheet2) "\\network\dr 1\cps91.xls"
reads the Excel file CPS91 into coefficient vector C1 from the network drive specified in the path.
Cross-references
See
“Importing Data” for a discussion and examples of importing data from external files.
For powerful, easy-to-use tools for reading data into a new workfile, see
“Creating a Workfile by Reading from a Foreign Data Source” and
wfopen.
Resize the coef object.
Syntax
coef_name.resize rows
Examples
c1.resize 20
resizes the coef C1 to 20 rows, retaining the contents of any existing elements and initializing new elements to 0.
Set the object attribute.
Syntax
coef_name.setattr(attr) attr_value
Sets the attribute attr to attr_value. Note that quoting the arguments may be required. Once added to an object, the attribute may be extracted using the @attr data member.
Examples
a.setattr(revised) never
String s = a.@attr("revised")
sets the “revised” attribute in the object A to the string “never”, and extracts the attribute into the string object S.
Cross-references
Set the column label in a coef object.
Syntax
coef_name.setcollabels label
Follow the keyword with the column label. Note that the column label should not contain spaces unless it is enclosed in quotes.
Examples
c1.setcollabels beta
sets the column label to “beta”.
Cross-references
Set the display format for cells in coefficient vector spreadsheet views.
Syntax
coef_name.setformat format_arg
where format_arg is a set of arguments used to specify format settings. If necessary, you should enclose the format_arg in double quotes.
For coefficient vectors, setformat operates on all of the cells in the vector.
You should use one of the following format specifications:
g[.precision] | significant digits |
f[.precision] | fixed decimal places |
c[.precision] | fixed characters |
e[.precision] | scientific/float |
p[.precision] | percentage |
r[.precision] | fraction |
To specify a format that groups digits into thousands using a comma separator, place a “t” after the format character. For example, to obtain a fixed number of decimal places with commas used to separate thousands, use “ft[.precision]”.
To use the period character to separate thousands and commas to denote decimal places, use “..” (two periods) when specifying the precision. For example, to obtain a fixed number of characters with a period used to separate thousands, use “ct[..precision]”.
If you wish to display negative numbers surrounded by parentheses (i.e., display the number -37.2 as “(37.2)”), you should enclose the format string in “()” (e.g., “f(.8)”).
Examples
To set the format for all cells in the coefficient vector to fixed 5-digit precision, simply provide the format specification:
c1.setformat f.5
Other format specifications include:
c1.setformat f(.7)
c1.setformat e.5
Cross-references
See
Coef::setwidth,
Coef::setindent, and
Coef::setjust for details on setting spreadsheet widths, indentation and justification.
Set the display indentation for cells in coefficient vector spreadsheet views.
Syntax
coef_name.setindent indent_arg
where indent_arg is an indent value specified in 1/5 of a width unit. The width unit is computed from representative characters in the default font for the current spreadsheet (the EViews spreadsheet default font at the time the spreadsheet was created), and corresponds roughly to a single character. Indentation is only relevant for non-center justified cells.
The default indentation setttings are taken from the Global Defaults for spreadsheet views (
“Spreadsheet Data Display”) at the time the spreadsheet was created.
Examples
To set the justification for a coef object to 2/5 of a width unit:
c1.setindent 2
Cross-references
See
Coef::setwidth and
Coef::setjust for details on setting spreadsheet widths and justification.
Set the horizontal justification for all cells in the spreadsheet view of the coef object.
Syntax
coef_name.setjust format_arg
where format_arg may be set to left, center, right, or auto (strings are left-justified and numbers are right-justified). Default display settings can be set in General Options; see
“Spreadsheet Data Display”.
Examples
c1.setjust left
left-justifies the cells in the spreadsheet view of the coef C1.
Cross-references
See
Coef::setwidth and
Coef::setindent for details on setting spreadsheet widths and indentation.
Set the row labels in a coef object.
Syntax
coef_name.setrowlabels label1 label2 label3...
Follow the keyword with a space delimited list of row labels. Note that each row label should not contain spaces unless it is enclosed in quotes. If you provide fewer labels than there are rows, EViews will keep the corresponding default row names (”R11”, “R12”, etc…).
Examples
c1.setrowlabels USA UK FRANCE
sets the row label for the first row in coef C1 to USA, the second to UK, and the third to FRANCE.
Cross-references
Set the column width in a coefficient object spreadsheet view.
Syntax
coef_name.setwidth width_arg
where width_arg specifies the width unit value. The width unit is computed from representative characters in the default font for the current spreadsheet (the EViews spreadsheet default font at the time the spreadsheet was created), and corresponds roughly to a single character. width_arg values may be non-integer values with resolution up to 1/10 of a width unit.
Examples
c1.setwidth 12
sets the width of the coef to 12 width units.
Cross-references
See
Coef::setindent and
Coef::setjust for details on setting indentation and justification.
Spreadsheet view of a coefficient vector.
Syntax
coef_name.sheet(options)
Options
p | Print the spreadsheet view. |
Examples
c01.sheet
displays the spreadsheet view of C01.
Displays the custom row and column labels of a coef spreadsheet.
Syntax
coef_name.showlabels mode
where mode is either 0 or 1 where 0 displays the default row and column labels and 1 displays the custom row and column labels (if present).
Examples
c1.showlabels 1
displays the custom row and column labels for the C1 spreadsheet. If custom labels have not been set the default labels will be displayed.
c1.showlabels 0
displays the default row and column labels for the C1 spreadsheet.
Cross-references
Descriptive statistics.
Computes and displays a table of means, medians, maximum and minimum values, standard deviations, and other descriptive statistics for the data in the coef object.
Syntax
coef_name.stats(options)
Options
Examples
c1.stats(p)
displays and prints the descriptive statistics view of the coefficient vector C1.
Cross-references
See
“Descriptive Statistics & Tests” and
“Descriptive Statistics” for a discussion of descriptive statistics views.
Write EViews data to a text (ASCII), Excel, or Lotus file on disk.
Creates a foreign format disk file containing data in a coefficient vector object. May be used to export EViews data to another program.
This routine should realistically only be used in the oft-hand chance that you wish to write into a Lotus file. Improved Excel, text, and other format writing is available in
Coef::export.
Syntax
coef_name.write(options) [path\filename]
Follow the name of the coef object by a period, the keyword, and the name for the output file. The optional path name may be on the local machine, or may point to a network drive. If the path name contains spaces, enclose the entire expression in double quotation marks. The entire coef will be exported.
Note that EViews cannot, at present, write into an existing file. The file that you select will, if it exists, be replaced.
Options
prompt | Force the dialog to appear from within a program. |
File type
t=dat, txt | ASCII (plain text) files. |
t=wk1, wk3 | Lotus spreadsheet files. |
t=xls | Excel spreadsheet files. |
If you omit the “t=” option, EViews will determine the type based on the file extension. Unrecognized extensions will be treated as ASCII files. For Lotus and Excel spreadsheet files specified without the “t=” option, EViews will automatically append the appropriate extension if it is not otherwise specified.
ASCII text files
na=string | Specify text string for NAs. Default is “NA”. |
d=arg | Specify delimiter (default is tab): “s” (space), “c” (comma). |
Spreadsheet (Lotus, Excel) files
letter_number | Coordinate of the upper-left cell containing data. |
Examples
c1.write(t=txt,na=.) a:\dat1.csv
writes the coefficient vector C1 into an ASCII file named “Dat1.CSV” on the A: drive. NAs are coded as “.” (dot).
c1.write(t=txt,na=.) dat1.csv
writes the same file in the default directory.
c1.write(t=xls) "\\network\drive a\results"
saves the contents of C1 in an Excel file “Results.xls” in the specified directory.
Cross-references