[R] Question Mixed-Design Anova in R

2018-11-23 Thread Lisa van der Burgh
Hi Everyone,



I have a question about Mixed-Design Anova in R. I want to obtain Mauchly�s 
test of Sphericity and the Greenhouse-Geisser correction. I have managed to do 
it in SPSS:



GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY Grouping

  /WSFACTOR=Measure 6 Polynomial

  /METHOD=SSTYPE(3)

  /PLOT=PROFILE(Measure*Grouping)

  /CRITERIA=ALPHA(.05)

  /WSDESIGN=Measure

  /DESIGN=Grouping.



I have tried to replicate this in R:

library("dplyr")

library("tidyr")

library("ggplot2")

library("ez")



PatientID <- c(1:10)

Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)

Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)

Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)

Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)

Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)

Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)

Grouping <- c(1,0,1,1,1,0,0,1,1,0)

dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3, Measure4, 
Measure5, Measure6, Grouping)

dataframe$Grouping <- as.factor(dataframe$Grouping)

dataframe



ezPrecis(dataframe)

glimpse(dataframe)



dataframe %>% count(PatientID)



dataframe %>% count(PatientID, Grouping, Measure1, Measure2, Measure3, 
Measure4, Measure5, Measure6) %>%

  filter(PatientID %in% c(1:243)) %>%

  print(n = 10)



# So, we have a mixed design with one between factor (Grouping) and 6 within 
factors (Measure 1 to 6).



dat_means <- dataframe %>%

  group_by(Grouping, Measure1, Measure2, Measure3, Measure4, Measure5, 
Measure6) %>%

  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4, Measure5, 
Measure6))) %>% ungroup()

View(dat_means)



ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4, Measure5, 
Measure6), mRT, colour = Grouping)) +

  geom_line(aes(group = Grouping)) +

  geom_point(aes(shape = Grouping), size = 3) +

  facet_wrap(~group)



ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2, Measure3, 
Measure4, Measure5, Measure6)),

between = Grouping, type = 3)



print(ANOVA)





However, this does not work. I know I am probably doing it completely wrong, 
but I do not know how to solve it. Besides that, I do not know what to fill in 
at the �x�.

Can somebody help me?



Thank you in advance.

Lisa


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] detecting measurement of specific id in column in R

2018-11-23 Thread Romy Rehschuh via R-help
Dear all, dear Jim,

thanks so much for your efforts! The code seems to work well :)

All the best,

Vicci

Am Do., 22. Nov. 2018 um 23:34 Uhr schrieb Jim Lemon :

> Hi Vicci,
> It's very clunky, but I think it will do what you want.
> rrdf<-read.csv(text="No,date,chamber,d13C,ppm_CO2,ppm_13CO2
>  1,10.14.2018 10:43 PM,IN,-0.192,439.6908,4.9382
>  2,10.14.2018 10:47 PM,101,-0.058,440.7646,4.9509
>  3,10.14.2018 10:50 PM,103,-1.368,535.6602,5.9967
>  4,10.14.2018 10:53 PM,104,-1.601,542.4841,6.0702
>  5,10.14.2018 10:57 PM,105,-1.353,475.2809,5.3299
>  6,10.14.2018 11:00 PM,106,-1.184,530.6732,5.9430
>  7,10.14.2018 11:03 PM,107,-1.582,512.5939,5.7418
>  8,10.14.2018 11:07 PM,108,-1.359,544.0658,6.0889
>  9,10.14.2018 11:10 PM,109,-1.557,543.2651,6.0790
>  10,10.14.2018 11:13 PM,110,-1.638,477.0006,5.3476
>  11,10.14.2018 11:17 PM,111,-1.475,530.1569,5.9357
>  12,10.14.2018 11:20 PM,IN,-0.039,439.3367,4.9350
>  13,10.14.2018 11:23 PM,1,-0.061,439.7931,4.9400
>  14,10.14.2018 11:26 PM,3,-0.510,456.0714,5.1201
>  15,10.14.2018 11:30 PM,4,-0.510,456.5144,5.1250
>  16,10.14.2018 11:33 PM,5,-0.767,454.4449,5.1005
>  17,10.14.2018 11:37 PM,6,-0.788,459.7679,5.1600
>  18,10.14.2018 11:40 PM,7,-0.978,456.6323,5.1240
>  19,10.14.2018 11:43 PM,8,-0.742,450.4059,5.0556
>  20,10.14.2018 11:47 PM,9,-0.675,451.6678,5.0700
>  21,10.14.2018 11:50 PM,10,-0.880,455.5837,5.1127
>  22,10.14.2018 11:53 PM,11,-0.912,463.0478,5.1960
>  23,10.15.2018 12:01 AM,IN,-0.368,439.5525,4.9359
>  24,10.15.2018 12:12 AM,102,-0.205,439.9343,4.9409
>  25,10.15.2018 12:15 AM,112,-1.685,474.5002,5.3196
>  26,10.15.2018 12:19 AM,113,-1.714,474.4248,5.3186
>  27,10.15.2018 12:22 AM,114,-2.032,496.5623,5.5623
>  28,10.15.2018 12:26 AM,115,-1.602,471.2034,5.2834
>  29,10.15.2018 12:29 AM,116,-1.303,554.4268,6.2028
>  30,10.15.2018 12:32 AM,117,-1.833,501.2357,5.6151
>  31,10.15.2018 12:36 AM,118,-1.745,496.0126,5.5578
>  32,10.15.2018 12:39 AM,119,-1.537,467.5305,5.2428
>  33,10.15.2018 12:42 AM,120,-2.109,507.5778,5.6836",
>  stringsAsFactors=FALSE)
>
>
> rrdf$ppm_13CO2_delta<-rrdf$ppm_CO2_delta<-rrdf$d13C_delta<-NA
> for(row in 1:nrow(rrdf)) {
>  if(rrdf$chamber[row] == "IN")
>   INval<-c(rrdf$d13C[row],rrdf$ppm_CO2[row],rrdf$ppm_13CO2[row])
>  rrdf[row,c("d13C_delta","ppm_CO2_delta","ppm_13CO2_delta")]<-
>   rrdf[row,c("d13C","ppm_CO2","ppm_13CO2")]-INval
> }
>
> Jim
>
> On Fri, Nov 23, 2018 at 8:52 AM Romy Rehschuh via R-help
>  wrote:
> >
> > Dear all,
> >
> > if the attachment didn´t arrive, maybe it works now.
> > I would like to substract the "IN" values (= the air which goes into the
> > chambers) for "d13C", "ppm_CO2" and "ppm_13CO2"
> > from the "d13C", "ppm_CO2" and "ppm_13CO2" for every single chamber.
> > I need to substract the "IN" values which were measured *before* the
> > chamber.
> >
> > So the calculation would look like df$d13C [chambers] - df$d13C [IN]
> >df$ppm_CO2
> > [chambers] - df$ppm_13CO2 [IN]
> >df$ppm_13CO2
> > [chambers] - df$ ppm_13CO2 [IN]
> > --> for chamber 101-111 this should be the first "IN" (No 1)
> > --> for chamber 1-11 this should be the second "IN" (No 12)
> > ...and so on
> >
> > I tried sth. like which(abs(date-x) == min(abs(date-x), but it just gives
> > me the closest "IN" in time and not the "IN" before.
> >
> > I would appreciate any help!
> > Thank you so much, Vicci
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] detecting measurement of specific id in column in R

2018-11-23 Thread PIKAL Petr
Hi

It could be done by ave function if you prepare chamber column to such task

library(zoo)
#make new column ch
rrdf$ch<-rrdf$chamber
#change what is not IN to NA
rrdf$ch[which(rrdf$chamber!="IN")]<-NA
#make distinct identifier for each IN chunk
rrdf$ch[which(rrdf$chamber=="IN")]<-paste("IN", 1:3, sep="")
fill NA values
rrdf$ch<-na.locf(rrdf$ch)

ave(rrdf[,4], rrdf$ch, FUN=function(x) x-x[1])

gives you values which could be added to original data e.g.

rrdf$ppm_13CO2_delta <- ave(rrdf$ ppm_13CO2, rrdf$ch, FUN=function(x) x-x[1])

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Jim Lemon
> Sent: Thursday, November 22, 2018 11:34 PM
> To: ro.rehsc...@googlemail.com
> Cc: r-help mailing list 
> Subject: Re: [R] detecting measurement of specific id in column in R
>
> Hi Vicci,
> It's very clunky, but I think it will do what you want.
> rrdf<-read.csv(text="No,date,chamber,d13C,ppm_CO2,ppm_13CO2
>  1,10.14.2018 10:43 PM,IN,-0.192,439.6908,4.9382
>  2,10.14.2018 10:47 PM,101,-0.058,440.7646,4.9509
>  3,10.14.2018 10:50 PM,103,-1.368,535.6602,5.9967
>  4,10.14.2018 10:53 PM,104,-1.601,542.4841,6.0702
>  5,10.14.2018 10:57 PM,105,-1.353,475.2809,5.3299
>  6,10.14.2018 11:00 PM,106,-1.184,530.6732,5.9430
>  7,10.14.2018 11:03 PM,107,-1.582,512.5939,5.7418
>  8,10.14.2018 11:07 PM,108,-1.359,544.0658,6.0889
>  9,10.14.2018 11:10 PM,109,-1.557,543.2651,6.0790
>  10,10.14.2018 11:13 PM,110,-1.638,477.0006,5.3476
>  11,10.14.2018 11:17 PM,111,-1.475,530.1569,5.9357
>  12,10.14.2018 11:20 PM,IN,-0.039,439.3367,4.9350
>  13,10.14.2018 11:23 PM,1,-0.061,439.7931,4.9400
>  14,10.14.2018 11:26 PM,3,-0.510,456.0714,5.1201
>  15,10.14.2018 11:30 PM,4,-0.510,456.5144,5.1250
>  16,10.14.2018 11:33 PM,5,-0.767,454.4449,5.1005
>  17,10.14.2018 11:37 PM,6,-0.788,459.7679,5.1600
>  18,10.14.2018 11:40 PM,7,-0.978,456.6323,5.1240
>  19,10.14.2018 11:43 PM,8,-0.742,450.4059,5.0556
>  20,10.14.2018 11:47 PM,9,-0.675,451.6678,5.0700
>  21,10.14.2018 11:50 PM,10,-0.880,455.5837,5.1127
>  22,10.14.2018 11:53 PM,11,-0.912,463.0478,5.1960
>  23,10.15.2018 12:01 AM,IN,-0.368,439.5525,4.9359
>  24,10.15.2018 12:12 AM,102,-0.205,439.9343,4.9409
>  25,10.15.2018 12:15 AM,112,-1.685,474.5002,5.3196
>  26,10.15.2018 12:19 AM,113,-1.714,474.4248,5.3186
>  27,10.15.2018 12:22 AM,114,-2.032,496.5623,5.5623
>  28,10.15.2018 12:26 AM,115,-1.602,471.2034,5.2834
>  29,10.15.2018 12:29 AM,116,-1.303,554.4268,6.2028
>  30,10.15.2018 12:32 AM,117,-1.833,501.2357,5.6151
>  31,10.15.2018 12:36 AM,118,-1.745,496.0126,5.5578
>  32,10.15.2018 12:39 AM,119,-1.537,467.5305,5.2428
>  33,10.15.2018 12:42 AM,120,-2.109,507.5778,5.6836",
>  stringsAsFactors=FALSE)
>
>
> rrdf$ppm_13CO2_delta<-rrdf$ppm_CO2_delta<-rrdf$d13C_delta<-NA
> for(row in 1:nrow(rrdf)) {
>  if(rrdf$chamber[row] == "IN")
>   INval<-c(rrdf$d13C[row],rrdf$ppm_CO2[row],rrdf$ppm_13CO2[row])
>  rrdf[row,c("d13C_delta","ppm_CO2_delta","ppm_13CO2_delta")]<-
>   rrdf[row,c("d13C","ppm_CO2","ppm_13CO2")]-INval
> }
>
> Jim
>
> On Fri, Nov 23, 2018 at 8:52 AM Romy Rehschuh via R-help  project.org> wrote:
> >
> > Dear all,
> >
> > if the attachment didn´t arrive, maybe it works now.
> > I would like to substract the "IN" values (= the air which goes into
> > the
> > chambers) for "d13C", "ppm_CO2" and "ppm_13CO2"
> > from the "d13C", "ppm_CO2" and "ppm_13CO2" for every single chamber.
> > I need to substract the "IN" values which were measured *before* the
> > chamber.
> >
> > So the calculation would look like df$d13C [chambers] - df$d13C [IN]
> >df$ppm_CO2
> > [chambers] - df$ppm_13CO2 [IN]
> >df$ppm_13CO2
> > [chambers] - df$ ppm_13CO2 [IN]
> > --> for chamber 101-111 this should be the first "IN" (No 1) for
> > --> chamber 1-11 this should be the second "IN" (No 12)
> > ...and so on
> >
> > I tried sth. like which(abs(date-x) == min(abs(date-x), but it just
> > gives me the closest "IN" in time and not the "IN" before.
> >
> > I would appreciate any help!
> > Thank you so much, Vicci
>
> __
> R-help@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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be

[R] R 3.5.2 scheduled for December 20

2018-11-23 Thread Peter Dalgaard via R-help
Full schedule available on developer.r-project.org

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
R-help@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.


Re: [R] Question Mixed-Design Anova in R

2018-11-23 Thread peter dalgaard
You seem to be bringing in a ton of stuff without looking at features in base 
R...

Check 

help(mauchly.test)
help(anova.mlm)

and examples therein. There are also options in the "car" package.

-pd

> On 23 Nov 2018, at 11:43 , Lisa van der Burgh <40760...@student.eur.nl> wrote:
> 
> Hi Everyone,
> 
> 
> 
> I have a question about Mixed-Design Anova in R. I want to obtain Mauchly�s 
> test of Sphericity and the Greenhouse-Geisser correction. I have managed to 
> do it in SPSS:
> 
> 
> 
> GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY Grouping
> 
>  /WSFACTOR=Measure 6 Polynomial
> 
>  /METHOD=SSTYPE(3)
> 
>  /PLOT=PROFILE(Measure*Grouping)
> 
>  /CRITERIA=ALPHA(.05)
> 
>  /WSDESIGN=Measure
> 
>  /DESIGN=Grouping.
> 
> 
> 
> I have tried to replicate this in R:
> 
> library("dplyr")
> 
> library("tidyr")
> 
> library("ggplot2")
> 
> library("ez")
> 
> 
> 
> PatientID <- c(1:10)
> 
> Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)
> 
> Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)
> 
> Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)
> 
> Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)
> 
> Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)
> 
> Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)
> 
> Grouping <- c(1,0,1,1,1,0,0,1,1,0)
> 
> dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3, Measure4, 
> Measure5, Measure6, Grouping)
> 
> dataframe$Grouping <- as.factor(dataframe$Grouping)
> 
> dataframe
> 
> 
> 
> ezPrecis(dataframe)
> 
> glimpse(dataframe)
> 
> 
> 
> dataframe %>% count(PatientID)
> 
> 
> 
> dataframe %>% count(PatientID, Grouping, Measure1, Measure2, Measure3, 
> Measure4, Measure5, Measure6) %>%
> 
>  filter(PatientID %in% c(1:243)) %>%
> 
>  print(n = 10)
> 
> 
> 
> # So, we have a mixed design with one between factor (Grouping) and 6 within 
> factors (Measure 1 to 6).
> 
> 
> 
> dat_means <- dataframe %>%
> 
>  group_by(Grouping, Measure1, Measure2, Measure3, Measure4, Measure5, 
> Measure6) %>%
> 
>  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4, Measure5, 
> Measure6))) %>% ungroup()
> 
> View(dat_means)
> 
> 
> 
> ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4, Measure5, 
> Measure6), mRT, colour = Grouping)) +
> 
>  geom_line(aes(group = Grouping)) +
> 
>  geom_point(aes(shape = Grouping), size = 3) +
> 
>  facet_wrap(~group)
> 
> 
> 
> ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2, 
> Measure3, Measure4, Measure5, Measure6)),
> 
>between = Grouping, type = 3)
> 
> 
> 
> print(ANOVA)
> 
> 
> 
> 
> 
> However, this does not work. I know I am probably doing it completely wrong, 
> but I do not know how to solve it. Besides that, I do not know what to fill 
> in at the �x�.
> 
> Can somebody help me?
> 
> 
> 
> Thank you in advance.
> 
> Lisa
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@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.


[R] question about R

2018-11-23 Thread Ahmadzadeh Siahrood Farzaneh
Dear all,
I have a problem which I have stucked for a while and I didn't find any 
solution. Would you please take your time and see if you could help me for the 
following R code.
I am using Survival analysis to fit the distribution to my data. My data ranges 
changes from smaller than 0 to a very big number like (yearly average mileage 
). When I add data which are very big in range I receive following error. First 
I taught by normalizing data it would be solved but it didn't.
If anyone has any experience about what would be the reason for error or how I 
can solve it ? I really appreciate your support and help.
f<- Surv(time, status) ~ covariates (there are 56)
weibul  <- flexsurvreg(f ,dist='weibull' ,data=Data)
Error in optim(method = "BFGS", par = c(0.566003631595269, 0, 0, 0, 0,  :
  initial value in 'vmmin' is not finite

Med V�nliga H�lsningar
Best Regards,

Farzaneh Ahmadzadeh, PhD. IE.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Question Mixed-Design Anova in R

2018-11-23 Thread Fox, John
Dear Lisa,

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of peter
> dalgaard
> Sent: Friday, November 23, 2018 10:16 AM
> To: Lisa van der Burgh <40760...@student.eur.nl>
> Cc: r-help@R-project.org
> Subject: Re: [R] Question Mixed-Design Anova in R
> 
> You seem to be bringing in a ton of stuff without looking at features in base
> R...
> 
> Check
> 
> help(mauchly.test)
> help(anova.mlm)
> 
> and examples therein. There are also options in the "car" package.

With respect to the latter, see in particular the O'Brien-Kaiser example in 
?Anova.

I hope this helps,
 John

-
John Fox
Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
Web: https://socialsciences.mcmaster.ca/jfox/


> 
> -pd
> 
> > On 23 Nov 2018, at 11:43 , Lisa van der Burgh <40760...@student.eur.nl>
> wrote:
> >
> > Hi Everyone,
> >
> >
> >
> > I have a question about Mixed-Design Anova in R. I want to obtain Mauchly s
> test of Sphericity and the Greenhouse-Geisser correction. I have managed to
> do it in SPSS:
> >
> >
> >
> > GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY
> Grouping
> >
> >  /WSFACTOR=Measure 6 Polynomial
> >
> >  /METHOD=SSTYPE(3)
> >
> >  /PLOT=PROFILE(Measure*Grouping)
> >
> >  /CRITERIA=ALPHA(.05)
> >
> >  /WSDESIGN=Measure
> >
> >  /DESIGN=Grouping.
> >
> >
> >
> > I have tried to replicate this in R:
> >
> > library("dplyr")
> >
> > library("tidyr")
> >
> > library("ggplot2")
> >
> > library("ez")
> >
> >
> >
> > PatientID <- c(1:10)
> >
> > Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)
> >
> > Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)
> >
> > Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)
> >
> > Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)
> >
> > Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)
> >
> > Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)
> >
> > Grouping <- c(1,0,1,1,1,0,0,1,1,0)
> >
> > dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3,
> > Measure4, Measure5, Measure6, Grouping)
> >
> > dataframe$Grouping <- as.factor(dataframe$Grouping)
> >
> > dataframe
> >
> >
> >
> > ezPrecis(dataframe)
> >
> > glimpse(dataframe)
> >
> >
> >
> > dataframe %>% count(PatientID)
> >
> >
> >
> > dataframe %>% count(PatientID, Grouping, Measure1, Measure2,
> Measure3,
> > Measure4, Measure5, Measure6) %>%
> >
> >  filter(PatientID %in% c(1:243)) %>%
> >
> >  print(n = 10)
> >
> >
> >
> > # So, we have a mixed design with one between factor (Grouping) and 6
> within factors (Measure 1 to 6).
> >
> >
> >
> > dat_means <- dataframe %>%
> >
> >  group_by(Grouping, Measure1, Measure2, Measure3, Measure4,
> Measure5,
> > Measure6) %>%
> >
> >  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4,
> > Measure5, Measure6))) %>% ungroup()
> >
> > View(dat_means)
> >
> >
> >
> > ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4,
> > Measure5, Measure6), mRT, colour = Grouping)) +
> >
> >  geom_line(aes(group = Grouping)) +
> >
> >  geom_point(aes(shape = Grouping), size = 3) +
> >
> >  facet_wrap(~group)
> >
> >
> >
> > ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2,
> > Measure3, Measure4, Measure5, Measure6)),
> >
> >between = Grouping, type = 3)
> >
> >
> >
> > print(ANOVA)
> >
> >
> >
> >
> >
> > However, this does not work. I know I am probably doing it completely
> wrong, but I do not know how to solve it. Besides that, I do not know what to
> fill in at the  x .
> >
> > Can somebody help me?
> >
> >
> >
> > Thank you in advance.
> >
> > Lisa
> >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@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.
> 
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000
> Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> __
> R-help@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.
__
R-help@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.


[R] [R-pkgs] New package pivmet: relabelling and K-means seeding via pivotal methods

2018-11-23 Thread legidi



Dear R users,

I am glad to announce the release (version 0.1) of the pivmet package,  
which proposes some pivotal methods in order to:



* undo the label switching problem which naturally arises during the  
MCMC sampling in Bayesian mixture models [pivotal relabelling] (Egidi  
et al. 2018a)


* initialize the K-means algorithm aimed at obtaining a good  
clustering solution [pivotal seeding] (Egidi et al. 2018b)


The package includes two vignettes for easing its use and is here available:

https://cran.r-project.org/web/packages/pivmet/index.html

and developed in github at:

https://github.com/LeoEgidi/pivmet


Here are the two referred articles:

Egidi et al. (2018a)
https://link.springer.com/article/10.1007/s11222-017-9774-2

Egidi et al. (2018b)
https://www.researchgate.net/profile/Leonardo_Egidi/publication/326225330_K-means_seeding_via_MUS_algorithm_-_Inizializzazione_del_K-means_tramite_l%27algoritmo_MUS/links/5b3f2c2caca27207851c7865/K-means-seeding-via-MUS-algorithm-Inizializzazione-del-K-means-tramite-lalgoritmo-MUS.pdf


All the best

Leonardo Egidi
Postdoctoral researcher, University of Trieste

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@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.


Re: [R] Implementation of the "Shuffled Complex Evolution" (SCE-UA) Algorithm

2018-11-23 Thread Mohamed Salem

Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[[alternative HTML version deleted]]

__
R-help@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.


[R] warnings when using binomial models and offset

2018-11-23 Thread Joana Martelo
Hello everyone

 

I'm trying to model fish capture success using length, velocity and group
composition as explanatory variables, density as an offset variable, and
fish.id. as random effect. I'm getting the follow warnings:

 

Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binomial,dat
a=cap)

 

Warning messages:

1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :

  Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)

2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :

  Model is nearly unidentifiable: very large eigenvalue

- Rescale variables?

 

 

-  I only get the warnings when I use length and group composition,
not with velocity.

-  I don't get any warning if I don't use the offset.

 

I've tried:

Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family=binom
ial(link="cloglog"),data=cap)

 

But still get the warning.

 

Any ideas of what might be the problem?

 

Many thanks!

 

 

Joana Martelo

 

 

 


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] warnings when using binomial models and offset

2018-11-23 Thread Bert Gunter
You should post this on the r-sig-mixed-models list, which is (obviously)
specifically concerned with mixed models, and where you are more likely to
find the expertise and help you seek.

Cheers,

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Nov 23, 2018 at 7:57 AM Joana Martelo 
wrote:

> Hello everyone
>
>
>
> I'm trying to model fish capture success using length, velocity and group
> composition as explanatory variables, density as an offset variable, and
> fish.id. as random effect. I'm getting the follow warnings:
>
>
>
> Model1<-glmer(capture~length+offset(density)+(1|fish.id
> ),family=binomial,dat
> a=cap)
>
>
>
> Warning messages:
>
> 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
>
>   Model failed to converge with max|grad| = 0.260123 (tol = 0.001,
> component
> 1)
>
> 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
>
>   Model is nearly unidentifiable: very large eigenvalue
>
> - Rescale variables?
>
>
>
>
>
> -  I only get the warnings when I use length and group composition,
> not with velocity.
>
> -  I don't get any warning if I don't use the offset.
>
>
>
> I've tried:
>
>
> Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family=binom
> ial(link="cloglog"),data=cap)
>
>
>
> But still get the warning.
>
>
>
> Any ideas of what might be the problem?
>
>
>
> Many thanks!
>
>
>
>
>
> Joana Martelo
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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]]

__
R-help@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.


Re: [R] Question Mixed-Design Anova in R

2018-11-23 Thread Lisa van der Burgh
Dear John and Peter,


Thank you both for your answers. I am going to try the solutions you gave me!


Thanks again,

Lisa


From: Fox, John 
Sent: 23 November 2018 16:54:49
To: Lisa van der Burgh
Cc: r-help@R-project.org; peter dalgaard
Subject: RE: [R] Question Mixed-Design Anova in R

Dear Lisa,

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of peter
> dalgaard
> Sent: Friday, November 23, 2018 10:16 AM
> To: Lisa van der Burgh <40760...@student.eur.nl>
> Cc: r-help@R-project.org
> Subject: Re: [R] Question Mixed-Design Anova in R
>
> You seem to be bringing in a ton of stuff without looking at features in base
> R...
>
> Check
>
> help(mauchly.test)
> help(anova.mlm)
>
> and examples therein. There are also options in the "car" package.

With respect to the latter, see in particular the O'Brien-Kaiser example in 
?Anova.

I hope this helps,
 John

-
John Fox
Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
Web: https://socialsciences.mcmaster.ca/jfox/


>
> -pd
>
> > On 23 Nov 2018, at 11:43 , Lisa van der Burgh <40760...@student.eur.nl>
> wrote:
> >
> > Hi Everyone,
> >
> >
> >
> > I have a question about Mixed-Design Anova in R. I want to obtain Mauchly s
> test of Sphericity and the Greenhouse-Geisser correction. I have managed to
> do it in SPSS:
> >
> >
> >
> > GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY
> Grouping
> >
> >  /WSFACTOR=Measure 6 Polynomial
> >
> >  /METHOD=SSTYPE(3)
> >
> >  /PLOT=PROFILE(Measure*Grouping)
> >
> >  /CRITERIA=ALPHA(.05)
> >
> >  /WSDESIGN=Measure
> >
> >  /DESIGN=Grouping.
> >
> >
> >
> > I have tried to replicate this in R:
> >
> > library("dplyr")
> >
> > library("tidyr")
> >
> > library("ggplot2")
> >
> > library("ez")
> >
> >
> >
> > PatientID <- c(1:10)
> >
> > Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)
> >
> > Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)
> >
> > Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)
> >
> > Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)
> >
> > Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)
> >
> > Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)
> >
> > Grouping <- c(1,0,1,1,1,0,0,1,1,0)
> >
> > dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3,
> > Measure4, Measure5, Measure6, Grouping)
> >
> > dataframe$Grouping <- as.factor(dataframe$Grouping)
> >
> > dataframe
> >
> >
> >
> > ezPrecis(dataframe)
> >
> > glimpse(dataframe)
> >
> >
> >
> > dataframe %>% count(PatientID)
> >
> >
> >
> > dataframe %>% count(PatientID, Grouping, Measure1, Measure2,
> Measure3,
> > Measure4, Measure5, Measure6) %>%
> >
> >  filter(PatientID %in% c(1:243)) %>%
> >
> >  print(n = 10)
> >
> >
> >
> > # So, we have a mixed design with one between factor (Grouping) and 6
> within factors (Measure 1 to 6).
> >
> >
> >
> > dat_means <- dataframe %>%
> >
> >  group_by(Grouping, Measure1, Measure2, Measure3, Measure4,
> Measure5,
> > Measure6) %>%
> >
> >  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4,
> > Measure5, Measure6))) %>% ungroup()
> >
> > View(dat_means)
> >
> >
> >
> > ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4,
> > Measure5, Measure6), mRT, colour = Grouping)) +
> >
> >  geom_line(aes(group = Grouping)) +
> >
> >  geom_point(aes(shape = Grouping), size = 3) +
> >
> >  facet_wrap(~group)
> >
> >
> >
> > ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2,
> > Measure3, Measure4, Measure5, Measure6)),
> >
> >between = Grouping, type = 3)
> >
> >
> >
> > print(ANOVA)
> >
> >
> >
> >
> >
> > However, this does not work. I know I am probably doing it completely
> wrong, but I do not know how to solve it. Besides that, I do not know what to
> fill in at the  x .
> >
> > Can somebody help me?
> >
> >
> >
> > Thank you in advance.
> >
> > Lisa
> >
> >
> >  [[alternative HTML version deleted]]
> >
> > __
> > R-help@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.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000
> Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
> __
> R-help@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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE d

[R] TrendRaster function

2018-11-23 Thread Jackson Rodrigues
Dear all,

I am trying to run the codes of "greenbrown" package for detection in
raster time serie.

However the error below reported occurs.

#
library(greenbrown)
data(ndvimap)
ndvimap
plot(ndvimap,8)

# calculate trend: annual aggregation method
AATmap <- TrendRaster(ndvimap$X1982.01.01, start=c(1982, 1), freq=12,
method="AAT", breaks=1)

Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) :
  cannot use this function


Could anyone help me to solve it?

Thank you,

Jackson

[[alternative HTML version deleted]]

__
R-help@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.


[R] Help needed regarding dlm model on stats.stackexchange

2018-11-23 Thread Ashim Kapoor
Dear all,

I have created a time varying parameters regression. When I do that I have
a parameter which is AR1. I am not able to recover this parameter.

My query is posted here :

https://stats.stackexchange.com/questions/377295/unable-to-recover-time-varying-ar1-parameter-from-state-space-model

I did not receive a reply so I am posting here.

Many thanks,
Ashim.

[[alternative HTML version deleted]]

__
R-help@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.