Re: [R] Moving average with loess

2012-03-09 Thread Downey, Patrick
Hi Robert, If you type ?loess It pulls up the documentation. What about that function do you not like? As you said, it needs two variables, but typically the second is just your time index. Try this: n <- 50 x <- rep(0,n) for(i in 2:n){ x[i] <- rnorm(1,x[i-1]) } loess(x ~ seq(1,n)) plot(1:n,x,t

Re: [R] Find identical pairs

2012-03-08 Thread Downey, Patrick
Hi Alex, x <- sample.int(4,20,replace=TRUE) y <- sample.int(4,20,replace=TRUE) cbind(x,y)[x==y,] Thanks, Mitch -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: Thursday, March 08, 2012 11:18 AM To: R help Subject: [R]

[R] Panel models: Fixed effects & random coefficients in plm

2012-03-08 Thread Downey, Patrick
Hello, I am using {plm} to estimate panel models. I want to estimate a model that includes fixed effects for time and individual, but has a random individual effect for the coefficient on the independent variable. That is, I would like to estimate the model: Y_it = a_i + a_t + B_i * X_it + e_it W

Re: [R] Installing binaries from R-Forge

2011-11-09 Thread Downey, Patrick
8: In install.packages("splm", repos = "http://R-Forge.R-project.org";, : installation of package 'plm' had non-zero exit status 9: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l "D:/Documents and Settings/pdowney/My Documen

Re: [R] Installing binaries from R-Forge

2011-11-09 Thread Downey, Patrick
nstall the package from source, just add the argument type="source" in your call to install.packages(). How to prepare your environment to allow to install source packages is described in the R Installation and Administration manual. Uwe Ligges On 09.11.2011 13:39, Downey, Patrick wrot

[R] Installing binaries from R-Forge

2011-11-09 Thread Downey, Patrick
Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, "In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R..." It later says "To install this package directly

Re: [R] 'save' saved object names instead of objects

2011-09-23 Thread Downey, Patrick
Thank you Jean Christophe and Sarah. You are both, of course, absolutely correct. -Original Message- From: Jean-Christophe BOUËTTÉ [mailto:jcboue...@gmail.com] Sent: Friday, September 23, 2011 9:44 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] 'save' sa

Re: [R] 'save' saved object names instead of objects

2011-09-23 Thread Downey, Patrick
A more compact example might be helpful: g <- array(0,dim=c(4,4)) g save(g,file="D:/g") h <- load(file="D:/g") h -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Downey, Patrick Sent: Friday, September 23,

[R] 'save' saved object names instead of objects

2011-09-23 Thread Downey, Patrick
Hello, I created an array to hold the results of a series of simulations I'm running: d.eta <- array(0,dim=c(3,3,200)) Then I tried to save the results using this: save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") When I later tried to reload them using this: d.eta <- load(file="D:/

Re: [R] merge function

2011-06-30 Thread Downey, Patrick
I was mistaken. There were duplicates in my y vector. Please ignore my previous message. Sorry. -Original Message- From: Downey, Patrick Sent: Thu 6/30/2011 11:08 PM To: r-help@r-project.org Subject: merge function Hello, I'm clearly confused about the merge function. I

[R] merge function

2011-06-30 Thread Downey, Patrick
Hello, I'm clearly confused about the merge function. In the following r <- merge(x,y,all.x=T,all.y=F) my y vector has only unique values (no duplicates). So I don't understand how this can ever generate an r which is of greater length than x. I thought the default behavior was only matching r

[R] Simulating SVAR Data

2011-06-01 Thread Downey, Patrick
Hello, I'd like to simulate data according to an SVAR model in order to demonstrate how other techniques (such as arima) yield biased estimates. I am interested in a 2 variable SVAR with 2 lags (in the notation of the vars vignette, K = 2, P = 2, where B = I_K). I'm using the {vars} package outlin

[R] Setting max. iterations for lmer

2011-05-28 Thread Downey, Patrick
Hello, I hate to ask a question which is directly addressed in the documentation, but can someone please give me an example of how to change the maximum number of iterations used by lmer. I'm having a hard time understanding this: control a list of control parameters. See below for d

Re: [R] pdf (probability distribution function) and cdf

2011-05-17 Thread Downey, Patrick
?dnorm -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: Tuesday, May 17, 2011 12:50 PM To: Jonathan Daily Cc: R-help@r-project.org Subject: Re: [R] pdf (probability distribution function) and cdf I am assuming a Gaussian

Re: [R] pdf (probability distribution function) and cdf

2011-05-17 Thread Downey, Patrick
I like the function Ecdf in the Hmisc package. For the pdf, you can also use plot(density(x)), which is in the stats package. ??Ecdf -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: Tuesday, May 17, 2011 10:09 AM To: R

Re: [R] Minimum value by ID

2011-05-17 Thread Downey, Patrick
Perfect. Thank you. -Mitch -Original Message- From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] Sent: Tuesday, May 17, 2011 9:51 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Minimum value by ID have a look at help file of function tapply(), and try this

[R] Minimum value by ID

2011-05-17 Thread Downey, Patrick
Hello, I have a longitudinal dataset where each individual has a different number of entries. Thus, it is of the following structure: x <- runif(12) id.var <- factor(c(rep("D1",4),rep("D2",2),rep("D3",3),rep("D4",3))) dat <- as.data.frame(x) dat$id.var <- id.var dat > dat x id

Re: [R] how to get row name using the which function

2011-05-02 Thread Downey, Patrick
Perhaps not the most elegant. rownames(example)[which.max(example)] If you wanted to type less, you could always write a function. names.max <- function(x){ return(rownames(example)[which.max(example)]) } -Mitch -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-

Re: [R] Finding elements in a character vector

2011-04-08 Thread Downey, Patrick
Perfect. Thank you. -Mitch -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Friday, April 08, 2011 8:03 PM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Finding elements in a character vector match(list.a,list.b

[R] Finding elements in a character vector

2011-04-08 Thread Downey, Patrick
Hello, I have two character vectors: list.a and list.b. Every element of list.a appears somewhere in list.b. Not all elements of list.b are in list.a, and some elements of list.b appear multiple times in list.a. I want to create a new vector (index) of the same length as list.a where the nth eleme

[R] Hierarchical Power Analysis

2011-02-25 Thread Downey, Patrick
Hello, A colleague is trying to do a fairly complicated power analysis for a project. The project would be evaluating random assignment to one of three conditions within each of 8 sites. The dependent variable would be binary (we do not care at this point whether it would be analyzed with logit or

[R] Arima contents

2011-02-16 Thread Downey, Patrick
Hello, I'm running a number of arima models using the "arima" function. Often, when lag length gets too high, these model don't converge and an error message appears as this: > reg <- arima(y,order=c(7,0,7),xreg=isr) Warning message: In arima(y, order = c(7, 0, 7), xreg = isr) : possible converg

[R] Extracting a formula from Arima for structural break analysis

2010-12-30 Thread Downey, Patrick
Hello, I fit an ARMA model to a series using the arima function. Now I wish to use the "breakpoints" function from the {strucchange} package to test for structural breaks. The breakpoints function requires a formula as input. The examples show how to write an AR model as a formula, but I have MA t

Re: [R] Y Axis Labels

2010-10-27 Thread Downey, Patrick
Thank you both. Using axis I have gotten exactly what I needed. Thanks, Mitch -Original Message- From: Thomas Levine [mailto:thomas.lev...@gmail.com] Sent: Wednesday, October 27, 2010 2:34 PM To: Sarah Goslee Cc: Downey, Patrick; r-help@r-project.org Subject: Re: [R] Y Axis Labels

[R] Y Axis Labels

2010-10-27 Thread Downey, Patrick
Hello, I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is there a way to label the values on the y-axis with the translation from the scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like "Never", "Once per month", "A few times per month", "A few times per

[R] Equality of Vectors

2010-08-13 Thread Downey, Patrick
Hello, Is there a way to get a single TRUE or FALSE statement from comparing two vectors? For example, c(1,2,3) == c(1,2,3) produces TRUE TRUE TRUE where I would like it to produce only TRUE for use in an if statement. Likewise, when two vectors are not exactly identical (in all elements) I w

[R] Displaying Iteration Count

2010-06-22 Thread Downey, Patrick
Hello, I'm running a very long for loop that usually takes hours. For my own piece of mind, it would be nice if I could check periodically and see which iteration the loop is on. A line of code that told R to print the iteration number every 100 or 200 iterations would be perfect. Does anyone kno

Re: [R] ecdf

2010-04-19 Thread Downey, Patrick
-Original Message- From: ONKELINX, Thierry [mailto:thierry.onkel...@inbo.be] Sent: Monday, April 19, 2010 9:08 AM To: Downey, Patrick; R help Subject: RE: [R] ecdf R is case sensitive. ecdf() is in the stats package, Ecdf() is in Hmisc. So you want Ecdf(x,what=

[R] ecdf

2010-04-19 Thread Downey, Patrick
Hello, I'd like to plot an empirical cumulative distribution function, except instead of the fraction of values < x, I'd like the fraction of values > x. I think this can be done using the ecdf function in {Hmisc}. I installed the package and loaded it. However, when following the example given

[R] Strange results from Multivariate Normal Density

2010-04-12 Thread Downey, Patrick
Hello, I'm using dmnorm from the package {mnormt} and getting strange results. First, according to the documentation, dmnorm should return a vector of densities, and I'm only getting one value returned (which is what I would expect). I've been interpreting this as the joint density of all values

[R] Lag Function

2010-03-22 Thread Downey, Patrick
Can anyone tell me what's going on here? x <- matrix(data=c(1,2,3,4,5),ncol=1) x1 <- lag(x,k=1) x x1 x - x1 That's with x specified as a column vector, but the same thing happens when it's a row vector. x <- c(1,2,3,4,5) x1 <- lag(x,k=1) x x1 x - x1 When the documentation says "Vector or matrix

[R] VAR with contemporaneous effects

2010-03-11 Thread Downey, Patrick
Hi, I would like to estimate a VAR of the form: Ay_t = By_t-1 + Cy_t-2 + ... + Dx_t + e_t Where A is a non-diagonal matrix of coefficients, B and C are matricies of coefficients and D is a matrix of coefficients for the exogenous variables. I don't think the package {vars} can do this because I

[R] Constraining coefficients to be equal in svar

2010-03-10 Thread Downey, Patrick
Hello, I'm working on an structural VAR using the var command to estimate and the svar command on the resultant object (package: vars). I want to constrain coefficients to equal one another, but that value to be estimated. So for the A matrix, I want A[2,1]=A[1,2] to be my constraints. Can this b