thanks to ben bolker "Look into the (very well-documented) emmeans package: https://CRAN.R-project.org/package=emmeans? well documented? you cannot be serious - this is R the install instructions are as follows * To install the latest development version from Github, install the newest version of the **devtools** package; then run ``` devtools::install_github("rvlenth/emmeans", dependencies = TRUE, build_vignettes = TRUE) ``` of course this requires a whole to of other stuff like rmarkdown with no idea as to where they may be found yet to find ANY R documentation that simply lists ALL required packages and library items for any help to be useful one needs to know 1. ALL the necessary packages 2. all the necessary commands. ? libraries meanwhile here is super friendly SPSS output SPSS Model Summary Target Events FreqPos Trials Nmax Probability Distribution Binomial Link Function Logit Information Criterion Akaike Corrected 1189.377 Bayesian 1227.957 Information criteria are based on the -2 log likelihood (1168.768) and are used to compare models. Models with smaller information criterion values fit better. Fixed Effectsa Source F df1 df2 Sig. Corrected Model 30.641 7 101 .000 Rab 66.755 3 94 .000 Between .379 1 93 .540 Rab * Between 5.312 3 94 .002 Probability distribution: Binomial Link function: Logit a. Target: FreqPos/Nmax Fixed Coefficientsa Model Term Coefficient Std. Error t Sig. 95% Confidence Interval Exp(Coefficient) 95% Confidence Interval for Exp(Coefficient) Lower Upper Lower Upper Intercept -.267 .1484 -1.801 .075 -.562 .027 .765 .570 1.028 Rab=4 -1.901 .2332 -8.149 .000 -2.364 -1.438 .149 .094 .237 Rab=3 -1.282 .2151 -5.963 .000 -1.710 -.855 .277 .181 .425 Rab=2 -.420 .1477 -2.847 .005 -.714 -.127 .657 .490 .881 Rab=1 0b . . . . . . . . Between=2 .564 .2069 2.727 .008 .153 .975 1.758 1.166 2.651 Between=1 0b . . . . . . . . [Rab=4]*[Between=2] -.895 .3438 -2.602 .011 -1.577 -.212 .409 .207 .809 [Rab=4]*[Between=1] 0b . . . . . . . . [Rab=3]*[Between=2] -1.253 .3296 -3.800 .000 -1.907 -.598 .286 .149 .550 [Rab=3]*[Between=1] 0b . . . . . . . . [Rab=2]*[Between=2] -.621 .2064 -3.010 .003 -1.031 -.211 .537 .357 .810 [Rab=2]*[Between=1] 0b . . . . . . . . [Rab=1]*[Between=2] 0b . . . . . . . . [Rab=1]*[Between=1] 0b . . . . . . . . Probability distribution: Binomial Link function: Logit a. Target: FreqPos/Nmax b. This coefficient is set to zero because it is redundant. R output Analysis of Variance Table Df Sum Sq Mean Sq F value Rab 3 870.17 290.058 290.058 Between 1 0.12 0.122 0.122 Rab:Between 3 63.20 21.067 21.067 Notice that F = Mean Sq, which is a SURPRISE usually F = MSeffect/MSerror, so where is the MS error? fixef(Logit1) (Intercept) Rab2 Rab3 Rab4 Between2 Rab2:Between2 Rab3:Between2 Rab4:Between2 -0.3162873 -0.5033874 -1.5218751 -2.2416235 0.6735183 -0.7491242 -1.4426385 -1.0069334 Really do appreciate help best Diana
On 27 Feb 2018, at 06:22, r-sig-mixed-models-request at r-project.org<mailto:r-sig-mixed-models-request at r-project.org> wrote:
Send R-sig-mixed-models mailing list submissions to r-sig-mixed-models at r-project.org<mailto:r-sig-mixed-models at r-project.org> To subscribe or unsubscribe via the World Wide Web, visit https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models or, via email, send a message with subject or body 'help' to r-sig-mixed-models-request at r-project.org You can reach the person managing the list at r-sig-mixed-models-owner at r-project.org When replying, please edit your Subject line so it is more specific than "Re: Contents of R-sig-mixed-models digest..." Today's Topics: 1. Re: zero-inflated-count-data? (Highland Statistics Ltd) 2. Re: means , CIs from lmer, glmer (Ben Bolker) 3. Re: zero-inflated-count-data? (Ben Bolker) 4. Longitudinal logistic regression with continuous-time first-order autocorrelation structure (Dennis Ruenger) ---------------------------------------------------------------------- Message: 1 Date: Mon, 26 Feb 2018 17:26:02 +0000 From: Highland Statistics Ltd <highstat at highstat.com> To: "r-sig-mixed-models at r-project.org" <r-sig-mixed-models at r-project.org> Subject: Re: [R-sig-ME] zero-inflated-count-data? Message-ID: <d1db8134-8ae0-ff56-4622-02a909a2ff1b at highstat.com> Content-Type: text/plain; charset="utf-8"; Format="flowed" ---------------------------------------------------------------------- Message: 1 Date: Mon, 26 Feb 2018 14:57:00 +0100 From: "C. AMAL D. GLELE" <altessedac2 at gmail.com> To: Jonathan Judge <bachlaw01 at outlook.com> Cc: Ben Bolker <bbolker at gmail.com>, R SIG Mixed Models <r-sig-mixed-models at r-project.org> Subject: Re: [R-sig-ME] zero-inflated-count-data? Message-ID: <CANrzCv0SZxAXjoftdkN7v5M4g6wrd3GM7qx23dFB=fi7JHisCg at mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi, dear all. Many thanks to you all for your very helpful answers. Jonathan, I've started fitting a model using zeroinfl function from pscl package, but I'm having the following difficulty according to one of my regressors, let be H_var (categorical with 8 levels): as regressors, I have 7 categorical variables (with a total of 26 levels) and two numerical variables; 1) when I fit the model like follows, model1<-zeroinfl(countdata~var1+H_var+var3+var4+var5+var6+var7+var8num +var9num,dist="negbin",data=mydata) , I receive the error message below: "Error in solve.default(as.matrix(fit$hessian)) : system is computationally singular: reciprocal condition number = 7.05621e-21 In addition: Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred " 2) but, if I remove H_var from the count component and fits model2 loke follows, model2<-zeroinfl(countdata~var1+var3+var4+var5+var6+var7+var8num+ var9num|H_var,dist="negbin",data=mydata) the model fits well and I do not receive error message anymore. 3) If use H_var in both component of the model, like follows, model3<-zeroinfl(countdata~var1+var3+var4+var5+var6+var7+var8num+ var9num+H_var|H_var,dist="negbin",data=mydata) I receive the following error message: "Error in solve.default(as.matrix(fit$hessian)) : system is computationally singular: reciprocal condition number = 4.2618e-20 " Question: Does someone have any idea about probables causes of the problems posed at points 1) and 3) ? Without seeing the data......simplify your model? Collinearity? Start simple and build up the complexity of the model. Maybe start with a Poisson GLM and figure out whether you really need a ZIP/ZINB? Why are you actually do a ZINB? can you, please, provide me details (some ways to do it) and/or lead about simulating data from a fitted model? See step 10 in: A protocol for conducting and presenting results of regression-type analyses (2016). Zuur & Ieno. http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12577/abstract and see Figure 8 from that paper for an example. R code is somewhere online as well. Alain In advance, thanks for your answers. Best, 2018-02-25 23:55 GMT+01:00 Jonathan Judge <bachlaw01 at outlook.com>: -- Dr. Alain F. Zuur Highland Statistics Ltd. 9 St Clair Wynd AB41 6DZ Newburgh, UK Email: highstat at highstat.com URL: www.highstat.com And: NIOZ Royal Netherlands Institute for Sea Research, Department of Coastal Systems, and Utrecht University, P.O. Box 59, 1790 AB Den Burg, Texel, The Netherlands Author of: 1. Beginner's Guide to Spatial, Temporal and Spatial-Temporal Ecological Data Analysis with R-INLA. (2017). 2. Beginner's Guide to Zero-Inflated Models with R (2016). 3. Beginner's Guide to Data Exploration and Visualisation with R (2015). 4. Beginner's Guide to GAMM with R (2014). 5. Beginner's Guide to GLM and GLMM with R (2013). 6. Beginner's Guide to GAM with R (2012). 7. Zero Inflated Models and GLMM with R (2012). 8. A Beginner's Guide to R (2009). 9. Mixed effects models and extensions in ecology with R (2009). 10. Analysing Ecological Data (2007). ------------------------------ Message: 2 Date: Mon, 26 Feb 2018 20:02:57 -0500 From: Ben Bolker <bbolker at gmail.com> To: "Kornbrot, Diana" <d.e.kornbrot at herts.ac.uk> Cc: "r-sig-mixed-models at r-project.org" <r-sig-mixed-models at r-project.org>, "Paice, Andrew" <a.paice at herts.ac.uk>, "Georgiou, George" <g.j.georgiou at herts.ac.uk>, "Sullivan, Keith" <k.sullivan3 at herts.ac.uk> Subject: Re: [R-sig-ME] means , CIs from lmer, glmer Message-ID: <CABghstTnvHcvQab_dH9j_BcfxvnbEREuHOkZaen9m_TmRLSovw at mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi Diana, A reproducible example is always helpful/increases your chances of getting a useful answer ... It might help if you included the SPSS output (or posted it somewhere -- note that this list doesn't take HTML-formatted messages nor most attachments), as many of us don't have access to it. Look into the (very well-documented) emmeans package: https://CRAN.R-project.org/package=emmeans and the lmerTest package (for Satterthwaite df approximations) On Mon, Feb 26, 2018 at 12:11 PM, Kornbrot, Diana
<d.e.kornbrot at herts.ac.uk> wrote:
I am keen to promote the use of generalised mixed models for the analysis of proportions to psychologists Have straight fowl code in SPSS [costly] and would like to supply equivalent R Code without ?tears? Design is a follows raw frequencies are: FreqPos for ?success? and FreqNeg for ?failure? Predictors are Rab with 4 levels, repeated over participants and Between with 2 separate groups of participants Model is binomial with logit link Require following output to correspond to SPSS output from code below Descriptive: Means, se and 95% CIs by Rab, by Between and by Rab*Between Inferential: fo Rab, Between and Rab*Between: F value, MSE, numerator df, denominator df [this enables p-values] Have tried logit1 <- glmer(cbind(FreqPos,FreqNeg) ~ Rab + Between + Rab*Between + (1| Participant), family=binomial(link="logit")) gives F and MSE no denominator df or MSE. Different results to SPSS nb F=MSE - that can?t be right F is supposed to be ratio of chi-squares summary (logit1) gives coefficients and SEs. Different results to SPSS also tried predicted and fitted but still no means have spent days searching internet for examples - but none of them seem to show how to get the output I need All help greatly appreciated ____ Spss syntax *Generalized Linear Mixed Models. GENLINMIXED /DATA_STRUCTURE SUBJECTS=Participant REPEATED_MEASURES=Rab COVARIANCE_TYPE=UNSTRUCTURED /FIELDS TARGET=FreqPos TRIALS=FIELD(Nmax) OFFSET=NONE /TARGET_OPTIONS DISTRIBUTION=BINOMIAL LINK=LOGIT /FIXED EFFECTS=Rab Between Rab*Between USE_INTERCEPT=TRUE /BUILD_OPTIONS TARGET_CATEGORY_ORDER=DESCENDING INPUTS_CATEGORY_ORDER=DESCENDING MAX_ITERATIONS=100 CONFIDENCE_LEVEL=95 DF_METHOD=SATTERTHWAITE COVB=MODEL PCONVERGE=0.000001(ABSOLUTE) SCORING=0 SINGULAR=0.000000000001 /EMMEANS TABLES=Rab COMPARE=Rab CONTRAST=DEVIATION /EMMEANS TABLES=Between CONTRAST=NONE /EMMEANS TABLES=Rab*Between CONTRAST=NONE /EMMEANS_OPTIONS SCALE=ORIGINAL PADJUST=LSD. best Diana _____________________________________ Professor Diana Kornbrot Mobile +44 (0) 7403 18 16 12 Work University of Hertfordshire College Lane, Hatfield, Hertfordshire AL10 9AB, UK +44 (0) 170 728 4626 d.e.kornbrot at herts.ac.uk<mailto:d.e.kornbrot at herts.ac.uk> http://dianakornbrot.wordpress.com/ http://go.herts.ac.uk/Diana_Kornbrot skype: kornbrotme Home 19 Elmhurst Avenue London N2 0LT, UK +44 (0) 208 444 2081 ------------------------------------------------------------ _______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models ------------------------------ Message: 3 Date: Mon, 26 Feb 2018 20:17:14 -0500 From: Ben Bolker <bbolker at gmail.com> To: Highland Statistics Ltd <highstat at highstat.com> Cc: "r-sig-mixed-models at r-project.org" <r-sig-mixed-models at r-project.org> Subject: Re: [R-sig-ME] zero-inflated-count-data? Message-ID: <CABghstRR41zVjimCX=Q3mc+AckchFOTc_8kb8ASfVb6pUSokyQ at mail.gmail.com> Content-Type: text/plain; charset="utf-8" For some model types (unfortunately not pscl::zeroinlf(), it looks like) you can just use the simulate() method ... By the way, Amal (hope that's a reasonable way to address you) - folks are really helpful here (as you will have noticed), but the list is primarily for questions about *mixed* (hierarchical/multilevel/whatever) models. At present your questions are more generic questions about zero-inflation and generalized linear modeling. I do recommend the books by Alain and his co-authors as a good way to get started on the fairly complex stuff you're attempting here. On Mon, Feb 26, 2018 at 12:26 PM, Highland Statistics Ltd
<highstat at highstat.com> wrote:
----------------------------------------------------------------------
Message: 1
Date: Mon, 26 Feb 2018 14:57:00 +0100
From: "C. AMAL D. GLELE" <altessedac2 at gmail.com>
To: Jonathan Judge <bachlaw01 at outlook.com>
Cc: Ben Bolker <bbolker at gmail.com>, R SIG Mixed Models
<r-sig-mixed-models at r-project.org>
Subject: Re: [R-sig-ME] zero-inflated-count-data?
Message-ID:
<CANrzCv0SZxAXjoftdkN7v5M4g6wrd3GM7qx23dFB=fi7JHisCg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi, dear all.
Many thanks to you all for your very helpful answers.
Jonathan,
I've started fitting a model using zeroinfl function from pscl package, but
I'm having the following
difficulty according to one of my regressors, let be H_var (categorical
with 8 levels):
as regressors, I have 7 categorical variables (with a total of 26 levels)
and two numerical
variables;
1) when I fit the model like follows,
model1<-zeroinfl(countdata~var1+H_var+var3+var4+var5+var6+var7+var8num
+var9num,dist="negbin",data=mydata)
, I receive the error message below:
"Error in solve.default(as.matrix(fit$hessian)) :
system is computationally singular: reciprocal condition number =
7.05621e-21
In addition: Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
"
2)
but, if I remove H_var from the count component and fits model2 loke
follows,
model2<-zeroinfl(countdata~var1+var3+var4+var5+var6+var7+var8num+
var9num|H_var,dist="negbin",data=mydata)
the model fits well and I do not receive error message anymore.
3)
If use H_var in both component of the model, like follows,
model3<-zeroinfl(countdata~var1+var3+var4+var5+var6+var7+var8num+
var9num+H_var|H_var,dist="negbin",data=mydata)
I receive the following error message:
"Error in solve.default(as.matrix(fit$hessian)) :
system is computationally singular: reciprocal condition number =
4.2618e-20
"
Question:
Does someone have any idea about probables causes of the problems posed
at points 1) and 3) ?
Without seeing the data......simplify your model? Collinearity? Start simple
and build up the complexity of the model.
Maybe start with a Poisson GLM and figure out whether you really need a
ZIP/ZINB? Why are you actually do a ZINB?
can you, please, provide me details (some ways to do it) and/or lead about
simulating data from a fitted model?
See step 10 in:
A protocol for conducting and presenting results of regression-type analyses
(2016).
Zuur & Ieno.
http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12577/abstract
and see Figure 8 from that paper for an example. R code is somewhere online
as well.
Alain
In advance, thanks for your answers.
Best,
2018-02-25 23:55 GMT+01:00 Jonathan Judge <bachlaw01 at outlook.com>:
--
Dr. Alain F. Zuur
Highland Statistics Ltd.
9 St Clair Wynd
AB41 6DZ Newburgh, UK
Email: highstat at highstat.com
URL: www.highstat.com
And:
NIOZ Royal Netherlands Institute for Sea Research,
Department of Coastal Systems, and Utrecht University,
P.O. Box 59, 1790 AB Den Burg,
Texel, The Netherlands
Author of:
1. Beginner's Guide to Spatial, Temporal and Spatial-Temporal Ecological
Data Analysis with R-INLA. (2017).
2. Beginner's Guide to Zero-Inflated Models with R (2016).
3. Beginner's Guide to Data Exploration and Visualisation with R (2015).
4. Beginner's Guide to GAMM with R (2014).
5. Beginner's Guide to GLM and GLMM with R (2013).
6. Beginner's Guide to GAM with R (2012).
7. Zero Inflated Models and GLMM with R (2012).
8. A Beginner's Guide to R (2009).
9. Mixed effects models and extensions in ecology with R (2009).
10. Analysing Ecological Data (2007).
_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
------------------------------
Message: 4
Date: Mon, 26 Feb 2018 22:22:17 -0800
From: Dennis Ruenger <dennis.ruenger at gmail.com>
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] Longitudinal logistic regression with
continuous-time first-order autocorrelation structure
Message-ID:
<CAFvg1=vdVbz28pw9B6GrOXNsnceXK3UgXksMDwJUOQ9PYoLK_g at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Dear All.
I need to analyze an intensive longitudinal data set with a binary outcome
variable. In the ?Ecological Momentary Assessment? (EMA) study,
participants received five random prompts per day for six weeks, asking
them (among other things) whether they were craving a particular drug
(yes/no). At the most basic level, I want to know whether the likelihood of
craving the drug changed across time.
Given the variable time intervals of measurement and many missing data
points, a continuous-time first-order autocorrelation model seems
necessary.
I found tutorials on how to allow for continuous-time autocorrelation and
missing data in an LMM, using nlme::lme and corCAR1, but I am at a loss as
to what to do in a GLMM.
I would be thankful for any suggestions on how to analyze this kind of data
in R.
Dennis
------------------------------
Subject: Digest Footer
_______________________________________________
R-sig-mixed-models mailing list
R-sig-mixed-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
------------------------------
End of R-sig-mixed-models Digest, Vol 134, Issue 39
***************************************************
_____________________________________
Professor Diana Kornbrot
Mobile
+44 (0) 7403 18 16 12
Work
University of Hertfordshire
College Lane, Hatfield, Hertfordshire AL10 9AB, UK
+44 (0) 170 728 4626
d.e.kornbrot at herts.ac.uk<mailto:d.e.kornbrot at herts.ac.uk>
http://dianakornbrot.wordpress.com/
http://go.herts.ac.uk/Diana_Kornbrot
skype: kornbrotme
Home
19 Elmhurst Avenue
London N2 0LT, UK
+44 (0) 208 444 2081
------------------------------------------------------------