Nick Petschek
2015-Sep-04 21:27 UTC
[R] Composite index reliability questions - cronbach()
Hi All, I have two questions on using cronbach() from the psy() package. My simplified situation is the following: I have a survey of 10 questions (column names are "Q1", "Q2", etc.) that went out to 100+ people. I have the responses to the questions, plus additional variables (demographics, location, etc.) in a data frame (named "JDC"). I want to build composite indices from these 10 questions. I plan to use two steps to create the indices. First, grouping the questions by what makes intuitive sense given what they ask, and second, by testing the reliability of these groupings using cronbach(). QUESTION 1 Let's say I think Q1, Q3, and Q5 will make a good index. With my limited knowledge of R, I would think there's a way to say "run the reliability on these three variables in this dataframe". However, I have so far only been able to test the reliability of *adjacent *variables. For example, I could do: *cronbach(jdc[,1:3])* to test Q1, Q2, and Q3. Is there a way to test non-adjacent variables? I realize I could do something like: *trust <- jdc[, c("Q2", "Q7", "Q8")]* *cronbach(trust)* but that adds a few extra steps, and I have tons of questions and indices which would make that very cumbersome, especially since I will go through several iterations in testing potential indices. QUESTION 2 Is there a way to refer to the column name when using cronbach(), instead of just the location of the variable? For example: This works: *cronbach(jdc[,1:3])* This doesn't:* cronbach(jdc[Q1, Q2, Q3])* Thanks in advance for any insights, answers, words of encouragement, or alternate ways I could solve this puzzle. Nick [[alternative HTML version deleted]]
Hi Nick, If you haven't just made a typo on your example in QUESTION 2, the "This doesn't" line should read: cronbach(jdc[,c("Q1","Q2","Q3")]) Without the quotes, R looks for three objects named Q1, Q2 and Q3 and probably doesn't find them. Jim On Sat, Sep 5, 2015 at 7:27 AM, Nick Petschek <nick.petschek at gmail.com> wrote:> Hi All, > > I have two questions on using cronbach() from the psy() package. > > My simplified situation is the following: I have a survey of 10 questions > (column names are "Q1", "Q2", etc.) that went out to 100+ people. I have > the responses to the questions, plus additional variables (demographics, > location, etc.) in a data frame (named "JDC"). I want to build composite > indices from these 10 questions. I plan to use two steps to create the > indices. First, grouping the questions by what makes intuitive sense given > what they ask, and second, by testing the reliability of these groupings > using cronbach(). > > QUESTION 1 > > Let's say I think Q1, Q3, and Q5 will make a good index. With my limited > knowledge of R, I would think there's a way to say "run the reliability on > these three variables in this dataframe". However, I have so far only been > able to test the reliability of *adjacent *variables. For example, I could > do: > > *cronbach(jdc[,1:3])* > > to test Q1, Q2, and Q3. Is there a way to test non-adjacent variables? > > I realize I could do something like: > > *trust <- jdc[, c("Q2", "Q7", "Q8")]* > *cronbach(trust)* > > but that adds a few extra steps, and I have tons of questions and indices > which would make that very cumbersome, especially since I will go through > several iterations in testing potential indices. > > > QUESTION 2 > > Is there a way to refer to the column name when using cronbach(), instead > of just the location of the variable? For example: > > This works: *cronbach(jdc[,1:3])* > This doesn't:* cronbach(jdc[Q1, Q2, Q3])* > > > Thanks in advance for any insights, answers, words of encouragement, or > alternate ways I could solve this puzzle. > > Nick > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]
Nick Petschek
2015-Sep-05 16:09 UTC
[R] Composite index reliability questions - cronbach()
Thanks, Jim! The lack of quotes was a typo, but what was not was my forgetting to include the "c(" function... Thanks! On Sat, Sep 5, 2015 at 7:23 AM, Jim Lemon <drjimlemon at gmail.com> wrote:> Hi Nick, > If you haven't just made a typo on your example in QUESTION 2, the "This > doesn't" line should read: > > cronbach(jdc[,c("Q1","Q2","Q3")]) > > Without the quotes, R looks for three objects named Q1, Q2 and Q3 and > probably doesn't find them. > > Jim > > > On Sat, Sep 5, 2015 at 7:27 AM, Nick Petschek <nick.petschek at gmail.com> > wrote: > >> Hi All, >> >> I have two questions on using cronbach() from the psy() package. >> >> My simplified situation is the following: I have a survey of 10 questions >> (column names are "Q1", "Q2", etc.) that went out to 100+ people. I have >> the responses to the questions, plus additional variables (demographics, >> location, etc.) in a data frame (named "JDC"). I want to build composite >> indices from these 10 questions. I plan to use two steps to create the >> indices. First, grouping the questions by what makes intuitive sense given >> what they ask, and second, by testing the reliability of these groupings >> using cronbach(). >> >> QUESTION 1 >> >> Let's say I think Q1, Q3, and Q5 will make a good index. With my limited >> knowledge of R, I would think there's a way to say "run the reliability on >> these three variables in this dataframe". However, I have so far only been >> able to test the reliability of *adjacent *variables. For example, I could >> do: >> >> *cronbach(jdc[,1:3])* >> >> to test Q1, Q2, and Q3. Is there a way to test non-adjacent variables? >> >> I realize I could do something like: >> >> *trust <- jdc[, c("Q2", "Q7", "Q8")]* >> *cronbach(trust)* >> >> but that adds a few extra steps, and I have tons of questions and indices >> which would make that very cumbersome, especially since I will go through >> several iterations in testing potential indices. >> >> >> QUESTION 2 >> >> Is there a way to refer to the column name when using cronbach(), instead >> of just the location of the variable? For example: >> >> This works: *cronbach(jdc[,1:3])* >> This doesn't:* cronbach(jdc[Q1, Q2, Q3])* >> >> >> Thanks in advance for any insights, answers, words of encouragement, or >> alternate ways I could solve this puzzle. >> >> Nick >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > >[[alternative HTML version deleted]]