Re: [R] Mapping 2D to 3D
> Understood I'd recommend you try to be more precise. > I just began looking at the volcano dataset which uses geom_contour. The volcano dataset does *not* use geom_contour. However, the help file for the volcano dataset, does use the filled.contour function, in its example. > I now realize that the function stat_density_2d really maps a heatmap If I hadn't read the rest of this thread, I wouldn't know what you meant by "maps" a heatmap. The kde2d function returns a list, containing a density matrix. (As per my previous post). The plotting functions, compute the density via the above density estimation function, and then plot that density, in some form. I suppose you could say the plotting functions map observations to density estimates, then map the density estimates to contours and/or other graphic data, and then map the graphic data to a plot, which is seen by a user... ...but it's probably easier to just say plot the density. >of a computed variable. It's rare in probability theory to refer to density as a "variable". (Which is relevant because density estimates are estimates of probability distributions). However, it is common in computer graphics and geometry, to use "z" for a "third variable". And in applied statistics and data science, "variable" could mean anything... So, be careful there... Based on your posts, I take it you want to plot a function of two variables (or plot a matrix of values), using a 2d plot. There are a number of options here. Contour plots. Filled contour plots. Heatmaps. Plots using hex/other binning. Maybe others...? Additionally, there are 3d plots, such as surface plots. And I note that it's possible to plot contour lines on top of color-filled contours or heatmaps. __ 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] CRAN R For Windows 3.6.3
> On Sep 19, 2020, at 1:44 PM, Duncan Murdoch wrote: > > On 18/09/2020 1:39 p.m., Shapira, Leeor via R-help wrote: >> Can you please let me know the End of Life and End of Vendor Support dates >> for CRAN R for Windows 3.6.3? Thank you. > > R doesn't have either of those. There is no vendor support ever. It is free > software; it is up to its users to support it. On the other hand, it is free > software, so you can use it forever. > > In practice, there is de facto support from its authors in that they are very > responsive to bug reports. That ends with the next release, so 3.6.3 support > ended in April, 2020 when R 4.0.0 was released. > > Another way to think of support and end of life equivalents is to ask how > long CRAN will provide the source code to packages for it. There are no time > limits on that, though it can be some work to find a set and tools to build > them if you are using older releases. > > And finally, you might want to know how long CRAN will keep updating binary > packages for R 3.6.3. I think that should continue until the release of R > 4.1.0, sometime around April 2021. > > Duncan Murdoch Hi, Just to add on to Duncan's comments, you may want to read the Software Development Life Cycle (SDLC) document here: https://www.r-project.org/certification.html That will give you insights into R's development, release and maintenance timelines. Regards, Marc Schwartz __ 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] How can we get a predicted value that are used to plot the figure using a plot_model function of sjPlot?
As no one has responded. Typically, > ?predict so > predict(fit) should give you fitted values for the class of fit, whatever it is. Cheers, Bert 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 Sat, Sep 19, 2020 at 1:29 AM Peter Wagey wrote: > Hi R users, > I was trying to create a figure of three-way-interactions. There is a > function "plot-model" but I was wondering whether we can extract the > predicted value before we run the "plot-model" function. > For example: > in this example, > plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]", > "c161sex")) > How can we see the predicted values that are used to plot the figure? If we > can see the data (predicted values), we could use other functions to create > another type of figures. > Thank you very much for your suggestions. > > Thanks, > > Peter > # > library(sjPlot) > library(sjmisc) > library(ggplot2) > data(efc) > theme_set(theme_sjplot()) > > # make categorical > efc$c161sex <- to_factor(efc$c161sex) > > # fit model with 3-way-interaction > fit <- lm(neg_c_7 ~ c12hour * barthtot * c161sex, data = efc) > > # select only levels 30, 50 and 70 from continuous variable Barthel-Index > plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]", > "c161sex")) > > How can we get the predicted value that is used to plot the graph? we would > like to see the predicted value using three groups of barthtot > [30,50,70].Is there any way we can extract the data (predicted value) so > that we can use other graphic functions to create figures? > > [[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] CRAN R For Windows 3.6.3
If you have production code written in R that make it expensive to even consider upgrading to the latest R, it may be worth paying the support fees of an organization like RStudio. Otherwise, I think it make sense to upgrade to the latest version and hope for the best. If you encounter problems, you can ask someplace on StackExchange or one of the R email lists like this or a package maintainer, as Duncan said. Spencer On 2020-09-19 12:44, Duncan Murdoch wrote: On 18/09/2020 1:39 p.m., Shapira, Leeor via R-help wrote: Can you please let me know the End of Life and End of Vendor Support dates for CRAN R for Windows 3.6.3? Thank you. R doesn't have either of those. There is no vendor support ever. It is free software; it is up to its users to support it. On the other hand, it is free software, so you can use it forever. In practice, there is de facto support from its authors in that they are very responsive to bug reports. That ends with the next release, so 3.6.3 support ended in April, 2020 when R 4.0.0 was released. Another way to think of support and end of life equivalents is to ask how long CRAN will provide the source code to packages for it. There are no time limits on that, though it can be some work to find a set and tools to build them if you are using older releases. And finally, you might want to know how long CRAN will keep updating binary packages for R 3.6.3. I think that should continue until the release of R 4.1.0, sometime around April 2021. Duncan Murdoch __ 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] Mapping 2D to 3D
On 09/19/2020 12:42 AM, Jeff Newmiller wrote: > When dealing with a 2-d density plot, the z variable is a predefined function > of your x and y data, it is not something you can specify. If you want to > specify z, then you need to use geom_contour. You appear to need to study the > theory of kernel density estimates, which is off topic here. (Technically > contributed packages like ggplot2 are off topic here also, though sometimes > people will answer questions about them anyway.) > > On September 18, 2020 6:34:43 PM PDT, H wrote: >> On 09/18/2020 02:26 AM, Jeff Newmiller wrote: >>> No, but fortunately you are off in the weeds. Density has an >> internally-computed "z" coordinate... you should be looking at >> ?geom_contour. >>> On September 17, 2020 7:17:33 PM PDT, H >> wrote: I am trying to understand how to map 2D to 3D using ggplot() and eventually plot_gg(). I am, however, stuck on understanding how to express the third variable to be mapped. This example: ggdiamonds = ggplot(diamonds, aes(x, depth)) + stat_density_2d(aes(fill = stat(nlevel)), geom = "polygon", n = 100, bins = 10,contour = TRUE) + facet_wrap(clarity~.) + scale_fill_viridis_c(option = "A") uses a variable nlevel that I now understand is calculated during >> the building of the ggplot but I have not figured out from where it is calculated or how to specify a variable of my choosing. Does anyone have a good reference for understanding how to specify >> this variable? Most examples on the 'net seem to use the same dataset but >> do not specify this particular aspect... __ 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. >> But looking at the code in my message above, how does one know what >> stat(nlevel) refers to? What if I wanted to map another variable in >> this particular dataset?? >> >> __ >> 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. Understood, I just began looking at the volcano dataset which uses geom_contour. I now realize that the function stat_density_2d really maps a heatmap of a computed variable. __ 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] CRAN R For Windows 3.6.3
On 18/09/2020 1:39 p.m., Shapira, Leeor via R-help wrote: Can you please let me know the End of Life and End of Vendor Support dates for CRAN R for Windows 3.6.3? Thank you. R doesn't have either of those. There is no vendor support ever. It is free software; it is up to its users to support it. On the other hand, it is free software, so you can use it forever. In practice, there is de facto support from its authors in that they are very responsive to bug reports. That ends with the next release, so 3.6.3 support ended in April, 2020 when R 4.0.0 was released. Another way to think of support and end of life equivalents is to ask how long CRAN will provide the source code to packages for it. There are no time limits on that, though it can be some work to find a set and tools to build them if you are using older releases. And finally, you might want to know how long CRAN will keep updating binary packages for R 3.6.3. I think that should continue until the release of R 4.1.0, sometime around April 2021. Duncan Murdoch __ 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] CRAN R For Windows 3.6.3
Can you please let me know the End of Life and End of Vendor Support dates for CRAN R for Windows 3.6.3? Thank you. [[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] Stats help for dissertation project
In fairness to Raija Hallam, I've met masters and doctoral students whose supervisors hadn't a clue. (Heck, I once worked at a University where the staff evaluation process involved taking the means of 5-point ordinal variables...) Two of these cases stick in my mind: one where the student had more observed variables than cases, and one where the student was controlling for the effect of the order in which the treatments were applied by applying the treatments in the same order to every subject. To Raija Hallam, do web searches for "linear regression in R" and "logistic regression in R". Look at the R web site r-project.org, specifically at https://www.r-project.org/doc/bib/R-books.html Print off a copy of that list of books, go to your University library, and borrow a couple, maybe an introductory book and "An R Companion to Applied Regression". It is incredibly important that you have a very clear idea of your research question, your experiment structure, and the nature of your data. Here's one point which even your supervisor is very likely to miss: the micronutrient analysis *MAY* best be regarded as COMPOSITIONAL DATA. R has a package called "compositions" that may be helpful. The description says "Regression, classification, contour plots, hypothesis testing and fitting of distributions for compositional data are some of the functions included. The standard text-book for such data is John Aitchison's (1986) ``The statistical analysis of compositional data''. Chapman & Hall." If I am right about this, then analysing your data using "standard" techniques may be *seriously* misleading. Ask your supervisor to find a statistician who can talk to you about your problem; at my former university we'd probably suggest inviting co-supervision to make sure your statistical analyses are credible. On Sat, 19 Sep 2020 at 22:30, Michael Dewey wrote: > Dear Raija > > This list is primarily for R programming questions so most of your post > is off-topic here. If you are registered for a degree presumably someone > is paying a fee to your institution and someone there is being paid to > supervise your project so I would have thought they would be the first > port of call. If they fail to meet their obligations then there is a > site Cross Validated where you may have better luck. > > Michael > > On 18/09/2020 18:19, Raija Hallam wrote: > > Hello, > > > > I am a conservation Masters student who is new to R and in need of some > > confirmation of my methods/ stats help! > > > > My dissertation project is looking at the micronutrient intake (iron, > zinc, > > calcium, magnesium and folic acid/folate) of 18 female monkeys, 14 of > which > > are reproductively 'successful' (their infant survived past 1 year) and 4 > > of which are reproductively 'unsuccessful' (their infant did not survive > to > > 1 year). The females go through a number of stages throughout their > > pregnancy, and I would like to focus on 2 of these stages, early > gestation > > and early lactation, as these appear in the literature to be important > > stages in terms of nutrition. Each stage is broken down into 4 week > periods > > so I have G1, G2 and G3 as early gestation and L1, L2, L3 and L4 as early > > lactation. These could also be combined into just 2 reproductive stages; > > early gestation (EG) and early lactation (EL), to make the model a bit > > simpler. > > > > > > *I first would like to investigate how micronutrient intake is affected > by > > the reproductive stage of females.* > > > > To investigate this I am thinking of doing a multivariate multiple > > regression general linear model, controlling for Female ID: > > ironintake ~ repphase + (1/FemaleID) > > zincintake ~ repphase + (1/FemaleID) > > etc. > > > > > > *I would also like to investigate how the micronutrients they intake > affect > > reproductive 'successfulness'.* > > > > To investigate this I am thinking of doing a binomial logistic regression > > generalised linear model, again controlling for Female ID: > > Repsuccess ~ ironintake + zincintake + calciumintake etc... +(1/FemaleID) > > > > > > As I'm new to R and a bit rusty with my stats knowledge I would be very > > grateful for any comments on my current stats tests and methods outlined > > above. If there are other tests that would fit my data better then I'm > all > > ears! > > > > Thank you! > > > > [[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. > > > > -- > Michael > http://www.dewey.myzen.co.uk/home.html > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read
Re: [R] Stats help for dissertation project
Dear Raija This list is primarily for R programming questions so most of your post is off-topic here. If you are registered for a degree presumably someone is paying a fee to your institution and someone there is being paid to supervise your project so I would have thought they would be the first port of call. If they fail to meet their obligations then there is a site Cross Validated where you may have better luck. Michael On 18/09/2020 18:19, Raija Hallam wrote: Hello, I am a conservation Masters student who is new to R and in need of some confirmation of my methods/ stats help! My dissertation project is looking at the micronutrient intake (iron, zinc, calcium, magnesium and folic acid/folate) of 18 female monkeys, 14 of which are reproductively 'successful' (their infant survived past 1 year) and 4 of which are reproductively 'unsuccessful' (their infant did not survive to 1 year). The females go through a number of stages throughout their pregnancy, and I would like to focus on 2 of these stages, early gestation and early lactation, as these appear in the literature to be important stages in terms of nutrition. Each stage is broken down into 4 week periods so I have G1, G2 and G3 as early gestation and L1, L2, L3 and L4 as early lactation. These could also be combined into just 2 reproductive stages; early gestation (EG) and early lactation (EL), to make the model a bit simpler. *I first would like to investigate how micronutrient intake is affected by the reproductive stage of females.* To investigate this I am thinking of doing a multivariate multiple regression general linear model, controlling for Female ID: ironintake ~ repphase + (1/FemaleID) zincintake ~ repphase + (1/FemaleID) etc. *I would also like to investigate how the micronutrients they intake affect reproductive 'successfulness'.* To investigate this I am thinking of doing a binomial logistic regression generalised linear model, again controlling for Female ID: Repsuccess ~ ironintake + zincintake + calciumintake etc... +(1/FemaleID) As I'm new to R and a bit rusty with my stats knowledge I would be very grateful for any comments on my current stats tests and methods outlined above. If there are other tests that would fit my data better then I'm all ears! Thank you! [[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. -- Michael http://www.dewey.myzen.co.uk/home.html __ 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] fusion of two matrices (numerical and logical)
(1) Using 'C == TRUE' (when you know C is logical) is equivalent to just plain C, only obscure. Similarly, 'C == FALSE' is more confusing than !C. (2) Consider B[C]. The rows of C have 2, 1, 1, 2, 1 TRUE. entries, so the result here *cannot* be a rectangular array. And whatever it is, it contains only the elements where C is true. (3) You probably already knew that 'ifelse' is vectorised. What you may not have realised is that it preserves array dimensions as well. > A <- cbind(c(1,2), c(3,4)) > B <- cbind(c(5,6), c(7,8)) > C <- cbind(c(FALSE,TRUE), c(TRUE,FALSE)) > ifelse(C, A, B) [,1] [,2] [1,]53 [2,]28 > ifelse(C, A, 0) [,1] [,2] [1,]03 [2,]20 Isn't it nice when the obvious code just works? On Sun, 6 Sep 2020 at 06:18, Vivek Sutradhara wrote: > Hi > I would like to get help in combining two matrices. Here is my example: > A <- 1:20 > B <- matrix(A,nrow=5,ncol=4) > # B is a numerical matrix > C <- B<7 > C[4,4] <- TRUE > # C is a logical matrix > # if I combine A and C, I get a vector > D1 <- A[C==TRUE] > D1 > D2 <- A[C==FALSE] > D2 > > I want to get a matrix with the same dimensions as matrix A. At the > coordinates given by the vector D1, I want to retain the values in > matrix A. At the locations in D2, I want a zero value. > I want to know if I can do this without using any loops. > Thanks, Vivek > > [[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.
[R] How can we get a predicted value that are used to plot the figure using a plot_model function of sjPlot?
Hi R users, I was trying to create a figure of three-way-interactions. There is a function "plot-model" but I was wondering whether we can extract the predicted value before we run the "plot-model" function. For example: in this example, plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]", "c161sex")) How can we see the predicted values that are used to plot the figure? If we can see the data (predicted values), we could use other functions to create another type of figures. Thank you very much for your suggestions. Thanks, Peter # library(sjPlot) library(sjmisc) library(ggplot2) data(efc) theme_set(theme_sjplot()) # make categorical efc$c161sex <- to_factor(efc$c161sex) # fit model with 3-way-interaction fit <- lm(neg_c_7 ~ c12hour * barthtot * c161sex, data = efc) # select only levels 30, 50 and 70 from continuous variable Barthel-Index plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]", "c161sex")) How can we get the predicted value that is used to plot the graph? we would like to see the predicted value using three groups of barthtot [30,50,70].Is there any way we can extract the data (predicted value) so that we can use other graphic functions to create figures? [[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] Stats help for dissertation project
Hello, I am a conservation Masters student who is new to R and in need of some confirmation of my methods/ stats help! My dissertation project is looking at the micronutrient intake (iron, zinc, calcium, magnesium and folic acid/folate) of 18 female monkeys, 14 of which are reproductively 'successful' (their infant survived past 1 year) and 4 of which are reproductively 'unsuccessful' (their infant did not survive to 1 year). The females go through a number of stages throughout their pregnancy, and I would like to focus on 2 of these stages, early gestation and early lactation, as these appear in the literature to be important stages in terms of nutrition. Each stage is broken down into 4 week periods so I have G1, G2 and G3 as early gestation and L1, L2, L3 and L4 as early lactation. These could also be combined into just 2 reproductive stages; early gestation (EG) and early lactation (EL), to make the model a bit simpler. *I first would like to investigate how micronutrient intake is affected by the reproductive stage of females.* To investigate this I am thinking of doing a multivariate multiple regression general linear model, controlling for Female ID: ironintake ~ repphase + (1/FemaleID) zincintake ~ repphase + (1/FemaleID) etc. *I would also like to investigate how the micronutrients they intake affect reproductive 'successfulness'.* To investigate this I am thinking of doing a binomial logistic regression generalised linear model, again controlling for Female ID: Repsuccess ~ ironintake + zincintake + calciumintake etc... +(1/FemaleID) As I'm new to R and a bit rusty with my stats knowledge I would be very grateful for any comments on my current stats tests and methods outlined above. If there are other tests that would fit my data better then I'm all ears! Thank you! [[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.