[R] how to successfully remove missing values for a repeated measures analysis

Sean O'Riordain seanpor at acm.org
Tue Jun 20 07:30:39 CEST 2006


Spencer,

A number of times I've been wrecking my head trying to solve a
problem, and when I thought I'd tried everything possible (all the
docs that I can think of, web searches etc...) I start re-reading the
posting guide (I've no idea how many times I've read it now)... and 9
times out of 10, the answer is there for me... :-)

Like yesterday... I had forgotten about the posting-guide (why Sean?
why?) and I was trying to get windows to startup with a default entry
for CRAN so I don't have to select *everytime*... which was starting
to annoy me... a lot... eventually after running out of options I
started down the posting guide route... and it turns out I've been
starting using "--vanilla", so I turned that off and hey presto... it
worked... :-)

Takeaway... now I read the posting guide earlier in the problem
solving process :-)

cheers,
Sean


On 20/06/06, Spencer Graves <spencer.graves at pdf.com> wrote:
>           I don't see enough information for me to diagnose the problem.   If
> it were my problem, I'd print out some assessment of the results of
> every step you've described below.  This should expose the step in which
> things disappear.
>
>           Hope this helps.
>           Spencer Graves
> p.s.  I almost never attach a data.frame.  It can be done, but I just
> find the mechanisms too subtle for my brain.  I use "with" routinely,
> but I know I can't include an assignment inside "with", because "with"
> creates a frame and then discards it after it's done.  Anything I
> created inside "with" gets thereby discarded.
>
> p.p.s.  If you'd like more help from this listserve, PLEASE do read the
> posting guide! "www.R-project.org/posting-guide.html".  People who
> follow that posting guide seem more likely to solve their own problems
> in the process of preparing a question for the listserve.  If that
> fails, they are more likely to get a useful reply quickly.  Clean, crisp
> questions sometimes generate a feeding frenzy of replies.  Questions
> that are harder to understand often get ignored.
>
> Bob Green wrote:
> > Hello ,
> >
> > I am hoping for some advice. I want to run a repeated measures ANOVA. The
> > primary problem is that my attempt to remove missing values created a
> > dataset of missing values.
> >
> > The data set consists of 92 rows (1 row per participant) x 186 variables.
> >
> > The steps of the analysis undertaken are outlined below (#). Any assistance
> > is appreciated in relation to how to remove the missing values so the
> > analysis is run. Feedback regarding the prior steps is also welcomed .
> >
> > Bob Green
> >
> >
> >
> > #Step 1
> >
> > study1dat <- read.csv("c:\\study1.csv",header=T)
> > attach (study1dat)
> >
> > outcome <- c(t1frq, t2frq,t3frq,t4frq)
> > grp <- factor( rep(group, 2,length=368) )
> > time <- gl(4,92,length=368)
> > subject <- gl(92,1,length=368)
> > data.frame(subject, grp, time, outcome)
> >
> > # there are 3 missing values in $outcome
> >
> > #Step 2 - create a new data frame removing missing values from variable
> > $outcome
> >
> >   d2<-study1dat[!is.na(outcome),]
> >
> > #the previous step generates NA values.
> >
> > #Step 3 detach original data set & attach dataset without missing values
> > detach(study1dat)
> >
> > attach(d2)
> >
> > The following object(s) are masked _by_ .GlobalEnv :         time
> >          The following object(s) are masked from package:datasets
> > :         sleep
> >
> > #Step 4 run analysis
> >
> > library(nlme)
> > anova(lme(outcome ~ grp * time, random = ~ 1 | subject))
> >
> > #The data is the format below
> >
> >      subject grp time outcome
> > 1         1   0    1       4
> > 2         2   0    1       3
> > 3         3   0    1       7
> > 4         4   0    1       0
> > 5         5   0    1       1
> > 6         6   0    1       7
> > 7         7   0    1       7
> > 8         8   0    1       7
> > 9         9   0    1       7
> > 10       10 0    1      5
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list