Re: [R] reduced set of alternatives in package mlogit

2016-04-01 Thread Christopher Desjardins
Hi Jose, You're referring to your response variable when you're saying it's missing some of the choices, right? Are your response choices ever known or do they just occur with extremely low frequency? Either way, I think the mlogit package would be inappropriate for you. I imagine you would have m

Re: [R] Good pointers for understanding the R language implementation

2016-04-06 Thread Christopher Desjardins
This might be useful: http://adv-r.had.co.nz/ On Tue, Apr 5, 2016 at 10:31 AM, Francisco Banha wrote: > Dear All, > > I'm currently working on a project with > the purpose of remotely executing R code, which requires me to have to > work with the code of R itself. I've searched the Internet for

[R] ggplot2 x axis question

2009-06-28 Thread Christopher Desjardins
Hi, I have 45 models that I have named: 1, 2, 3, ... , 45 and I am trying to plot them in order of ascending BIC values. I am however unclear as to how I can get the models to line up on the x-axis by BIC and not by numeric order. For example, if model 5 has a lower BIC than 1, I want it to be

Re: [R] ggplot2 x axis question

2009-06-29 Thread Christopher Desjardins
ley wickham wrote: > Hi Chris, > > Try this: > > qplot(reorder(model, delta), delta, data = growthm.bic) > > Hadley > > On Sun, Jun 28, 2009 at 9:53 AM, Christopher > Desjardins wrote: > >> Hi, >> I have 45 models that I have named: 1, 2, 3, ... , 45 an

Re: [R] ggplot2 x axis question

2009-06-29 Thread Christopher Desjardins
n, Jun 29, 2009 at 10:39 AM, Christopher > Desjardins wrote: > >> Hi Hadley, >> Thanks for the reply and the great graphing package. That code is giving me >> the following error: >> >> >>> qplot(reorder(model,delta),delta,data=growthm.bic) >>

[R] How to combine two data frames by ID

2009-07-14 Thread Christopher Desjardins
Hi, I am trying to combine two data frames by ID. The first data frame is the whole data set and the second data frame is a subset of the first. What I would like to do is take the values from variable, p1, from the second data frame and merge them back into that variable in the first data fr

[R] Error with r2winbugs

2009-07-16 Thread Christopher Desjardins
Hi, I am trying to do run the following model saved in "C:/bugs/sus.bug" model { for (i in 1:n){ y[i] ~ dpois(lamdba[i]) log(lambda[i]) <- mu+bmale[male[i]]+bschn[schn[i]]+epsilon[i] # epsilon[i] ~ dnorm(0,tau.epsilon) } mu ~ dnorm(0,.0001) bmale ~ dnorm(0,.0001) tau.epsilon

[R] combining 4 vectors into one

2009-07-19 Thread Christopher Desjardins
Hi, How can I perform the following y1y2y3y4 1 0 3 2 0 1 2 1 3 2 0 1 0 5 1 0 into ... > y 1 0 3 2 0 1 2 1 3 2 0 1 0 5 1 0 Please cc me on reply as I subscribe to the digest. Thanks! Chris ___

Re: [R] combining 4 vectors into one

2009-07-19 Thread Christopher Desjardins
0 1 0 5 1 0 > > > > > On Sun, Jul 19, 2009 at 7:25 PM, Christopher > Desjardins wrote: > >> Hi, >> How can I perform the following >> >> y1y2y3y4 >> 1 0 3 2 >> 0 1 2 1 >> 3 2

[R] Changing gird marks in ggplot2

2009-04-24 Thread Christopher Desjardins
Hi, When I zoom into a graph created in ggplot2 with the coord_cartesian(ylim=c(0,5)) option, I have no values labelled on my y-axis. For this graph ggplot2 only puts labels the y-axis at intervals of 10 (i.e. 0, 10, 20, ...). However, the major portion of the graph I am interested in is located be

[R] Randomly drop a percent of data from a data.frame

2013-08-16 Thread Christopher Desjardins
Hi, I have the following data. > set.seed(6245) > data <- data.frame(x1=rnorm(5),x2=rnorm(5),x3=rnorm(5),x4=rnorm(5)) > round(data,digits=3) x1 x2 x3 x4 1 0.482 1.320 -0.859 -0.142 2 -0.753 -0.041 -0.063 0.886 3 0.028 -0.256 -0.069 0.354 4 -0.086 0.475 0.244 0.781 5 0.69

Re: [R] Randomly drop a percent of data from a data.frame

2013-08-16 Thread Christopher Desjardins
on(x){x1<- > match(x,sample(unlist(data2[,3:4]),round(0.8*length(unlist(data2[,3:4]);x[ > is.na(x1)]<-NA;x}) > data2 > # x1 x2 x3 x4 > #1 0.482 1.320 -0.859 -0.142 > #2 -0.753 -0.041 NA NA > #3 0.028 -0.256 -0.069 0.354 > #4 -0.0

Re: [R] Amelia, Zelig and latex in R

2013-08-17 Thread Christopher Desjardins
Does this do what you want? library(Amelia) library(Zelig) library(stargazer) library(xtable) data(africa) m = 10 imp1 <- amelia(x = africa,cs="country",m=m) imp2 <- amelia(x = africa,cs="country",m=m) lm.imputed1 <- zelig(infl ~ trade + civlib, model="ls",data = imp1) lm.imputed2 <- zelig(infl

Re: [R] Amelia, Zelig and latex in R

2013-08-17 Thread Christopher Desjardins
SE) > but then I get my error: > Error: Unrecognized object type. > > Even though your example is insightful, I can't figure out how to solve > my problem. > Any advice is very welcome. > Regards, > f. > > > On 17 August 2013 17:02, Christopher Desjardins

Re: [R] Amelia, Zelig and latex in R

2013-08-17 Thread Christopher Desjardins
Oh and are you looking for just the summarized results over all the imputed runs? i thought you wanted them from each iteration. On Sat, Aug 17, 2013 at 11:38 AM, Christopher Desjardins < cddesjard...@gmail.com> wrote: > What do you mean by results? Do you want just the estimated p

Re: [R] Amelia, Zelig and latex in R

2013-08-18 Thread Christopher Desjardins
Seems you're after the pooled results. Would the following work? library(Amelia) library(Zelig) library(xtable) data(africa) m = 10 imp1 <- amelia(x = africa,cs="country",m=m) imp2 <- amelia(x = africa,cs="country",m=m) lm.imputed1 <- zelig(gdp_pc ~ trade + civlib, model="ls",data = imp1) lm.i

Re: [R] Amelia, Zelig and latex in R

2013-08-18 Thread Christopher Desjardins
do by hand in the tex code. > Is it possible that there is no way to get nicely latex formatted tables > concerning multiply imputed data-set? > But maybe I should open a separate thread on this. > Thanks a lot for your kind and patient help. > Best regards, > f. > >

Re: [R] Combining data from different saved files with same object names into one data frame

2013-02-04 Thread Christopher Desjardins
> fsumstatZINB=paste("/Users/chris/Dropbox/phd/analysis/Simulation/zinbmodels/summaries/zinbsumstat-",j,k,l,m,".rdata", > sep="") > load(fsumstatZINB) > print(zinbMeans[,1]) > result[[paste(j,k,l,m)]] <- zinbMeans >

[R] New Submission to CRAN note

2012-09-21 Thread Christopher Desjardins
Hi, I want to submit a package to CRAN and I am getting the following Note: * checking CRAN incoming feasibility ... NOTE New submission How can I take care of this? And/or is it a big deal? Thanks and sorry if this is something that I easily overlooked I have googled this topic for a while and

[R] Replacing NAs in long format

2012-11-03 Thread Christopher Desjardins
Hi, I have the following data: > data[1:20,c(1,2,20)] idr schyear year 1 80 1 91 1 10 NA 2 4 NA 2 5 -1 2 60 2 71 2 82 2 93 2 104 2 11 NA 2 126 3 4 NA 3 5 -2 3 6 -1 3

Re: [R] Replacing NAs in long format

2012-11-03 Thread Christopher Desjardins
gt; 3.13 3 4 -3 > 3.14 3 5 -2 > 3.15 3 6 -1 > 3.16 3 70 > 3.17 3 81 > 3.18 3 92 > 3.19 3 103 > 3.20 3 114 > > > > > > > On Sat, Nov 3, 2012 at 1:14 PM, Christopher Desjardi

Re: [R] Replacing NAs in long format

2012-11-03 Thread Christopher Desjardins
flag changes for an idr. Which it shouldn't. Thanks, Chris On Sat, Nov 3, 2012 at 5:50 PM, Christopher Desjardins < cddesjard...@gmail.com> wrote: > Hi Jim, > Thank you so much. That does exactly what I want. > Chris > > > On Sat, Nov 3, 2012 at 1:30 PM, jim holtman w

Re: [R] Replacing NAs in long format

2012-11-04 Thread Christopher Desjardins
721 > #5 2 900 > #6 2 1010 > #7 2 1120 > > > A.K. > > > > > > > - Original Message - > From: William Dunlap > To: arun ; Christopher Desjardins < > cddesjard...@gmail.com> &g

[R] Simulation with cpm package

2012-11-13 Thread Christopher Desjardins
Hi, I am running the following code based on the cpm vignette's code. I believe the code is syntactically correct but it just seems to hang R. I can get this to run if I set the sims to 100 but with 2000 it just hangs. Any ideas why? Thanks, Chris library(cpm) cpmTypes <- c("Kolmogorov-Smirnov","M

[R] Calling Gnuplot from R

2010-07-08 Thread Christopher Desjardins
Hi, I am wondering if there is a way to call Gnuplot from R and/or if anyone can recommend a package on CRAN capable of doing this? Thanks, Chris PS - Please cc me on the response. [[alternative HTML version deleted]] __ R-help@r-project.org mai

[R] RWinEdt and WinEdt 6.0

2010-07-15 Thread Christopher Desjardins
Hi, I am curious if the status of RWinEdt and WinEdt 6.0 has changed since this thread http://r.789695.n4.nabble.com/RWinEdt-in-WinEdt-6-td2174285.html Thanks for the help (especially Uwe Ligges for writing RWinEdt). Chris [[alternative HTML version deleted]]

[R] Change pattern in histograms in ggplot2

2011-05-18 Thread Christopher Desjardins
Hi, I am wondering if there is a way to change the pattern of the fill in histogram in ggplot2? By default the fill is solid and I'd like to add some sort of pattern to make it more visible that these are different levels of a factor. Thanks! Chris [[alternative HTML version deleted]] __

[R] Changing order of facet grid in ggplot2

2011-05-18 Thread Christopher Desjardins
Hi I am running the following code: sym <- c(sym1,sym2,sym4) lifedxm <- c("O-BD","O-WELL","O-UNI") life <- c(lifedxm,lifedxm,lifedxm) tp <- c("TP-ANY","TP-ANY", "TP-ANY", "TP-SUB", "TP-SUB", "TP-SUB", "TP-CLIN" , "TP-CLIN", "TP-CLIN") data <- data.frame(sym,life,tp) qplot(life,geom="bar",w

[R] Sweave and Textwrangler

2011-03-26 Thread Christopher Desjardins
Hi, I am trying to get TextWrangler to work with LaTeX and Sweave. Ideally I would call a script from TextWrangler that would run Sweave on a document, then LaTeX (using SyncTeX), and finally open the corresponding pdf in Skim. Of course I don't always need to run Sweave and would be looking for th

[R] Creating 3 vectors that sum to 1

2011-03-29 Thread Christopher Desjardins
I have 3 vectors: p1, p2, and p3. I would like each vector to be any possible value between 0 and 1 and p1 + p2 + p3 = 1. I want to graph these and I've thought about using scatterplot3d(). Here's what I have so far. library(scatterplot3d) p1 <- c(1,0,0,.5,.5,0,.5,.25,.25,.34,.33,.33,.8,.1,.1,.9,.

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Christopher Desjardins
generally you can generate n-tuples that sum to unity as: > > > > > > diff(c(0, sort(runif(n-1)), 1)) > > > > > > > > > Ravi. > > > > > > > > > > > > Ravi

[R] Quick recode of -999 to NA in R

2011-03-30 Thread Christopher Desjardins
Hi, I am trying to write a loop to recode my data from -999 to NA in R. What's the most efficient way to do this? Below is what I'm presently doing, which is inefficient. Thanks, Chris dat0 <- read.table("time1.dat") colnames(dat0) <- c("e1dq", "e1arcp", "e1dev", "s1prcp", "s1nrcp", "s1ints",

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Christopher Desjardins
x27;t at the time of my question or script writing. Thanks, Chris > > On Wed, Mar 30, 2011 at 10:15 AM, Christopher Desjardins > wrote: > > Hi, > > I am trying to write a loop to recode my data from -999 to NA in R. > What's > > the most efficient way to do this?

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Christopher Desjardins
On Wed, Mar 30, 2011 at 10:51 AM, peter dalgaard wrote: > > On Mar 30, 2011, at 16:05 , Christopher Desjardins wrote: > > >> > >> dat0 <- read.table('tim1.dat', na = -999) > >> > > > > Ah ... yes. I knew that but clearly didn&#

[R] Getting number of students with zeroes in long format

2011-04-06 Thread Christopher Desjardins
Hi, I have longitudinal school suspension data on students. I would like to figure out how many students (id_r) have no suspensions (sus), i.e. have a code of '0'. My data is in long format and the first 20 records look like the following: > suslm[1:20,c(1,7)] id_r sus 11 0 15 10 16

Re: [R] Getting number of students with zeroes in long format

2011-04-06 Thread Christopher Desjardins
On Wed, Apr 6, 2011 at 4:03 PM, Douglas Bates wrote: > On Wed, Apr 6, 2011 at 3:44 PM, Christopher Desjardins > wrote: > > Hi, > > I have longitudinal school suspension data on students. I would like to > > figure out how many students (id_r) have no suspensions (sus), i

Re: [R] Getting number of students with zeroes in long format

2011-04-07 Thread Christopher Desjardins
rote: > Hi Chris, > > Sorry I did not see your email before ;-) Here is one option: > > > r <- with(d, tapply(sus, id_r, function(x) any(x > 0))) > > r >111516181920212224252630 > 31 32 > FALSE TRUE FALSE FA

Re: [R] Getting number of students with zeroes in long format

2011-04-07 Thread Christopher Desjardins
On Thu, Apr 7, 2011 at 8:07 AM, Christopher Desjardins < cddesjard...@gmail.com> wrote: > Hi Jorge, > I want to make sure this does what I want. > > So I want to get a count of students that never get a suspension. Once a > student has a non-zero I don't want to count

[R] Plotting just a portion of a smoother graph in ggplot2

2011-08-04 Thread Christopher Desjardins
Hi, I am using ggplot2 to with the following code: gmathk2 <- qplot(time,math,colour=Kids,data=kids.ach.lm.k5,geom="smooth",method="lm",formula=y~ns(x,1)) + opts(title="Smoother Plot: Math K-5") + xlab("Time") + ylab("Math") + scale_colour_brewer(pal="Set1"); gmathk2 This plots all the smoother f

[R] Finding the column with the maximum value by row

2012-07-17 Thread Christopher Desjardins
Hi, Let's say I have the following data: > a=matrix(c(1,2,4,4,2,1,1,2,4),nrow=3,byrow=T) > a [,1] [,2] [,3] [1,]124 [2,]421 [3,]124 What syntax should I use to get R to tell me the column that corresponds to the maximum value for each row? For my exa

[R] Recoding several variables into one use the most recent data

2011-06-27 Thread Christopher Desjardins
Hi, I have the following data management issue. I am trying to combine multiple years of ethnicity data into one variable called ethnic. The data looks similar to the following idethnic07ethnic08 ethnic09ethnic10 1 1 1 11 2 1

[R] Confidence bands in ggplot2

2011-07-07 Thread Christopher Desjardins
Hi, I have the following data: > est sch190 sch107 sch290 sch256 sch287 sch130 sch139 4.16656026 2.64306071 4.22579866 6.12024789 4.49624748 11.12799127 1.17353917 sch140 sch282 sch161 sch193 sch156 sch288 sch352 3.

Re: [R] Confidence bands in ggplot2

2011-07-07 Thread Christopher Desjardins
', colour='red') + > geom_pointrange(aes(x=as.factor(sch), y=est, ymin=lower.95ci, > ymax=upper.95ci))+ > xlab('School') + ylab("Value-added")+theme_bw() > > > > > On 07/07/2011 05:55 PM, Christopher Desjardins wrote: >> Hi, &

[R] Suppressing the labelling of tick marks on ggplot2

2011-07-09 Thread Christopher Desjardins
Hi, I have the follow ggplot2 code I am running: ggplot(data=bb.res.math,aes(x=factor(id.bb),y=bb.math.comb,fill=BB)) + geom_bar() + facet_grid(BB~.) + scale_fill_brewer(pal="Set1") + ylab("Average Student Residual (Math)") + xlab("Student ID") The number of unique id.bb is 2207 and so my X-axi

[R] Changing ungrouped cases to grouped cases

2012-07-19 Thread Christopher Desjardins
Hi, I have my data the following way: y A B C 0 11 2 0 12 1 1 11 2 0 11 2 1 11 2 1 12 1 0 12 2 . . . And so on. How can I make my data look like the following: y A B C 2 1 1 2 1 1 2 1 0 1 2 2 . . .

Re: [R] Changing ungrouped cases to grouped cases

2012-07-20 Thread Christopher Desjardins
--- > David L Carlson > Associate Professor of Anthropology > Texas A&M University > College Station, TX 77843-4352 > > > -Original Message----- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org

Re: [R] Changing ungrouped cases to grouped cases

2012-07-20 Thread Christopher Desjardins
12 0 1 2 2 1 . . . So I would know there were 2 successes out of 4. Thanks! Chris On Fri, Jul 20, 2012 at 10:41 AM, Christopher Desjardins < cddesjard...@gmail.com> wrote: > Thanks the aggregate() command is what I was looking for. > Chris > > > On Thu, Ju

[R] hat matrix for zeroinfl and hurdle objects

2012-08-22 Thread Christopher Desjardins
Hi, I am wondering if there is an easy way to access the hat matrix for zeroinfl and hurdle objects in the pscl library? Thanks, Chris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

[R] SPSS F-test on change in R square between hierarchical models

2011-11-23 Thread Christopher Desjardins
Hi, I am wondering if anyone knows how to perform an F-test on the change in R square between hierarchical models in R? SPSS provides this information and a researcher that I am working with is interested in getting this information. Alternatively, if someone knows how I can calculate the test sta

[R] Simplifying my code

2011-11-27 Thread Christopher Desjardins
Hi, I have a pretty simple problem. Here is the code: dat1=complete(dat.mice,1) dat2=complete(dat.mice,2) dat3=complete(dat.mice,3) dat4=complete(dat.mice,4) dat5=complete(dat.mice,5) dat6=complete(dat.mice,6) dat7=complete(dat.mice,7) dat8=complete(dat.mice,8) dat9=complete(dat.mice,9) d

[R] For loops

2012-04-09 Thread Christopher Desjardins
Hi, I am having trouble with syntax for a for loop. Here is what I am trying to do. class=c(rep(1,3),rep(2,3),rep(3,3)) out1=rnorm(length(class)) out2=rnorm(length(class)) out3=rnorm(length(class)) data=data.frame(class,out1,out2,out3) dat.split=split(data,data$class) for(i in 1:3){ sub[i]=da

[R] Lambert (1992) simulation

2012-04-26 Thread Christopher Desjardins
Hi, I am trying to replicate Lambert (1992)'s simulation with zero-inflated Poisson models. The citation is here: @article{lambert1992zero, Author = {Lambert, D.}, Journal = {Technometrics}, Pages = {1--14}, Publisher = {JSTOR}, Title = {Zero-inflated {P}oisson regression, with an application to d

Re: [R] Lambert (1992) simulation

2012-04-27 Thread Christopher Desjardins
On Fri, Apr 27, 2012 at 1:53 AM, Achim Zeileis wrote: > On Thu, 26 Apr 2012, Christopher Desjardins wrote: > > Hi, >> I am trying to replicate Lambert (1992)'s simulation with zero-inflated >> Poisson models. The citation is here: >> >> @article{la

[R] Getting predicted values from a zero-inflated negative binomial using zeroinfl()

2012-05-05 Thread Christopher Desjardins
Hi, I am a little confused at the output from predict() for a zeroinfl object. Here's my confusion: ## From zeroinfl package fm_zinb2 <- zeroinfl(art ~ . | ., data = bioChemists, dist = "negbin") ## The raw zero-inflated overdispersed data > table(bioChemists$art) 0 1 2 3 4 5 6