Re: [R] Is there some way to customize colours for the View output?

2024-05-07 Thread Rolf Turner


On Tue, 7 May 2024 06:34:50 -0400
Duncan Murdoch  wrote:

> On 07/05/2024 6:31 a.m., Iago Giné Vázquez wrote:
> > Thanks Duncan.
> > 
> > I am currently on Windows. Is there any solution for it?
> 
> Switch to Linux or MacOS?


Fortune nomination!

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
 +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619

__
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] [R-sig-ME] lmer error: number of observations <= number of random effects

2024-05-07 Thread Bert Gunter
I think you should seek out a local statistician with whom to consult if at
all possible, as the details of your research goals and the nature of the
data you have to meet those goals matter and cannot be effectively
discussed in a remote forum like this. That is, to be blunt, you seem to be
risk of producing junk. Just my opinion, which you are of course free to
ignore. Certainly, no response needed, and I will not say anything further.

Cheers,
Bert

On Tue, May 7, 2024 at 9:12 AM Srinidhi Jayakumar via R-help <
r-help@r-project.org> wrote:

> Thank you very  much for your responses!
>
> What if I reduce the model to
>  modelLSI3 <- lmer(SA ~ Index1* LSI+ (1+LSI |ID),data = LSIDATA, control =
> lmerControl(optimizer ="bobyqa"), REML=TRUE).
> This would allow me to see the random effects of LSI and I can drop the
> random effect of age (Index1) since I can see that in the unconditional
> model [model0 <- lmer(SA ~ Index1+ (1+Index1|ID),data = LSIDATA, control =
> lmerControl(optimizer ="bobyqa"), REML=TRUE)]. Would the modelLSI3 also
> have a type 1 error?
>
> Thank you,
> Srinidhi
>
>
>
>
> On Mon, 6 May 2024, 03:11 TT FF,  wrote:
>
> > See if this paper may help If it helps reducing the model when you have
> > few observations. the (1|ID) may increase the type 1 error.
> > https://journals.sagepub.com/doi/10.1177/25152459231214454
> >
> > Best
> >
> > On 6 May 2024, at 07:45, Thierry Onkelinx via R-sig-mixed-models <
> > r-sig-mixed-mod...@r-project.org> wrote:
> >
> > Dear Srinidhi,
> >
> > You are trying to fit 1 random intercept and 2 random slopes per
> > individual, while you have at most 3 observations per individual. You
> > simply don't have enough data to fit the random slopes. Reduce the random
> > part to (1|ID).
> >
> > Best regards,
> >
> > Thierry
> >
> > ir. Thierry Onkelinx
> > Statisticus / Statistician
> >
> > Vlaamse Overheid / Government of Flanders
> > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
> AND
> > FOREST
> > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> > thierry.onkel...@inbo.be
> > Havenlaan 88 bus 73, 1000 Brussel
> > *Postadres:* Koning Albert II-laan 15 bus 186, 1210 Brussel
> > *Poststukken die naar dit adres worden gestuurd, worden ingescand en
> > digitaal aan de geadresseerde bezorgd. Zo kan de Vlaamse overheid haar
> > dossiers volledig digitaal behandelen. Poststukken met de vermelding
> > ‘vertrouwelijk’ worden niet ingescand, maar ongeopend aan de
> geadresseerde
> > bezorgd.*
> > www.inbo.be
> >
> >
> >
> ///
> > To call in the statistician after the experiment is done may be no more
> > than asking him to perform a post-mortem examination: he may be able to
> say
> > what the experiment died of. ~ Sir Ronald Aylmer Fisher
> > The plural of anecdote is not data. ~ Roger Brinner
> > The combination of some data and an aching desire for an answer does not
> > ensure that a reasonable answer can be extracted from a given body of
> data.
> > ~ John Tukey
> >
> >
> ///
> >
> > 
> >
> >
> > Op ma 6 mei 2024 om 01:59 schreef Srinidhi Jayakumar via
> R-sig-mixed-models
> > :
> >
> > I am running a multilevel growth curve model to examine predictors of
> > social anhedonia (SA) trajectory through ages 12, 15 and 18. SA is a
> > continuous numeric variable. The age variable (Index1) has been coded as
> 0
> > for age 12, 1 for age 15 and 2 for age 18. I am currently using a time
> > varying predictor, stress (LSI), which was measured at ages 12, 15 and
> 18,
> > to examine whether trajectory/variation in LSI predicts difference in SA
> > trajectory. LSI is a continuous numeric variable and was grand-mean
> > centered before using in the models. The data has been converted to long
> > format with SA in 1 column, LSI in the other, ID in another, and age in
> > another column. I used the code below to run my model using lmer.
> However,
> > I get the following error. Please let me know how I can solve this error.
> > Please note that I have 50% missing data in SA at age 12.
> > modelLSI_maineff_RE <- lmer(SA ~ Index1* LSI+ (1 + Index1+LSI |ID), data
> =
> > LSIDATA, control = lmerControl(optimizer ="bobyqa"), REML=TRUE)
> > summary(modelLSI_maineff_RE)
> > Error: number of observations (=1080) <= number of random effects (=1479)
> > for term (1 + Index1 + LSI | ID); the random-effects parameters and the
> > residual variance (or scale parameter) are probably unidentifiable
> >
> > I did test the within-person variance for the LSI variable and the
> > within-person variance is significant from the Greenhouse-Geisser,
> > Hyunh-Feidt tests.
> >
> > I also tried control = lmerControl(check.nobs.vs.nRE = "ignore") which
> gave
> > me the following output. modelLSI_maineff_RE <- lmer(SA ~ Index1* LSI+
> (1 +
> > Index1+LSI |ID), data 

Re: [R] [R-sig-ME] lmer error: number of observations <= number of random effects

2024-05-07 Thread Srinidhi Jayakumar via R-help
Thank you very  much for your responses!

What if I reduce the model to
 modelLSI3 <- lmer(SA ~ Index1* LSI+ (1+LSI |ID),data = LSIDATA, control =
lmerControl(optimizer ="bobyqa"), REML=TRUE).
This would allow me to see the random effects of LSI and I can drop the
random effect of age (Index1) since I can see that in the unconditional
model [model0 <- lmer(SA ~ Index1+ (1+Index1|ID),data = LSIDATA, control =
lmerControl(optimizer ="bobyqa"), REML=TRUE)]. Would the modelLSI3 also
have a type 1 error?

Thank you,
Srinidhi




On Mon, 6 May 2024, 03:11 TT FF,  wrote:

> See if this paper may help If it helps reducing the model when you have
> few observations. the (1|ID) may increase the type 1 error.
> https://journals.sagepub.com/doi/10.1177/25152459231214454
>
> Best
>
> On 6 May 2024, at 07:45, Thierry Onkelinx via R-sig-mixed-models <
> r-sig-mixed-mod...@r-project.org> wrote:
>
> Dear Srinidhi,
>
> You are trying to fit 1 random intercept and 2 random slopes per
> individual, while you have at most 3 observations per individual. You
> simply don't have enough data to fit the random slopes. Reduce the random
> part to (1|ID).
>
> Best regards,
>
> Thierry
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkel...@inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> *Postadres:* Koning Albert II-laan 15 bus 186, 1210 Brussel
> *Poststukken die naar dit adres worden gestuurd, worden ingescand en
> digitaal aan de geadresseerde bezorgd. Zo kan de Vlaamse overheid haar
> dossiers volledig digitaal behandelen. Poststukken met de vermelding
> ‘vertrouwelijk’ worden niet ingescand, maar ongeopend aan de geadresseerde
> bezorgd.*
> www.inbo.be
>
>
> ///
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> ///
>
> 
>
>
> Op ma 6 mei 2024 om 01:59 schreef Srinidhi Jayakumar via R-sig-mixed-models
> :
>
> I am running a multilevel growth curve model to examine predictors of
> social anhedonia (SA) trajectory through ages 12, 15 and 18. SA is a
> continuous numeric variable. The age variable (Index1) has been coded as 0
> for age 12, 1 for age 15 and 2 for age 18. I am currently using a time
> varying predictor, stress (LSI), which was measured at ages 12, 15 and 18,
> to examine whether trajectory/variation in LSI predicts difference in SA
> trajectory. LSI is a continuous numeric variable and was grand-mean
> centered before using in the models. The data has been converted to long
> format with SA in 1 column, LSI in the other, ID in another, and age in
> another column. I used the code below to run my model using lmer. However,
> I get the following error. Please let me know how I can solve this error.
> Please note that I have 50% missing data in SA at age 12.
> modelLSI_maineff_RE <- lmer(SA ~ Index1* LSI+ (1 + Index1+LSI |ID), data =
> LSIDATA, control = lmerControl(optimizer ="bobyqa"), REML=TRUE)
> summary(modelLSI_maineff_RE)
> Error: number of observations (=1080) <= number of random effects (=1479)
> for term (1 + Index1 + LSI | ID); the random-effects parameters and the
> residual variance (or scale parameter) are probably unidentifiable
>
> I did test the within-person variance for the LSI variable and the
> within-person variance is significant from the Greenhouse-Geisser,
> Hyunh-Feidt tests.
>
> I also tried control = lmerControl(check.nobs.vs.nRE = "ignore") which gave
> me the following output. modelLSI_maineff_RE <- lmer(SA ~ Index1* LSI+ (1 +
> Index1+LSI |ID), data = LSIDATA, control = lmerControl(check.nobs.vs.nRE =
> "ignore", optimizer ="bobyqa", check.conv.singular = .makeCC(action =
> "ignore", tol = 1e-4)), REML=TRUE)
>
> summary(modelLSI_maineff_RE)
> Linear mixed model fit by REML. t-tests use Satterthwaite's method
> ['lmerModLmerTest']
> Formula: SA ~ Index1 * LSI + (1 + Index1 + LSI | ID)
> Data: LSIDATA
> Control: lmerControl(check.nobs.vs.nRE = "ignore", optimizer = "bobyqa",
> check.conv.singular = .makeCC(action = "ignore", tol = 1e-04))
>
> REML criterion at convergence: 7299.6
>
> Scaled residuals:
> Min 1Q Median 3Q Max
> -2.7289 -0.4832 -0.1449 0.3604 4.5715
>
> Random effects:
> Groups Name Variance Std.Dev. Corr
> ID (Intercept) 30.2919 5.5038
> Index1 2.4765 1.5737 -0.15
> LSI 0.1669 0.4085 -0.23 

[R] Problem with creating a PCA graph in a loop

2024-05-07 Thread gavin duley
Hi all,

I am having enormous problems with a loop that iterates over different
levels in the factor wine.data$Time (levels T06, T09, and T12) and
creates a PCA and graph for individuals at that time only. These
graphs need to be accessible outside the loop, so I can combine them
using ggpubr::ggarrange to produce a figure for a paper.

The difficulty I am having is with the labels produced by
ggrepel::geom_label_repel. Since the loop uses the variable i to set
the level of wine.data$Time, when used outside the loop the labels
produced by geom_label_repel are always for T12 (i.e., the last level
run by the loop).

Oddly, this only affects the labels: the title, set using
ggtitle(paste0("PCA of wine.data observations at Time ", print(i))),
shows the correct time, and the datapoints are for the correct time.

Is there some way to get geom_label_repel to read current_rownames and
store the values in the ggplot object, rather than to reload them
every time I display or save the ggplot graph?

Thanks!
gavin,

Code for reference. I can provide a sample dataset for reproducibility
if needed.

for(i in levels(wine.data$Time)){
  print(i)
  wine.data.filt <- filter(wine.data,Time == i)
  current_rownames <- rownames(wine.data.filt)
  wine.data.filt.pca <- dudi.pca(wine.data.filt[3:11],
   nf=6,
   scannf=F)
  wine.data_quanti_sup <- wine.data.filt[,12, drop = FALSE]
  head(wine.data_quanti_sup)

  # Colour by Treatment
  assign(paste0("individ_", i),
 fviz_pca_ind(wine.data.filt.pca,
  geom.ind = "point",
  mean.point=F,
  col.ind = wine.data.filt$Treatment,
  ellipse.type = "confidence",
  legend.title = "Groups"
 )+ggtitle(paste0("PCA of wine.data observations at Time ", print(i)))
 +
   scale_colour_manual(
 values = c(
   "Control" = "#00A087FF",
   "Low" = "#3C5488FF",
   "High" = "#E64B35FF")
   ) + geom_label_repel(position =
ggpp::position_nudge_center(0.2, 0.1, 0, 0),
box.padding = 0.5,
max.overlaps = Inf,
aes(label=current_rownames,
colour=wine.data.filt$Treatment
)
   ) +
   scale_fill_manual(
 values = c(
   "Control" = "#00A087FF",
   "Low" = "#3C5488FF",
   "High" = "#E64B35FF")
   ))
}

__
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] Is there some way to customize colours for the View output?

2024-05-07 Thread Ivan Krylov via R-help
В Tue, 7 May 2024 09:51:55 +
Iago Giné Vázquez  пишет:

> In the View help, it is told that:
> 
> On Windows, the initial size of the data viewer window is taken
> from the default dimensions of a pager (see Rconsole), but adjusted
> downwards to show a whole number of rows and columns.

The Windows data editor lives in
src/library/utils/src/windows/dataentry.c [1]. There are references to
the array guiColors and indices dataeditbg, dataedituser, dataeditbg,
dataeditfg. I was able to find the colours with these names in the GUI
preferences, edit them and see an effect on the edit() window.

-- 
Best regards,
Ivan

[1]
https://svn.r-project.org/R/trunk/src/library/utils/src/windows/dataentry.c

__
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] Is there some way to customize colours for the View output?

2024-05-07 Thread Duncan Murdoch

On 07/05/2024 6:31 a.m., Iago Giné Vázquez wrote:

Thanks Duncan.

I am currently on Windows. Is there any solution for it?


Switch to Linux or MacOS?

Duncan Murdoch



Best regards,
Iago



*De:* Duncan Murdoch 
*Enviat el:* dimarts, 7 de maig de 2024 12:24
*Per a:* Iago Giné Vázquez ; r-help@r-project.org 


*Tema:* Re: [R] Is there some way to customize colours for the View output?
If you are using X11, then the paragraph on X resources is relevant.
Create a file named .Xresources in your home directory, and put a line like

R_dataentry.background: green

in it.  On my Mac, this has to be in place before Xquartz is started.
There is probably a similar restriction on other platforms.

Colour names (used for foreground and background) can be words or hex
colors like #ff .  I don't know the format for "geometry", but I'd
guess it's like the -geometry argument to X11 apps, e.g. 1000x1000+0+0.

If you are on Windows, none of this is relevant.

Duncan Murdoch

On 07/05/2024 5:51 a.m., Iago Giné Vázquez wrote:

Hi all,

As the email subject tells, I write to ask if there is the chance to customize 
the colours (and in particular the background) of the `View` output window.


In the View help, it is told that:

  On Windows, the initial size of the data viewer window is taken from the 
default dimensions of a pager (see Rconsole), but adjusted downwards to show a 
whole number of rows and columns.

So if it works for the sizes, it could work for the colours. But after modifying

## Colours for console and pager(s)
# (see rw/etc/rgb.txt for the known colours).
background = gray9
normaltext = yellow
usertext = YellowGreen
highlight = golderod

I did not have success.

On the other hand, in the data.entry it is told that

  The data entry window responds to X resources of class R_dataentry. 
Resources foreground, background and geometry are utilized.

But I do not know if this is related and how to modify those resources.

Can someone help me?

If this is not possible, is there any chance of making a feature request of 
this to R-devel? (I mean, I could write to R-devel list, but do you think there 
would be any interest in developing this?)

Thanks!
Best regards,

Iago

    [[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@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] Is there some way to customize colours for the View output?

2024-05-07 Thread Iago Giné Vázquez
Thanks Duncan.

I am currently on Windows. Is there any solution for it?

Best regards,
Iago



De: Duncan Murdoch 
Enviat el: dimarts, 7 de maig de 2024 12:24
Per a: Iago Gin� V�zquez ; r-help@r-project.org 

Tema: Re: [R] Is there some way to customize colours for the View output?

If you are using X11, then the paragraph on X resources is relevant.
Create a file named .Xresources in your home directory, and put a line like

R_dataentry.background: green

in it.  On my Mac, this has to be in place before Xquartz is started.
There is probably a similar restriction on other platforms.

Colour names (used for foreground and background) can be words or hex
colors like #ff .  I don't know the format for "geometry", but I'd
guess it's like the -geometry argument to X11 apps, e.g. 1000x1000+0+0.

If you are on Windows, none of this is relevant.

Duncan Murdoch

On 07/05/2024 5:51 a.m., Iago Gin� V�zquez wrote:
> Hi all,
>
> As the email subject tells, I write to ask if there is the chance to 
> customize the colours (and in particular the background) of the `View` output 
> window.
>
>
> In the View help, it is told that:
>
>  On Windows, the initial size of the data viewer window is taken from the 
> default dimensions of a pager (see Rconsole), but adjusted downwards to show 
> a whole number of rows and columns.
>
> So if it works for the sizes, it could work for the colours. But after 
> modifying
>
> ## Colours for console and pager(s)
> # (see rw/etc/rgb.txt for the known colours).
> background = gray9
> normaltext = yellow
> usertext = YellowGreen
> highlight = golderod
>
> I did not have success.
>
> On the other hand, in the data.entry it is told that
>
>  The data entry window responds to X resources of class R_dataentry. 
> Resources foreground, background and geometry are utilized.
>
> But I do not know if this is related and how to modify those resources.
>
> Can someone help me?
>
> If this is not possible, is there any chance of making a feature request of 
> this to R-devel? (I mean, I could write to R-devel list, but do you think 
> there would be any interest in developing this?)
>
> Thanks!
> Best regards,
>
> Iago
>
>[[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] Is there some way to customize colours for the View output?

2024-05-07 Thread Duncan Murdoch
If you are using X11, then the paragraph on X resources is relevant. 
Create a file named .Xresources in your home directory, and put a line like


R_dataentry.background: green

in it.  On my Mac, this has to be in place before Xquartz is started. 
There is probably a similar restriction on other platforms.


Colour names (used for foreground and background) can be words or hex 
colors like #ff .  I don't know the format for "geometry", but I'd 
guess it's like the -geometry argument to X11 apps, e.g. 1000x1000+0+0.


If you are on Windows, none of this is relevant.

Duncan Murdoch

On 07/05/2024 5:51 a.m., Iago Giné Vázquez wrote:

Hi all,

As the email subject tells, I write to ask if there is the chance to customize 
the colours (and in particular the background) of the `View` output window.


In the View help, it is told that:

 On Windows, the initial size of the data viewer window is taken from the 
default dimensions of a pager (see Rconsole), but adjusted downwards to show a 
whole number of rows and columns.

So if it works for the sizes, it could work for the colours. But after modifying

## Colours for console and pager(s)
# (see rw/etc/rgb.txt for the known colours).
background = gray9
normaltext = yellow
usertext = YellowGreen
highlight = golderod

I did not have success.

On the other hand, in the data.entry it is told that

 The data entry window responds to X resources of class R_dataentry. 
Resources foreground, background and geometry are utilized.

But I do not know if this is related and how to modify those resources.

Can someone help me?

If this is not possible, is there any chance of making a feature request of 
this to R-devel? (I mean, I could write to R-devel list, but do you think there 
would be any interest in developing this?)

Thanks!
Best regards,

Iago

[[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@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] Is there some way to customize colours for the View output?

2024-05-07 Thread Iago Giné Vázquez
Hi all,

As the email subject tells, I write to ask if there is the chance to customize 
the colours (and in particular the background) of the `View` output window.


In the View help, it is told that:

On Windows, the initial size of the data viewer window is taken from the 
default dimensions of a pager (see Rconsole), but adjusted downwards to show a 
whole number of rows and columns.

So if it works for the sizes, it could work for the colours. But after modifying

## Colours for console and pager(s)
# (see rw/etc/rgb.txt for the known colours).
background = gray9
normaltext = yellow
usertext = YellowGreen
highlight = golderod

I did not have success.

On the other hand, in the data.entry it is told that

The data entry window responds to X resources of class R_dataentry. 
Resources foreground, background and geometry are utilized.

But I do not know if this is related and how to modify those resources.

Can someone help me?

If this is not possible, is there any chance of making a feature request of 
this to R-devel? (I mean, I could write to R-devel list, but do you think there 
would be any interest in developing this?)

Thanks!
Best regards,

Iago

[[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.