Command Reference : Function Reference : Function Reference: P
  
Function Reference: P
 
@pagecount
@pageexist
@pagefreq
@pageids
@pageidx
@pageinidx
@pagelist
@pagename
@pagerange
@pagesmpl
@pagesmplidx
@pc
@pca
@pccagr
@pch
@pcha
@pchy
@pctiles
@pcy
@periodtodate
@permute
@pi
@pinverse
@pmax
@pmin
@pmt
@pow
@pow1pm1
@powm1
@prod
@psi
@pv
@pagecount Number of pages in workfile.
@pageexist Does a page exist in the workfile.
@pagefreq Frequency specification for the workfile page.
@pageids Workfile page observation identifiers.
@pageidx Index vector of the specified observations.
@pageinidx Indicators for whether each observation in the workfile page is in an index.
@pagelist List of pages in workfile.
@pagename Name of active workfile page.
@pagerange Range specification of active workfile page.
@pagesmpl Sample specification in active workfile page.
@pagesmplidx Index vector of observations in the current sample.
@pc One-period percentage change (in percent).
@pca One-period percentage change, annualized (in percent).
@pccagr Annualized growth rate (in percent).
@pch One-period percentage change (in decimal fraction).
@pcha One-period percentage change, annualized (in decimal fraction).
@pchy One-year percentage change (in decimal fraction).
@pctiles Percentile values.
@pcy One-year percentage change, (in percent).
@periodtodate Within-period cumulative sum (period-to-date).
@permute Permutation of matrix.
@pi Pi – ratio of a circle's circumference to its diameter ().
@pinverse Moore-Penrose pseudo-inverse of matrix.
@pmax Pairwise maximum.
@pmin Pairwise minimum.
@pmt Payment amount required for annuity to pay given present value.
@pow Power function.
@pow1pm1 Power function of 1 plus argument, minus 1.
@powm1 Power function, minus 1.
@prod Product.
@psi First derivative of the natural log of the gamma function.
@pv Present value of annuity receipts and (optional) final lump sum receipt.
@pagecount
Number of pages in the workfile.
Syntax: @pagecount
Return: integer
Returns the number of pages in the current workfile.
Examples
scalar pgs = @pagecount
Cross-references
See also @pageexist and @pagelist.
@pageexist
Indicator for whether a page exists in the workfile.
Syntax: @pageexist(str)
str: string
Return: integer
Returns a 0 or 1 depending on whether the page specified by str exists in the current workfile.
Examples
The command
scalar pgs = @pageexist("Monthly")
creates a scalar that takes the value 1 if there is a page in the default workfile named “Monthly”.
if (@pageexist("Quarterly") = 1) then
pageselect Quarterly
endif
tests for whether the page “Quarterly” exists in the workfile, and if it does, makes it the active page.
Cross-references
See also @pagecount and @pagelist.
@pagefreq
Frequency of the current workfile page.
Syntax: @pagefreq
Return: string
Returns a string containing the frequency of the active page:
“Sec”, “5Sec”, “15Sec”, “30Sec”
Seconds in intervals of: 1, 5, 15, or 30 seconds, respectively, with optionally specified days of the week and start and end times during the day appended in parentheses.
“Min”, “2Min”, “5Min”, “10Min”, “15Min”, “20Min”, “30Min”
Minutes in intervals of: 1, 2, 5, 10, 15, 20, or 30 minutes, respectively, with optionally specified days of the week and start and end times during the day appended in parentheses.
“H”, “2H”, “4H”, “6H”, “8H”, “12H”
Hours in intervals of: 1, 2, 4, 6, 8, or 12 hours, respectively.with optionally specified days of the week and start and end times during the day appended in parentheses.
“D(s, e)”
Daily with arbitrary days of the week. Specify the first and last days of the week with integers s and e, where Monday is given the number 1 and Sunday is given the number 7.
“D5”
Daily with five days per week, Monday through Friday.
“D7”
Daily with seven days per week.
“W”
Weekly
“T”
Ten-day (daily in intervals of ten).
“F”
Fortnight
“BM”
Bimonthly
“M”
Monthly
“Q”
Quarterly
“S”
Semi-annual
“A”
Annual
“2Y”, “3Y”, “4Y”, “5Y”, “6Y”, “7Y”, “8Y”, “9Y”, “10Y”, “20Y”
Multi-year in intervals of: 2, 3, 4, 5, 6, 7, 8, 9, 10, or 20 years, respectively.
Examples
The command
string frq = @pagefreq
saves the frequency string in the string object FRQ.
The program commands
%frq = @pagefreq
pagecreate(page="newpage") {%frq} 2015 2023
extracts a string with the frequency of the active workfile page, then uses the frequency information to create a new page named “Newpage” with observations from 2015 to 2023 using the same frequency.
Cross-references
See also @pageids, wfcreate, and pagecreate.
@pageids
Workfile page observation identifier series.
Syntax: @pageids
Return: string
Returns a string containing a space delimited list of the observation identifier series for the current workfile page.
Examples
workfile a 2010 2023
string id = @pageids
extracts the identifier string from the workfile. As with other standard structured workfiles of this type, ID contains "@DATE".
For a dated panel workfile with date identifier YEAR, and cross section identifier series COUNTRY,
string ids = @pageids
returns the string variable IDS containing “YEAR COUNTRY”.
Cross-references
See also @pagefreq, wfcreate, and pagecreate.
@pageidx
Index vector of specific observations.
Syntax: @pageidx(x)
x: vector, svector, string
Return: vector
Returns a vector containing the index values in the current workfile page of the observations specified in x.
If x is a vector, the elements of x should be date numbers.
If x is a svector, the elements of x should be string representations of dates.
If x is a string, it should contain a space delimited list of dates.
Any specified observations that are not in the current page will be ignored.
This function is only available in regular frequency, non-panel workfiles.
Examples
wfcreate(wf=qwf) q 2001 2024
vstring vdates = "2010q2 2010q3 2021q1 2023q4"
svector sdates = @wsplit(vdates)
creates a workfile containing quarterly data from 2001 to 2024, creates a string object containing four specific dates, and creates the corresponding svector with those string values.
Then the commands
vector id1 = @pageidx("2010q2 2010q3 2021q1 2023q4")
vector id2 = @pageidx(vdates)
vector id3 = @pageidx(sdates)
all create four element vectors containing the values {38, 39, 81, 92}.
vector(4) ndates
for !i = 1 to 4
ndates(!i) = @dateval(sdates(!i))
next
vector id4 = @pageidx(ndates)
uses a vector with date numbers to return the same vector.
Cross-references
See “Dates”.
See also @pageinidx, @pagesmplidx, @dateval, and @wsplit.
@pageinidx
Indicators for whether a observation in a workfile page is in an index.
Syntax: @pageinidx(x)
x: vector
Return: vector
Returns a vector containing (0,1) boolean values for whether each observation in the current workfile page is specified in x, where x contains the indices of observations.
Examples
wfcreate(wf=qwf) q 2001 2024
vector id1 = @pageidx("2010q2 2010q3 2021q1 2023q4")
vector include = @pageinidx(id1)
creates a workfile containing quarter observations from 2001 to 2024, identifies the index values for four specific dates and then obtains the vector INCLUDE which has the value of 1 for those four dates, and 0 otherwise.
One useful application of this indicator vector is setting the workfile sample. Since ID1 is the same length as the current page, the commands
vector include = @pageinidx(id1)
mtos(include, keep)
smpl if keep=1
set the current workfile sample to include only the four observations specified above.
Cross-references
See also @pageidx, @pagesmplidx, and mtos.
@pagelist
All workfile page names.
Syntax: @pagelist
Return: string
Returns a string containing a space delimited list of names of all of the pages in the active workfile.
Examples
string allnames = @pagelist
saves the list of all of the pages in the workfile.
string temp = @pagelist
string pg = @word(@pagelist, 2)
pagedelete {pg}
deletes the second page in the workfile.
Cross-references
See also pageselect, and pagesave.
@pagename
Name of active workfile page.
Syntax: @pagename
Return: string
Returns a string containing the name of the active page in the workfile.
Examples
string pgname = @pagename
saves the name of the active workfile page in the string variable PGNAME.
The commands
%name = @pagename
pagedelete {%name}
delete the current page.
Cross-references
See also @wfname and @wfpath.
@pagerange
Range specification in active workfile page.
Syntax: @pagerange
Return: string
Returns a string containing the range specification for the active page in the workfile.
Examples
string smplstr = @pagesmpl
places the range string in the string variables SMPLSTR.
Cross-references
See also smpl and @pagesmpl.
@pagesmpl
Sample specification in active workfile page.
Syntax: @pagesmpl
Return: string
Returns a string containing the current sample specification for the active page in the workfile.
Examples
smpl 2010 2022 if inflation > 3.0
string smplstr = @pagesmpl
places the workfile string in the string variables SMPLSTR.
Cross-references
See also smpl and @pagerange
@pagesmplidx
Index vector of observations in the current sample.
Syntax: @pagesmplidx
Return: vector
Returns a vector containing the index values of the observations in the current sample in the active workfile page.
Examples
wfcreate(wf=awf) a 2001 2024
smpl 2002 2003 2010 2011
creates a workfile containing annual observations from 2001 to 2024, then sets the sample to contain observations from 2002–2003 and 2010–2011. There are 24 observations in this workfile which may be identified by index values 1 to 24.
vector ids = @pagesmplidx
creates a vector containing the values {2, 3, 10, 11} corresponding to the index values of the sample observations.
Cross-references
See also smpl, @pageidx, @pageinidx.
@pc
One-period percentage change (in percent).
Syntax: @pc(x)
x: series
n: integer, series
Return: series
Returns one-period percentage change (in percent) in the series x:
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @pc(x)
produces a linked series of monthly profit growth in percent.
Cross-references
See also @pca, @pch, @pcha, @pchy, and @pcy.
@pca
One-period percentage change, annualized (in percent).
Syntax: @pca(x)
x: series
n: integer, series
Return: series
Returns the n-th root of the total return of x over n periods, minus 1:
where is the lag associated with the yearly frequency (e.g., for quarterly data, for monthly data).
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @pca(x)
produces a linked series of annualized profit growth in percent.
Cross-references
See also @pc, @pch, @pcha, @pchy, and @pcy.
@pccagr
Annualized growth rate (in percent).
Syntax: @pccagr(x, n)
x: series
n: integer
Return: series
Returns the n-th root of the total annual return of x over n periods, minus 1, multiplied by 100:
This function is panel aware.
Examples
If x is a series of quarterly profits, then
show @pccagr(x, 1)
returns a linked series containing annualized profit growth rates in percent.
Cross-references
See also @cagr.
@pch
One-period percentage change (in decimal fraction).
Syntax: @pch(x)
x: series
n: integer, series
Return: series
Returns one-period percentage change (in decimal fraction) in the series x:
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @pch(x)
produces a linked series of monthly profit growth in decimal fraction.
Cross-references
See also @pc, @pca, @pcha, @pchy, and @pcy.
@pcha
One-period percentage change, annualized (in decimal fraction).
Syntax: @pcha(x)
x: series
n: integer, series
Return: series
Returns one-period percentage change (in decimal fraction) in the series x:
where is the lag associated with the yearly frequency (e.g., for quarterly data, for monthly data).
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @pcha(x)
produces a linked series of annualized profit growth in decimal fraction.
Cross-references
See also @pc, @pca, @pch, @pchy, and @pcy.
@pchy
One-year percentage change (in decimal fraction).
Syntax: @pchy(x)
x: series
n: integer, series
Return: series
Returns one-year percentage change (in decimal fraction) in the series x:
where is the lag associated with the yearly frequency (e.g., for quarterly data, for monthly data).
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @pchy(x)
produces a linked series of one-year profit growth in decimal fraction.
Cross-references
See also @pc, @pca, @pch, @pcha, and @pcy.
@pctiles
Percentile values.
Determine the percentile associated with each value.
Syntax: @pctiles(x[, z, s])
x: series, vector, matrix
z: (optional) string literal
s: (optional) sample string or object when x is a series and assigning to a series
Return: series
If is the ranking associated with observation of , the percentile is given by
The z option controls tie-handling with rankings handled according to the setting:
“i” (ignore), “f” (first), “l” (last), “a” (average - default), “r” randomize.
For series calculations, EViews will use the current or specified workfile sample.
Examples
Let x be a vector of length 4 with elements 1, 2, 3, 4. Then
= @pctiles(x)
returns a vector whose elements are 25, 50, 75, 100.
matrix y = @mnrnd(200, 4)
matrix pct1 = @pctiles(y, "a")
matrix pct2 = 100 * @ranks(y, "a") / @obs(y)
compute the percentiles of the randomly generated matrix Y directly using @pctiles and indirectly using @ranks. Both PCT1 and PCT2 are matrices where each element is the percentile of the corresponding element of Y amongst all elements.
Cross-references
See also @quantile.
@pcy
One-year percentage change, (in percent).
Syntax: @pcy(x)
x: series
n: integer, series
Return: series
Returns one-year percentage change (in percent) in the series x:
where is the lag associated with the yearly frequency (e.g., for quarterly data, for monthly data).
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @pcy(x)
produces a linked series of one-year profit growth in percent.
Cross-references
See also @pc, @pca, @pch, @pcha, and @pchy.
@periodtodate
Within-period cumulative sum (period-to-date).
Syntax: @periodtodate(x, y[, s])
x: series
y: series
s: (optional) sample string or object
Return: series
Cumulative sum of series x within each period, where each period is defined by a contiguous block of identical values in series y, subject to limitations imposed by the optional sample or workfile sample.
This function is panel aware.
Examples
If x is a series of monthly profits, then
show @periodtodate(x, @quarter)
returns a linked series of quarter-to-date monthly profits.
Cross-references
See also @ytd.
@permute
Permutation of matrix.
Syntax: @permute(m)
m: data object
Return: data object
Returns a data object whose rows are randomly drawn without replacement from rows of the input m. The output has the same type and size as the input object.
To draw with replacement from rows of a data object, use @resample.
Examples
matrix xp = @permute(x)
yields the matrix XB whose rows were randomly sampled without replacement from the matrix X.
Cross-references
See also @colsort, @rowsort, and @sort.
See also @ranks as well as @capplyranks and @rapplyranks.
See also @resample.
@pi
Pi – ratio of a circle's circumference to its diameter ().
Syntax: @pi
Return: number
Examples
= @sin(@pi/2)
returns 1.
Cross-references
See also @log2pi.
@pinverse
Moore-Penrose pseudo-inverse of matrix.
Syntax: @pinverse(m)
m: matrix, sym
Return: matrix, sym
Returns the Moore-Penrose pseudo-inverse of a matrix object or sym.
The pseudo-inverse has the property that both pre-multiplying and post-multiplying the pseudo-inverse by the source matrix returns the source matrix, and that both pre-multiplying and post-multiplying the source matrix by the pseudo-inverse will return the pseudo-inverse.
For matrix and pseudo-inverse ,
Calling the function to produce the pseudo-inverse of a matrix returns a matrix, while the pseudo-inverse of a sym returns a sym. Note that pseudo-inverting a sym is much faster than inverting a matrix.
Examples
matrix m1 = @mnrnd(10, 10)
matrix m1p = @pinverse(m1)
computes the pseudo-inverse of a randomly generated matrix M1.
matrix m2p = @pinverse(@inner(m1))
computes the pseudo-inverse of the PSD inner product of M1.
The following validate the properties of the pseudo-inverse:
matrix diff1 = m1 * m1p * m1 - m1
matrix diff2 = m1p * m1 * m1p - m1p
as both DIFF1 and DIFF2 equal zero.
Cross-references
See also @inverse and @issingular.
@pmax
Pairwise maximum.
Syntax: @pmax(x, y)
x: series
y: series
Return: series
Returns the pairwise maximum of and (for more than two series, use @rmax). Missing values propagate.
Examples
Let x and y be series objects.
show @pmax(x,y)
returns a linked series of observation-wise maximums in x and y.
Cross-references
See also @pmin and @rmax.
@pmin
Pairwise minimum.
Syntax: @pmin(x, y)
x: series
y: series
Return: series
Returns the pairwise minimum of and (for more than two series, use @rmin). Missing values propagate.
Examples
Let x and y be series objects.
show @pmin(x,y)
returns a linked series of observation-wise minimums in x and y.
Cross-references
See also @pmax and @rmin.
@pmt
Payment amount required for annuity to pay given present value.
Syntax: @pmt(r, n, pv[, v, bf])
r: number
n: integer
pv: number
v: (optional) number
bf: (optional) number
Return: number
Find the receipt amount x required to produce at least the present value pv from an n-period annuity, with discount rate r, and optional receipt of a final lump sum v.
A non-zero value for the optional bf indicates that the receipts are made at the beginning of periods (annuity due) instead of ends (ordinary annuity).
The present value of by n-periods of ordinary annuity receipts and a final lump sum is:
The present value of n-periods of annuity due receipts and a final lump sum is:
Then for a given PVO or PVD and annuity type, the function returns the smallest x required for the present values to exceed the required value.
Examples
= @pmt(0.05, 10, 1000)
returns the value 129.5046, indicating that a 10-period annuity that pays $129.50 per period has a present value of around $1000 assuming the discount rate of 5%.
Cross-references
See also @fv, @nper, @pv, and @rate.
@pow
Power function.
Syntax: @pow(x, y)
x: number
y: number
Return: number
Returns the power of : . If must be an integer value.
Examples
= @pow(2,8)
returns 256.
Cross-references
See also @powm1 and @pow1pm1.
@pow1pm1
Power function of 1 plus argument, minus 1.
Returns .
Syntax: @pow1pm1(x, y)
x: number
y: number
Return: number
If , then must be an integer value.
Provides higher precision calculation of than direct evaluation using
@pow(1+x, y) - 1
for near 1.
Examples
= @pow1pm1(0.07,10)
returns 0.96715....
Cross-references
See also @pow and @powm1.
@powm1
Power function, minus 1.
Returns .
Syntax: @powm1(x, y)
x: number
y: number
Return: number
If , then must be an integer value.
Provides higher precision calculation of than direct evaluation of
@pow(x, y) - 1
for near 1.
Examples
= @powm1(1.07,10)
returns 0.96715....
Cross-references
See also @pow and @pow1pm1.
@prod
Product.
Computes the product of the elements of x. Note that this function is prone to numeric overflow.
Syntax: @prod(x[, s])
x: series, vector, matrix
s: (optional) sample string or object when x is a series and assigning to a series
Return: number
For series calculations, EViews will use the current or specified workfile sample.
Examples
If x is a series of length 5 whose elements are 1, 2, 3, 4, 5, then
= @prod(x)
returns 120 (or equivalently, 5!).
Cross-references
See also @inner, @sum, and @sumsq.
@psi
First derivative of the natural log of the gamma function.
Syntax: @psi(x)
x: number
Return: number
for .
Examples
= @psi(1)
returns -0.57721....
Cross-references
See also @digamma, @gammalog, and @trigamma.
@pv
Present value of annuity receipts and (optional) final lump sum receipt.
Syntax: @pv(r, n, x[, v, bf])
r: number
n: integer
x: number
v: (optional) number
bf: (optional) number
Return: number
Compute present value of receipt of an n-period annuity, with receipts x and discount rate r, and optional receipt of a final lump sum v.
If n is not an integer, the integer floor will be used.
A non-zero value for the optional bf indicates that the receipts are made at the beginning of periods (annuity due) instead of ends (ordinary annuity).
The present value of by n-periods of ordinary annuity receipts and a final lump sum is:
The present value of n-periods of annuity due receipts and a final lump sum is:
Examples
= @pv(0.05, 15, 100)
returns the value 1037.966, indicating that a 15-period annuity that pays $100 per period has a present value of $1037.97 assuming the discount rate of 5%.
Cross-references
See also @fv, @nper, @pmt, and @rate.