Re: [R] Plotting interactions from lme with ggplot

2012-06-01 Thread dadrivr
Could somebody look at this? I'm new to ggplot, so any help would be greatly appreciated. I provided an example to facilitate. Thanks! dadrivr wrote I'm fitting a lme growth curve model with two predictors and their interaction as predictors. The multilevel model is nested so that level 1

[R] Plotting interactions from lme with ggplot

2012-05-26 Thread dadrivr
I'm fitting a lme growth curve model with two predictors and their interaction as predictors. The multilevel model is nested so that level 1 is time within the individual, and level 2 is the individual. I would like to plot the mean group-level trajectories at plus and minus 1 SD from the mean of

[R] Correlograms: using boxes and different variables on rows and columns

2012-05-25 Thread dadrivr
I'm trying to make correlograms using corrgram. See below for a simple example. library(corrgram) data(baseball) vars1 - c(Assists,Atbat,Errors,Hits,Homer,logSal) vars2 - c(Putouts,RBI,Runs,Walks,Years) corrgram(baseball[,vars2],lower.panel=panel.shade, upper.panel=panel.pie) I am

Re: [R] FIML in R

2012-04-07 Thread dadrivr
I completely agree that the development of full-information maximum likelihood (FIML) estimation for use in packages like lm, lme, lmer, etc. would make R much more attractive. FIML is better than other approaches to missing data (e.g., multiple imputation; see Graham, Olchowski, Gilreath,

[R] Remove quotes from a string to use in a variable call

2012-03-20 Thread dadrivr
Hi, I have a string that I want to use in a variable call. How can I remove the quotes and/or the string properties of the string to use it in a variable call? Here's an example: library(lme) fm2 - lme(distance ~ age, data = Orthodont, random = ~ 1) summary(fm2) I want to update the above

[R] Calculating Pseudo R-squared from nlme

2012-02-23 Thread dadrivr
I am fitting individual growth models using nlme (multilevel models with repeated measurements nested within the individual), and I am trying to calculate the Pseudo R-squared for the models (an overall summary of the total outcome variability explained). Singer and Willett (2003) recommend

[R] Running Amelia with parallel processors in Windows

2012-02-21 Thread dadrivr
Hi, I want to impute a data set multiple times with Amelia, but the data set is large so it takes a long time. As a result, I'm trying to run the multiple imputation with parallel processors in Windows, but am having trouble. Here is a quick example: ## library(foreach) library(doSNOW)

[R] Keep rows where a variable matches one item of a vector

2012-01-12 Thread dadrivr
How do I subset data to only keep those rows of a dataframe where a variable's value matches one item of a vector. For example, how do I keep all of the rows (and all variables) where mydata$id equals one of the values in keepid? See below? mydata - NULL mydata$id - 1:30 mydata$value -

Re: [R] Problem with by statement for spaghetti plots

2011-09-07 Thread dadrivr
Bump, please help! -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-by-statement-for-spaghetti-plots-tp3788536p3796131.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] Change properties of line summary in interaction.plot

2011-09-07 Thread dadrivr
Can anybody help me with this? -- View this message in context: http://r.789695.n4.nabble.com/Change-properties-of-line-summary-in-interaction-plot-tp3788614p3796133.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

[R] Reshaping data from wide to tall format for multilevel modeling

2011-09-07 Thread dadrivr
Hi, I'm trying to reshape my data set from wide to tall format for multilevel modeling. Unfortunately, the function I typically use (make.univ from the multilevel package) does not appear to work with unbalanced data frames, which is what I'm dealing with. Below is an example of the columns of

Re: [R] Problem with by statement for spaghetti plots

2011-09-07 Thread dadrivr
Sorry, I thought the link would work for people because it is a public link and it works for me when I run it in R. Anyways, here is an example set of data that I am having trouble with: /id - c(230017,230017,230017,230018,230018,230018,230019,230019,230019,230020,230020,

Re: [R] Change properties of line summary in interaction.plot

2011-09-07 Thread dadrivr
Here's an example: /id - c(17,17,17,18,18,18,19,19,19,20,20,20,21,21,21,22,22,22,23,23,23,24, 24,24,25,25,25,26,26,26) age - rep(c(30,36,42),10) outcome - c(12,17,10,5,5,2,NA,NA,NA,8,6,5,11,13,10,15,11,15,13,NA,9,0,0,0,20, 14,16,1,2,2) mydata -

Re: [R] Change properties of line summary in interaction.plot

2011-09-07 Thread dadrivr
David Winsemius wrote: What mean summary line? I count 8 lines and that matches the number if id's with complete data. Yea, I don't know why there is no mean summary line showing up. I requested it in the interaction.plot statement (fun = mean), and I don't get any errors. Any ideas? --

Re: [R] Change properties of line summary in interaction.plot

2011-09-07 Thread dadrivr
,age,outcome)) interaction.plot(mydata$age, mydata$id, mydata$outcome, fun = mean, legend = FALSE, lty = 1, xtick = TRUE, type = l) How can I make the 'mean' summary line red and thicker? David Winsemius wrote: On Sep 7, 2011, at 4:49 PM, dadrivr wrote: David Winsemius wrote: What mean

[R] Problem with by statement for spaghetti plots

2011-09-03 Thread dadrivr
Hi, I am trying to apply the example at the bottom of the following page to my own data: http://128.97.141.26/stat/R/faq/spagplot.htm http://128.97.141.26/stat/R/faq/spagplot.htm The code from the example is: /tolerance-read.table(http://www.ats.ucla.edu/stat/R/faq/tolpp.csv,sep=,;, header=T)

[R] Change properties of line summary in interaction.plot

2011-09-03 Thread dadrivr
Is it possible to change the color/thickness of the summary line in an interaction.plot without changing the other individual data lines? I would like to make the line from the summary function (mean) the color red and thicker than the surrounding black lines. How can I do that? Here is a link

Re: [R] Plotting individual trajectories from individual growth model

2011-02-23 Thread dadrivr
Thanks guys, I had to change two things to get it to work: 1. As Dennis pointed out, all of the variables in the model had to be variable names in the preds data frame. 2. I had to use na.pass in the following statement to be able to merge the predicted values with the preds data frame because

Re: [R] Plotting individual trajectories from individual growth model

2011-02-22 Thread dadrivr
Thanks Dennis, The code works for perfectly for the data in the example. For some reason, however, I get the following error message when I use a different data set: preds - expand.grid(age = c(30,36,42), Subject = unique(mydata$id)) predict(lmemodel, preds, na.action=na.omit) Error in

Re: [R] Plotting individual trajectories from individual growth model

2011-02-21 Thread dadrivr
Hi Dennis, That's very helpful. The plot appears appears to be of the data and not the fitted linear trajectories, however, as the lines are not linear. Is it possible to plot the fitted linear trajectories (according to the fixed/random intercepts and slopes of the lme model)? Thanks again!

[R] Plotting individual trajectories from individual growth model

2011-02-20 Thread dadrivr
Hi all, I am trying to plot the fitted trajectories for each individual from an individual growth model (fit with a linear mixed effects model in lme). How can I plot each person's trajectory in the *same* panel, along with the mean-level trajectory? Below is an image of a plot similar to what

Re: [R] Creating publication-quality plots for use in Microsoft Word

2010-09-16 Thread dadrivr
Thanks for all the suggestions, guys. It looks like TIFF may be the easiest solution, as I wouldn't have to worry about printing to a postscript printer or converting to PDF (when using EPS). That way, I could send the Word file as is to all coauthors (important for collaboration - i.e., track

[R] Creating publication-quality plots for use in Microsoft Word

2010-09-15 Thread dadrivr
Hi everyone, I am trying to make some publication-quality plots for use in Microsoft Word, but I am having trouble creating high-quality plots that are supported by Microsoft Word. If I use the R plot function to create the figure, the lines are jagged, and the picture is not of high quality

Re: [R] Creating publication-quality plots for use in Microsoft Word

2010-09-15 Thread dadrivr
Thanks for your help, guys. I'm looking to produce a high-quality plot (no jagged lines or other distortions) with a filetype that is accepted by Microsoft Word on a PC and that most journals will accept. That's why I'd prefer to stick with JPEG, TIFF, PNG, or the like. I'm not sure EPS would

Re: [R] Multilevel modeling with count variables

2010-03-27 Thread dadrivr
Thanks everyone for the helpful ideas. It appears that this will be more difficult than I thought. I don't necessary have an inclination toward p-values, but many journals certainly do. I would be willing to try to calculate the confidence intervals around the estimates, but I haven't gotten

[R] Multilevel modeling with count variables

2010-03-26 Thread dadrivr
I am using a multilevel modeling approach to model change in a person's symptom score over time (i.e., longitudinal individual growth models). I have been using the lme function in the multilevel package for the analyses, but my problem is that my outcome (symptoms) and one of my predictors

Re: [R] Multilevel modeling with count variables

2010-03-26 Thread dadrivr
By the way, my concern with lmer and glmer is that they don't produce p-values, and the techniques used to approximate the p-values with those functions (pvals.fnc, HPDinterval, mcmcsamp, etc.) only apply to Gaussian distributions. Given that I would likely be working with quasi-poisson

[R] Plot interaction in multilevel model

2010-03-05 Thread dadrivr
I am trying to plot an interaction in a multilevel model. Here is some sample data. In the following example, it is longitudinal (i.e., repeated measures), so the outcome, score (at each of the three time points), is nested within the individual. I am interested in the interaction between

[R] Reshape a data set

2009-12-13 Thread dadrivr
I am trying to reshape a data set. Could someone please help me with the reshape, cast, and melt functions? I am new to R and I have tried reading up on how to use the reshape package, but I am very confused. Here is an example of what I am trying to do: subject coder score time [1,]

Re: [R] Partial correlations and p-values

2009-12-01 Thread dadrivr
? Is something wrong with my formula in R? Any help would be greatly appreciated. Thanks! Peter Ehlers wrote: dadrivr wrote: The variables have the same length, but with different numbers of missing values (NA). As a result, the residuals calculations (xres yres) have different lengths, and I

[R] Export to SPSS without truncating variable names

2009-11-21 Thread dadrivr
I am trying to export a data frame to SPSS. I am using write.foreign to export the .txt data file and the .sps SPSS syntax file to read the .txt file into SPSS. I am running into problems because my data set includes variable names that are longer than 8 characters, and the write.foreign

Re: [R] Partial correlations and p-values

2009-11-12 Thread dadrivr
, Nov 11, 2009 at 10:34 PM, dadrivr dadr...@gmail.com wrote: Awesome, that's what I was looking for.  I have two additional questions: (1) What can I do if the variables are of different lengths? (2) How do I update the formula if I want to control for more than one variable. Let's take

[R] Partial correlations and p-values

2009-11-11 Thread dadrivr
I'm trying to write code to calculate partial correlations (along with p-values). I'm new to R, and I don't know how to do this. I have searched and come across different functions, but I haven't been able to get any of them to work (for example, pcor and pcor.test from the ggm package). In

Re: [R] Partial correlations and p-values

2009-11-11 Thread dadrivr
the residuals. (2) control for z and a (i.e., more than one variable)? Thanks so much for your help. Peter Ehlers wrote: dadrivr wrote: I'm trying to write code to calculate partial correlations (along with p-values). I'm new to R, and I don't know how to do this. I have searched and come

Re: [R] convert list to numeric

2009-11-02 Thread dadrivr
[[i]] instead of task[i] b On Nov 1, 2009, at 11:04 PM, dadrivr wrote: I would like to preface this by saying that I am new to R, so I would ask that you be patient and thorough, so that I'm not completely clueless. I am trying to convert a list to numeric so that I can perform

[R] convert list to numeric

2009-11-01 Thread dadrivr
I would like to preface this by saying that I am new to R, so I would ask that you be patient and thorough, so that I'm not completely clueless. I am trying to convert a list to numeric so that I can perform computations on it (specifically mean-center the variable), but I am running into