Survey Data - comparing multiple groups

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Survey Data - comparing multiple groups

Mavra Ahmed
Hi Everyone,


I am trying to assess whether the mean of carbohydrate intake (dependent variable = continuous) is significantly different between five groups (groups = people categorized into five different groups) (independent variable= categorical). This is survey data with replicates and therefore I have changed the structure of the data to svyrepdesign.


I have ran Kruskal Wallis as follows but get the following error:

svyranktest(CARB ~ group, df, test=c("KruskalWallis"))


> Error in if (this.n == 1 && !this.certain) { :

  missing value where TRUE/FALSE needed


I also ran svyglm but am unable to conduct this test to look at comparisons between groups:

summary(svyglm(CARB ~ group, design=df, family=gaussian))


I would like to be able to get p-values between the groups and be able to adjust for multiple comparisons and would appreciate if someone can guide me.


I appreciate your help.


Thanks,

Mav



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Survey Data - comparing multiple groups

Abby Spurdle
> I have ran Kruskal Wallis as follows but get the following error:
> svyranktest(CARB ~ group, df, test=c("KruskalWallis"))

From the survey package, I assume.
And df is a data frame, I also assume.
(Complete self-contained examples are good).

I checked the documentation.
The second argument is not a data frame.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Survey Data - comparing multiple groups

Mavra Ahmed
Thanks, Abby.


Apologies, I did convert my df into a svrepdesign object as follows:

df<-svrepdesign (data=df1, scale=1, repweights = df1[, 496:995], type="BRR", combined.weights=TRUE, weight=~WTS_P, na.rm=TRUE)


 therefore, I have called "df" as a svrepdesign however, from the survey package, the svyranktest is shown  with svydesign only and not with svrepdesign. I could consider using other tests such as svyglm but am also having issues with it.


Thank you,

Mav


________________________________
From: Abby Spurdle <[hidden email]>
Sent: July 25, 2019 9:48:05 PM
To: Mavra Ahmed <[hidden email]>
Cc: [hidden email] <[hidden email]>
Subject: Re: [R] Survey Data - comparing multiple groups

> I have ran Kruskal Wallis as follows but get the following error:
> svyranktest(CARB ~ group, df, test=c("KruskalWallis"))

From the survey package, I assume.
And df is a data frame, I also assume.
(Complete self-contained examples are good).

I checked the documentation.
The second argument is not a data frame.



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Survey Data - comparing multiple groups

Abby Spurdle
> I would like to be able to get p-values between the groups and be able to
adjust for multiple comparisons and would appreciate if someone can guide
me.

> I did convert my df into a svrepdesign object as follows:
> > df<-svrepdesign (data=df1, scale=1, repweights = df1[, 496:995],
type="BRR", combined.weights=TRUE, weight=~WTS_P, na.rm=TRUE)
>  therefore, I have called "df" as a svrepdesign however, from the survey
package, the svyranktest is shown  with svydesign only and not with
svrepdesign. I could consider using other tests such as svyglm but am also
having issues with it.

This is outside my area.
However, as no one else as responded, I'll offer some more comments.

Firstly, I'm doubtful the Kruskal Wallis test will give you pairwise
p-values.
There are other tests for this.
It's also possible to create a matrix of p-values, using an arbitrary test,
and then use a correction method.
However, I recommend caution with this.

Secondly, I don't know if the svyranktest() function will work with the
svrepdesign object or not.
However, if not, I would assume that other functions in the package would
work.

Either way, I'm wondering if you've created the svrepdesign object
correctly.
In particular, "weight=~WTS_P" would assign a formula to weights, probably,
which doesn't sound right.
And "repweights = df1[, 496:995]" looks questionable, because one, is has
hundreds of columns, and two, you've already given that data in the first
argument.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Survey Data - comparing multiple groups

Mavra Ahmed
Thank you so much for your response and apologies for the delay in responding. This has been helpful.


I have been looking into several other options over the last few weeks and been talking with statisticians as well and SAS seems to have some options that work for survey type of data. At this point, I am still exploring R and if I am able to provide additional feedback on this issue, I will post. I really appreciate your help. Thank you.


________________________________
From: Abby Spurdle <[hidden email]>
Sent: July 27, 2019 9:39:49 PM
To: Mavra Ahmed <[hidden email]>
Cc: [hidden email] <[hidden email]>
Subject: Re: [R] Survey Data - comparing multiple groups

> I would like to be able to get p-values between the groups and be able to adjust for multiple comparisons and would appreciate if someone can guide me.

> I did convert my df into a svrepdesign object as follows:
> > df<-svrepdesign (data=df1, scale=1, repweights = df1[, 496:995], type="BRR", combined.weights=TRUE, weight=~WTS_P, na.rm=TRUE)
>  therefore, I have called "df" as a svrepdesign however, from the survey package, the svyranktest is shown  with svydesign only and not with svrepdesign. I could consider using other tests such as svyglm but am also having issues with it.

This is outside my area.
However, as no one else as responded, I'll offer some more comments.

Firstly, I'm doubtful the Kruskal Wallis test will give you pairwise p-values.
There are other tests for this.
It's also possible to create a matrix of p-values, using an arbitrary test, and then use a correction method.
However, I recommend caution with this.

Secondly, I don't know if the svyranktest() function will work with the svrepdesign object or not.
However, if not, I would assume that other functions in the package would work.

Either way, I'm wondering if you've created the svrepdesign object correctly.
In particular, "weight=~WTS_P" would assign a formula to weights, probably, which doesn't sound right.
And "repweights = df1[, 496:995]" looks questionable, because one, is has hundreds of columns, and two, you've already given that data in the first argument.



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.