euthymios kasvikis
2018-Aug-03 21:29 UTC
[R] Perform GEE regression in R with multiple dependent variables
Im trying to perform generalized estimating equation (GEE) on the (sample)
dataset below with R and I would like some little guidance. First of all I
will describe my dataset. As you can see below it includes 5 variables.
Country_ID shows the country of the politician, Ideo_Ordinal his poltical
belief from 1 to 7 (far left to far right). Then we have measurements
regarding three characteristics. I would like to run an analysis based on
the country and the political beliefs of every politician (dependent
variables) in relation with the 3 characteristics. I have used the geepack
package using:
library(geepack)
samplem<-coef(summary(geeglm(sample$Ideo_Ordinal
~Machiavellianism+Psychopathy+Narcissism ,data = sample, id sample$Ideo_Ordinal,
corstr = "independence")))
%>%
rownames_to_column() %>%
mutate(lowerWald = Estimate-1.96*Std.err, # Lower Wald CI
upperWald=Estimate+1.96*Std.err, # Upper Wald CI
df=1,
ExpBeta = exp(Estimate)) %>% # Transformed estimate
mutate(lWald=exp(lowerWald), # Upper transformed
uWald=exp(upperWald)) # Lower transformed
samplem
I would like to know if it is valid to add in this method the Country_ID
simultaneously with Ideo_Ordinal and how to do it.
Country_ID Ideo_Ordinal Machiavellianism Narcissism Psychopathy
3 1 3 0.250895132 0.155238716 0.128683755
5 1 3 -0.117725000 -0.336256435 -0.203137879
7 1 3 0.269509029 -0.260728261 0.086819555
9 1 6 0.108873496 0.175528190 0.182884928
14 1 3 0.173129951 0.054468468 0.155030794
15 1 6 -0.312088872 -0.414358301 -0.212599946
17 1 3 -0.297647658 -0.096523143 -0.228533352
18 1 3 -0.020389157 -0.210180866 -0.046687695
20 1 3 -0.523432382 -0.125114982 -0.431070629
21 1 1 0.040304508 0.022743463 0.233657881
22 1 3 0.253695988 -0.330825166 0.101122320
23 1 3 -0.478673895 -0.421801231 -0.422894791
27 1 6 -0.040856419 -0.566728704 -0.136069484
28 1 3 0.240040249 -0.398404825 0.135603114
29 1 6 -0.207631653 -0.005347621 -0.294935155
30 1 3 0.458042533 0.462935386 0.586244831
31 1 3 -0.259850232 -0.233074787 -0.092249465
33 1 3 0.002164223 -0.637668706 -0.267158031
34 1 6 0.050991955 -0.098030021 -0.043826848
36 1 3 -0.338052871 -0.168894328 -0.230198200
38 1 3 0.174382347 0.023807812 0.192963609
41 2 3 -0.227322148 -0.010016330 -0.095576329
42 2 3 -0.267514920 0.066108837 -0.218979873
43 2 3 0.421277754 0.385223920 0.421274111
44 2 3 -0.399592341 -0.498154998 -0.320402699
45 2 1 0.162038344 0.328116118 0.104105963
47 2 3 -0.080755709 0.003080287 -0.043568723
48 2 3 0.059474124 -0.447305420 0.003988071
49 2 3 -0.219773040 -0.312902659 -0.239057883
51 2 3 0.438659431 0.364042111 0.393014172
52 2 3 -0.088560903 -0.490889275 -0.006041054
53 2 3 -0.122612591 0.074438944 0.103722836
54 2 3 -0.450586055 -0.304253061 -0.132365179
55 2 6 -0.710545197 -0.451329850 -0.764201786
56 2 3 0.330718447 0.335460128 0.429173481
57 2 3 0.442508023 0.297522144 0.407155726
60 2 3 0.060797815 -0.096516876 -0.012802977
61 2 3 -0.250757764 -0.113219864 -0.215345379
62 2 1 0.153654345 -0.089615287 0.118626045
65 2 3 0.042969508 -0.486999608 -0.080829636
66 3 3 0.158337022 0.208229002 0.241607154
67 3 3 0.220237408 0.397914524 0.262207709
69 3 3 0.200558577 0.244419633 0.301732113
71 3 3 0.690244689 0.772692418 0.625921098
72 3 3 0.189810070 0.377774321 0.293988340
73 3 3 -0.385724422 -0.262131032 -0.373159652
74 3 3 -0.124095769 -0.109816334 -0.127157915
75 3 1 0.173299879 0.453592671 0.325357383
76 3 3 -0.598215129 -0.643286651 -0.423824759
77 3 3 -0.420558406 -0.361763025 -0.465612116
78 3 3 -0.176788569 -0.305506924 -0.203730879
80 3 3 -0.114790731 0.262392918 0.061382073
81 3 3 -0.274904173 -0.342603918 -0.302761994
82 3 3 -0.146902101 -0.059558818 -0.120550957
84 3 3 0.038303792 -0.139833875 0.170005914
85 3 3 -0.220212221 -0.541399757 -0.555201764
87 3 3 0.255300386 0.179484246 0.421428096
88 3 6 -0.548823069 -0.405541620 -0.322935805
[[alternative HTML version deleted]]
Duncan Mackay
2018-Aug-06 04:29 UTC
[R] Perform GEE regression in R with multiple dependent variables
Hi
Please read the geepack manual carefully.
GEE ordinal regression is not simple.
You need to format your data and do not use sample as a storage name. It is
the name of a function
dta is storage
dta$Ideo_Ordinal <- ordered(factor(dta$Ideo_Ordinal))
m0 <-
ordgee(Ideo_Ordinal ~ Machiavellianism+Psychopathy+Narcissism ,data = dta,
id = Country_ID,
corstr = "independence")
You need to see if the model is appropriate first and whether the sandwich
errors are right before you go further
If this is your data you may not get credible results.
You need to read up on the requirements of GEEs and ordinal GEEs in
particular
There are a number of packages with different data requirements and methods
If you have repeated measurements repolr; ?multgee (just from memory)
Small sample sizes are a problem there are a number of packages dealing with
this but you will have to see which is best for you
Many do not offer a method for ordinal or multinomial GEE.
One further question to ask population specific or subject specific ie to
GEE or not to GEE
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2350
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of euthymios
kasvikis
Sent: Saturday, 4 August 2018 07:30
To: r-help at r-project.org
Subject: [R] Perform GEE regression in R with multiple dependent variables
Im trying to perform generalized estimating equation (GEE) on the (sample)
dataset below with R and I would like some little guidance. First of all I
will describe my dataset. As you can see below it includes 5 variables.
Country_ID shows the country of the politician, Ideo_Ordinal his poltical
belief from 1 to 7 (far left to far right). Then we have measurements
regarding three characteristics. I would like to run an analysis based on
the country and the political beliefs of every politician (dependent
variables) in relation with the 3 characteristics. I have used the geepack
package using:
library(geepack)
samplem<-coef(summary(geeglm(sample$Ideo_Ordinal
~Machiavellianism+Psychopathy+Narcissism ,data = sample, id sample$Ideo_Ordinal,
corstr = "independence")))
%>%
rownames_to_column() %>%
mutate(lowerWald = Estimate-1.96*Std.err, # Lower Wald CI
upperWald=Estimate+1.96*Std.err, # Upper Wald CI
df=1,
ExpBeta = exp(Estimate)) %>% # Transformed estimate
mutate(lWald=exp(lowerWald), # Upper transformed
uWald=exp(upperWald)) # Lower transformed
samplem
I would like to know if it is valid to add in this method the Country_ID
simultaneously with Ideo_Ordinal and how to do it.
Country_ID Ideo_Ordinal Machiavellianism Narcissism Psychopathy
3 1 3 0.250895132 0.155238716 0.128683755
5 1 3 -0.117725000 -0.336256435 -0.203137879
7 1 3 0.269509029 -0.260728261 0.086819555
9 1 6 0.108873496 0.175528190 0.182884928
14 1 3 0.173129951 0.054468468 0.155030794
15 1 6 -0.312088872 -0.414358301 -0.212599946
17 1 3 -0.297647658 -0.096523143 -0.228533352
18 1 3 -0.020389157 -0.210180866 -0.046687695
20 1 3 -0.523432382 -0.125114982 -0.431070629
21 1 1 0.040304508 0.022743463 0.233657881
22 1 3 0.253695988 -0.330825166 0.101122320
23 1 3 -0.478673895 -0.421801231 -0.422894791
27 1 6 -0.040856419 -0.566728704 -0.136069484
28 1 3 0.240040249 -0.398404825 0.135603114
29 1 6 -0.207631653 -0.005347621 -0.294935155
30 1 3 0.458042533 0.462935386 0.586244831
31 1 3 -0.259850232 -0.233074787 -0.092249465
33 1 3 0.002164223 -0.637668706 -0.267158031
34 1 6 0.050991955 -0.098030021 -0.043826848
36 1 3 -0.338052871 -0.168894328 -0.230198200
38 1 3 0.174382347 0.023807812 0.192963609
41 2 3 -0.227322148 -0.010016330 -0.095576329
42 2 3 -0.267514920 0.066108837 -0.218979873
43 2 3 0.421277754 0.385223920 0.421274111
44 2 3 -0.399592341 -0.498154998 -0.320402699
45 2 1 0.162038344 0.328116118 0.104105963
47 2 3 -0.080755709 0.003080287 -0.043568723
48 2 3 0.059474124 -0.447305420 0.003988071
49 2 3 -0.219773040 -0.312902659 -0.239057883
51 2 3 0.438659431 0.364042111 0.393014172
52 2 3 -0.088560903 -0.490889275 -0.006041054
53 2 3 -0.122612591 0.074438944 0.103722836
54 2 3 -0.450586055 -0.304253061 -0.132365179
55 2 6 -0.710545197 -0.451329850 -0.764201786
56 2 3 0.330718447 0.335460128 0.429173481
57 2 3 0.442508023 0.297522144 0.407155726
60 2 3 0.060797815 -0.096516876 -0.012802977
61 2 3 -0.250757764 -0.113219864 -0.215345379
62 2 1 0.153654345 -0.089615287 0.118626045
65 2 3 0.042969508 -0.486999608 -0.080829636
66 3 3 0.158337022 0.208229002 0.241607154
67 3 3 0.220237408 0.397914524 0.262207709
69 3 3 0.200558577 0.244419633 0.301732113
71 3 3 0.690244689 0.772692418 0.625921098
72 3 3 0.189810070 0.377774321 0.293988340
73 3 3 -0.385724422 -0.262131032 -0.373159652
74 3 3 -0.124095769 -0.109816334 -0.127157915
75 3 1 0.173299879 0.453592671 0.325357383
76 3 3 -0.598215129 -0.643286651 -0.423824759
77 3 3 -0.420558406 -0.361763025 -0.465612116
78 3 3 -0.176788569 -0.305506924 -0.203730879
80 3 3 -0.114790731 0.262392918 0.061382073
81 3 3 -0.274904173 -0.342603918 -0.302761994
82 3 3 -0.146902101 -0.059558818 -0.120550957
84 3 3 0.038303792 -0.139833875 0.170005914
85 3 3 -0.220212221 -0.541399757 -0.555201764
87 3 3 0.255300386 0.179484246 0.421428096
88 3 6 -0.548823069 -0.405541620 -0.322935805
[[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.
euthymios kasvikis
2018-Aug-06 15:00 UTC
[R] Perform GEE regression in R with multiple dependent variables
First of all thanks for your advice. So suppose that I would like to use
the multgee package. The model would be like:
library(multgee)
fitord <- ordLORgee(Ideo_Ordinal~ Machiavellianism+Psychopathy+Narcissism,
data=RightWomen,
id= ordered(factor(Country_ID)))
summary(fitord)
???? ???, 6 ??? 2018 ???? 7:29 ?.?., ?/? Duncan Mackay <dulcalma at
bigpond.com>
??????:
> Hi
>
> Please read the geepack manual carefully.
> GEE ordinal regression is not simple.
> You need to format your data and do not use sample as a storage name. It is
> the name of a function
>
> dta is storage
> dta$Ideo_Ordinal <- ordered(factor(dta$Ideo_Ordinal))
>
> m0 <-
> ordgee(Ideo_Ordinal ~ Machiavellianism+Psychopathy+Narcissism ,data = dta,
> id = Country_ID,
> corstr = "independence")
>
> You need to see if the model is appropriate first and whether the sandwich
> errors are right before you go further
>
> If this is your data you may not get credible results.
> You need to read up on the requirements of GEEs and ordinal GEEs in
> particular
> There are a number of packages with different data requirements and
> methods
> If you have repeated measurements repolr; ?multgee (just from memory)
> Small sample sizes are a problem there are a number of packages dealing
> with
> this but you will have to see which is best for you
> Many do not offer a method for ordinal or multinomial GEE.
> One further question to ask population specific or subject specific ie to
> GEE or not to GEE
>
>
> Regards
>
> Duncan
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2350
>
>
>
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of
euthymios
> kasvikis
> Sent: Saturday, 4 August 2018 07:30
> To: r-help at r-project.org
> Subject: [R] Perform GEE regression in R with multiple dependent variables
>
> Im trying to perform generalized estimating equation (GEE) on the (sample)
> dataset below with R and I would like some little guidance. First of all I
> will describe my dataset. As you can see below it includes 5 variables.
> Country_ID shows the country of the politician, Ideo_Ordinal his poltical
> belief from 1 to 7 (far left to far right). Then we have measurements
> regarding three characteristics. I would like to run an analysis based on
> the country and the political beliefs of every politician (dependent
> variables) in relation with the 3 characteristics. I have used the geepack
> package using:
>
> library(geepack)
>
> samplem<-coef(summary(geeglm(sample$Ideo_Ordinal
> ~Machiavellianism+Psychopathy+Narcissism ,data = sample, id >
sample$Ideo_Ordinal,
> corstr = "independence")))
%>%
> rownames_to_column() %>%
> mutate(lowerWald = Estimate-1.96*Std.err, # Lower Wald CI
> upperWald=Estimate+1.96*Std.err, # Upper Wald CI
> df=1,
> ExpBeta = exp(Estimate)) %>% # Transformed
estimate
> mutate(lWald=exp(lowerWald), # Upper transformed
> uWald=exp(upperWald)) # Lower transformed
> samplem
>
> I would like to know if it is valid to add in this method the Country_ID
> simultaneously with Ideo_Ordinal and how to do it.
>
> Country_ID Ideo_Ordinal Machiavellianism Narcissism Psychopathy
> 3 1 3 0.250895132 0.155238716 0.128683755
> 5 1 3 -0.117725000 -0.336256435 -0.203137879
> 7 1 3 0.269509029 -0.260728261 0.086819555
> 9 1 6 0.108873496 0.175528190 0.182884928
> 14 1 3 0.173129951 0.054468468 0.155030794
> 15 1 6 -0.312088872 -0.414358301 -0.212599946
> 17 1 3 -0.297647658 -0.096523143 -0.228533352
> 18 1 3 -0.020389157 -0.210180866 -0.046687695
> 20 1 3 -0.523432382 -0.125114982 -0.431070629
> 21 1 1 0.040304508 0.022743463 0.233657881
> 22 1 3 0.253695988 -0.330825166 0.101122320
> 23 1 3 -0.478673895 -0.421801231 -0.422894791
> 27 1 6 -0.040856419 -0.566728704 -0.136069484
> 28 1 3 0.240040249 -0.398404825 0.135603114
> 29 1 6 -0.207631653 -0.005347621 -0.294935155
> 30 1 3 0.458042533 0.462935386 0.586244831
> 31 1 3 -0.259850232 -0.233074787 -0.092249465
> 33 1 3 0.002164223 -0.637668706 -0.267158031
> 34 1 6 0.050991955 -0.098030021 -0.043826848
> 36 1 3 -0.338052871 -0.168894328 -0.230198200
> 38 1 3 0.174382347 0.023807812 0.192963609
> 41 2 3 -0.227322148 -0.010016330 -0.095576329
> 42 2 3 -0.267514920 0.066108837 -0.218979873
> 43 2 3 0.421277754 0.385223920 0.421274111
> 44 2 3 -0.399592341 -0.498154998 -0.320402699
> 45 2 1 0.162038344 0.328116118 0.104105963
> 47 2 3 -0.080755709 0.003080287 -0.043568723
> 48 2 3 0.059474124 -0.447305420 0.003988071
> 49 2 3 -0.219773040 -0.312902659 -0.239057883
> 51 2 3 0.438659431 0.364042111 0.393014172
> 52 2 3 -0.088560903 -0.490889275 -0.006041054
> 53 2 3 -0.122612591 0.074438944 0.103722836
> 54 2 3 -0.450586055 -0.304253061 -0.132365179
> 55 2 6 -0.710545197 -0.451329850 -0.764201786
> 56 2 3 0.330718447 0.335460128 0.429173481
> 57 2 3 0.442508023 0.297522144 0.407155726
> 60 2 3 0.060797815 -0.096516876 -0.012802977
> 61 2 3 -0.250757764 -0.113219864 -0.215345379
> 62 2 1 0.153654345 -0.089615287 0.118626045
> 65 2 3 0.042969508 -0.486999608 -0.080829636
> 66 3 3 0.158337022 0.208229002 0.241607154
> 67 3 3 0.220237408 0.397914524 0.262207709
> 69 3 3 0.200558577 0.244419633 0.301732113
> 71 3 3 0.690244689 0.772692418 0.625921098
> 72 3 3 0.189810070 0.377774321 0.293988340
> 73 3 3 -0.385724422 -0.262131032 -0.373159652
> 74 3 3 -0.124095769 -0.109816334 -0.127157915
> 75 3 1 0.173299879 0.453592671 0.325357383
> 76 3 3 -0.598215129 -0.643286651 -0.423824759
> 77 3 3 -0.420558406 -0.361763025 -0.465612116
> 78 3 3 -0.176788569 -0.305506924 -0.203730879
> 80 3 3 -0.114790731 0.262392918 0.061382073
> 81 3 3 -0.274904173 -0.342603918 -0.302761994
> 82 3 3 -0.146902101 -0.059558818 -0.120550957
> 84 3 3 0.038303792 -0.139833875 0.170005914
> 85 3 3 -0.220212221 -0.541399757 -0.555201764
> 87 3 3 0.255300386 0.179484246 0.421428096
> 88 3 6 -0.548823069 -0.405541620 -0.322935805
>
> [[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]]