Re: [R] Assigning factors probabilistically based on the value of another variable.

2010-03-28 Thread Economics Guy
o what I need. However, in the real program what I need to be able to do is precisely vary the degree of exactness in the assignment. So I need to be able to have the assignment range from completely random assignment to the exact assignment that "exact" above provid

[R] Assigning factors probabilistically based on the value of another variable.

2010-03-27 Thread Economics Guy
nks, That Economics Guy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] Saving output in an iterated function

2009-06-21 Thread Economics Guy
; Reduce(f, init = d, x = rep(1, 4), accumulate = TRUE) > > > On Sun, Jun 21, 2009 at 9:06 AM, Economics Guy wrote: >> # I have a function that takes a few vectors manipulates them and then >> outputs a matrix of results: >> >> funct1 <- function(eh,be){ >&g

[R] Saving output in an iterated function

2009-06-21 Thread Economics Guy
# I have a function that takes a few vectors manipulates them and then outputs a matrix of results: funct1 <- function(eh,be){ ce <- eh+be data.frame(eh,be,ce) } ones <- c(1,1,1) twos <- c(2,2,2) funct1(ones,twos) # I would like to iterate it and save the results

[R] Running a function through a vector with the scalars as arguments

2009-06-17 Thread Economics Guy
I have a vector of probabilities that I would like to feed to rbinom() and have it return a 1 or 0 for each element. I have tried simply using the entire vector as the argument hoping R would understand. Instead I get a scalar: theProbs <- runif(10,0,1) youreON <- rbinom(1, 1, theProbs) Next I

[R] FMOLS

2008-10-23 Thread Economics Guy
Is anyone aware of an R package that implements Pedroni's FMOLS (Fully Modified Ordinary Least Squares) package, for panel data with non-stationary and co-integration? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEA

[R] Randomly drawing observations from factors.

2008-07-31 Thread Economics Guy
I have a large data set where one of the columns needs be a unique identifier (ID) for each row. However for a few of the rows they have the same ID. What I need to do is randomly draw one of the rows and keep it in the data frame and drop all the others which have the same ID. For example: v1 <-

Re: [R] Percentages for categorical data by group

2008-05-23 Thread Economics Guy
I appreciate all the help. The trouble is that in my real data set each group does not always have an observation that choose each response. This results in some of the "rows" returned from prop.table() to be shorter than others so I get: Warning message: In function (..., deparse.level = 1) :

Re: [R] Percentages for categorical data by group

2008-05-23 Thread Economics Guy
Thanks Michael that works! Now I am having a problem getting the results into a format I can use. prop.table generates a contingency table that I tried to turn into a data frame I could graph from with as.data.frame() however the results are not a true data.frame. The rows have commas between som

[R] Percentages for categorical data by group

2008-05-23 Thread Economics Guy
I can think of several ways to blunt force hard code what I want but I imagine there is a command or two that can be easily combined to do this: I have a data frame with about 23000 observations. There first variable is the group to which the observation belongs (about 500 different groups). The s

Re: [R] Using loop numbers in write.csv

2008-03-13 Thread Economics Guy
g) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > [EMAIL PROTECTED] > (801) 408-8111 > > > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Economics Guy > > Sent: T

[R] Using loop numbers in write.csv

2008-03-13 Thread Economics Guy
This is a question I have wanted to ask for a while but hesitated because I was sut sure I would find the answer on my own, but as of yet...no dice. 1) Is there a way to use the loop number in naming things in R. Specifically I have a simulation that has two loops. I would like to be able to writ

[R] Generating a new matrix using rbinom and a matrix of probabilities.

2008-03-11 Thread Economics Guy
I am having a little trouble getting R to do something without writing a couple of very awkward loops. I have a matrix of probabilities and I want to generate a new matrix of ones and zeros where each element in the new matrix is the result of a draw from a binomial distribution where the probabil