Displaying 20 results from an estimated 3000 matches similar to: "Formulae for R functions"
2008 Mar 30
2
convert weekly time series data to monthly
I have weekly time series data with year, month, day, and price variables.
The input data set for the weekly series takes the following form:
Year month day price
1990 8 20 119.1
1990 8 27 124.5
1990 9 3 124.2
1990 9 10 125.2
1990 9 17 126.6
1990 9 24 127.2
1990 10 1 132.1
1990 10 8 133.3
1990 10 15 133.9
1990 10 22 134.5
1990 10 29 133.9
.. ... ... ...
... ... .... ....
2008 3 3 313.7
2008
2008 Jan 03
1
R procedure similar to STATA heckprob?
Is anyone aware of an R procedure similar to STATA's "heckprob" procedure?
"Heckprob" fits maximum likelihood probit models correcting for sample
selection bias.
Thanks,
Richard Saba
Department of Economics
Auburn University
Email: sabaric@auburn.edu
[[alternative HTML version deleted]]
2008 Mar 21
1
tseries(arma) vs. stats(arima)
Hello,
The "arma" function in the "tseries" package allows estimation of models
with specific "ar" and "ma" lags with its "lag" argument.
For example: y[t] = a[0] + a[1]y[t-3] +b[1]e[t-2] + e[t] can be estimated
with the following specification : arma(y, lag=list(ar=3,ma=2)).
Is this possible with the "arima" function in the
2007 Dec 05
1
Working with "ts" objects
I am relatively new to R and object oriented programming. I have relied on
SAS for most of my data analysis. I teach an introductory undergraduate
forecasting course using the Diebold text and I am considering using R in
addition to SAS and Eviews in the course. I work primarily with univariate
or multivariate time series data. I am having a great deal of difficulty
understanding and working with
2008 Apr 30
2
Bug? in summary( ) function base package
There seems to be an error in the summary() function when applied to "ts"
class objects. The results of a call to summary( ), on the R "ts" data set
USAccDeaths , reports the wrong value for Max. The value reported by the
summary function is 11320. The max( ) function returns the correct value
11317, the July 1993 value. Coercing the data to a data.frame and calling
summary
2007 Oct 26
1
Newey-West and SUR regression models
Is anyone aware of a procedure to apply Newey-West corrections for
autocorrelation to a SUR regression model? The SANDWICH package seems to be
applicable only to LM or GLM models.
Thanks,
Richard Saba
Department of Economics
Auburn University
Email: sabaric at auburn.edu
2008 Jan 11
1
question about xreg of arima
Hi,
I am trying to understand exactly what xreg does in arima. The documentation
for xreg says:"xreg Optionally, a vector or matrix of external regressors,
which must have the same number of rows as x." What does this mean with
regard to the action of xreg in arima?
Apparently somehow xreg made the following two arima fit equivalent in R:
arima(x, order=c(1,1,1), xreg=1:length(x))
is
2010 Apr 08
1
reshape panel data
I have a data set with observations on 549 cities spanning an 18 year
period. However, some of cities did not report in one or more of the 18
years. I would like to implement the procedure suggested by Wooldridge
section 17.1.3 in his "Econometric analysis of cross section and panel data"
to correct for attrition. For example the table below indicates that the 3rd
and the 7th cities in
2007 Nov 28
2
extracting year an month from ts data set
I have an ascii data set of monthly observation starting in Jan 1946 with a
header.
hstarts
57
65
95
103
103
97
94
.
.
.
Which I read with the following code
tab6.1<-ts(read.table(fname, header=TRUE),frequency=12,start=c(1946,1))
I would like to run a time series model with dummy variables for each month.
If I had a variable which take values from 1 to 12 indicating the month I
could use
2010 Feb 07
2
Reading hierarchical data
I would like to read the following hierarchical data set. There is a family
record followed by one or more personal records.
If col. 7 is "1" it is a family record. If it is "2" it is a personal
record.
The family record is formatted as follows:
col. 1-5 family id
col. 7 "1"
col. 9 dwelling type code
The personal record is formatted as follows:
col.
2008 Sep 23
4
gsub difficulty
Greetings R-ians:
I know what doesn?t work but I don?t know why, nor how to remedy things.
I have a character string containing "." which I want to replace with " "
gsub(".", " ", file.label) replaces the every character with a blank.
However gsub(".xls", " ", file.label) replaces ".xls" with a blank as
expected.
It appears
2008 Jan 26
3
Which R version created a package?
Greetings, R-ians:
I would like to know which version or R was used to create a given package.
I think I remember seeing that topic discussed recently but cannot find it
among my notes. Can anyone tell me how to determine which version of R
created a package?
Thanks.
Charles Annis, P.E.
<mailto:Charles.Annis@StatisticalEngineering.com>
Charles.Annis@StatisticalEngineering.com
2008 Aug 14
5
help with my sloppy syntax
R-ians:
After some effort I coerced my code to do what I want but my syntax is a
kludge. Suggestions on more elegant syntax?
par <- NIM.results$par
do.call("Draw.NIM.POD.curve", list(par[1], par[2], par[3], par[4],
par[5], a.hat.decision, .... et cetera ...
It seems that I should be able to avoid defining the variable "par" and then
specifying each of its elements,
2006 Sep 29
3
control L to clear the Rgui screen in Windows
Greetings R-ians:
Searching the Searchable Mail Archives I discovered that ctrl L will clear
the Rgui screen, which is what I'd like to do from a print (or some similar)
statement.
Is there a mechanism to use the ctrl L clear-screen sequence in a script, or
print statement?
Thanks for your counsel.
Charles Annis, P.E.
Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:?
2006 Jul 09
4
string problems with "\\" (Windows)
Greetings, R-ians:
I'm using R 2.3.1 on WindowsXP.
I need to find the name of a file at the end of a sting that contains the
path + file, with the problematic "\\" as separators.
The string looks something like this:
"C:\\Documents and Settings\\myName\\My Documents\\R
Projects\\Project1\\file.name.csv"
What I want is "file.name.csv"
Currently I use the
2006 Jul 09
4
string problems with "\\" (Windows)
Greetings, R-ians:
I'm using R 2.3.1 on WindowsXP.
I need to find the name of a file at the end of a sting that contains the
path + file, with the problematic "\\" as separators.
The string looks something like this:
"C:\\Documents and Settings\\myName\\My Documents\\R
Projects\\Project1\\file.name.csv"
What I want is "file.name.csv"
Currently I use the
2006 Mar 05
2
plotting partial deriviatives
Dear R Helpers:
I am trying to annotate a plot. The following code snippet works, but it is
kind of a kludge since it adds the partial derivative symbols after creating
the plotmath frac(). Is there a more elegant way to write a partial
derivative?
dev.off()
plot(NA, xlim=c(-3,3), ylim=c(0,1.6), xlab="", ylab="", tck=-0.015)
text(1.6, 1, expression(paste("slope =
2008 Oct 05
2
trouble with character \u00e2
Greetings R-wizards:
For historical reasons I have filenames with the character "?" and have
successfully used "\u00e2" in its place, with the hoped-for result on all my
on-screen plots.
However since R2.7.0 I have trouble with savePlot() when the file name
includes that character as it does in this example:
savePlot(paste("diagnostic ? vs a ", file.label,
2009 Aug 26
1
Scripting - sort of
Dear R-ians:
I'm running R2.9.2 on a 6 year old Windows XP DELL with 2 Gig RAM and a 3MHz
Pentium 4 chip.
I've written a package using the User Menus Under Windows commands
(winMenuAdd, etc). It works very well.
I have 6 test cases and running any one of them requires many selections
form the menus and some keyboard entry, and it takes me hours to exercise
them all to see
2006 Aug 19
4
string-to-number
Greetings, Amigos:
I have been trying without success to convert a character string,
> repeated.measures.columns
[1] "3,6,10"
into c(3,6,10) for subsequent use.
as.numeric(repeated.measures.columns) doesn't work (likely because of the
commas)
[1] NA
Warning message:
NAs introduced by coercion
I've tried many things including
strsplit(repeated.measures.columns, split =