Luigi Marongiu
2021-Oct-24 05:39 UTC
[R] generate average frame from different data frames
Thank you. Sorry for the fuzziness of the question but I find it difficult to give a proper definition of the problem. I have given a graphical rendering on this post https://www.researchgate.net/post/How_to_find_95_CI_of_a_matrix_of_classification_data As you can see in the figure, there are dots where the same value is represented all the time, and others where the values fluctuate. I would like to generate the "mean" merge of the figures. (Perhaps also with lines saying: this value comes out 9/10 of times, this 5/10 of times...). The problem is that the Z values are factors, not numbers. On Sun, Oct 24, 2021 at 12:08 AM Jim Lemon <drjimlemon at gmail.com> wrote:> > Hi Luigi, > I may be missing the point, but: > > matrix((z1+z2+z3)/3,ncol=10) > > gives you the mean rating for each item, and depending upon what > distribution you choose, the confidence intervals could be calculated > in much the same way. > > Jim > > On Sun, Oct 24, 2021 at 7:16 AM Luigi Marongiu <marongiu.luigi at gmail.com> wrote: > > > > Hello, > > I have a series of classifications of the same data. I saved this > > classification in a single dataframe (but it could be a list). X and Y > > are the variable and Z is the classification by three raters. `I` is > > the individual identifier of each entry: > > ``` > > z1 = c(0,0,0,0,0,1,0,0,0,2, > > 0,1,1,1,0,0,0,1,0,2, > > 0,1,1,2,0,0,0,1,0,2, > > 1,1,1,2,1,0,0,1,1,2, > > 1,0,0,2,1,1,0,1,2,0) > > z2 = c(0,0,0,0,0,1,0,0,1,1, > > 0,1,1,2,0,0,0,1,1,2, > > 0,0,0,1,0,0,0,1,0,0, > > 1,2,1,2,1,0,0,1,1,2, > > 1,0,1,2,1,1,0,1,2,0) > > z3 = c(0,0,0,2,0,0,0,0,0,2, > > 0,1,0,2,0,0,0,1,0,2, > > 0,1,1,2,0,0,0,1,0,2, > > 1,1,1,2,1,0,0,2,1,2, > > 2,0,1,1,1,1,0,1,1,0) > > df = data.frame(X=rep(1:5,3), Y=rep(1:5,3), Z=factor(c(z1,z2,z3)), I =1:150) > > ``` > > Is there a way to obtain a kind of heath map for each point? Let's say > > for the point (x=1,y-1), what was the most common (average) > > classification? Is it possible to get the 95% CI of that mean? > > Would Two-Dimensional Kernel Density Estimation be the right path? > > Thank you > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code.-- Best regards, Luigi
Hi Luigi, In that case you will want a binomial confidence interval. Jim On Sun, Oct 24, 2021 at 4:39 PM Luigi Marongiu <marongiu.luigi at gmail.com> wrote:> > Thank you. Sorry for the fuzziness of the question but I find it > difficult to give a proper definition of the problem. I have given a > graphical rendering on this post > https://www.researchgate.net/post/How_to_find_95_CI_of_a_matrix_of_classification_data > As you can see in the figure, there are dots where the same value is > represented all the time, and others where the values fluctuate. I > would like to generate the "mean" merge of the figures. (Perhaps also > with lines saying: this value comes out 9/10 of times, this 5/10 of > times...). > The problem is that the Z values are factors, not numbers. > > On Sun, Oct 24, 2021 at 12:08 AM Jim Lemon <drjimlemon at gmail.com> wrote: > > > > Hi Luigi, > > I may be missing the point, but: > > > > matrix((z1+z2+z3)/3,ncol=10) > > > > gives you the mean rating for each item, and depending upon what > > distribution you choose, the confidence intervals could be calculated > > in much the same way. > > > > Jim > > > > On Sun, Oct 24, 2021 at 7:16 AM Luigi Marongiu <marongiu.luigi at gmail.com> wrote: > > > > > > Hello, > > > I have a series of classifications of the same data. I saved this > > > classification in a single dataframe (but it could be a list). X and Y > > > are the variable and Z is the classification by three raters. `I` is > > > the individual identifier of each entry: > > > ``` > > > z1 = c(0,0,0,0,0,1,0,0,0,2, > > > 0,1,1,1,0,0,0,1,0,2, > > > 0,1,1,2,0,0,0,1,0,2, > > > 1,1,1,2,1,0,0,1,1,2, > > > 1,0,0,2,1,1,0,1,2,0) > > > z2 = c(0,0,0,0,0,1,0,0,1,1, > > > 0,1,1,2,0,0,0,1,1,2, > > > 0,0,0,1,0,0,0,1,0,0, > > > 1,2,1,2,1,0,0,1,1,2, > > > 1,0,1,2,1,1,0,1,2,0) > > > z3 = c(0,0,0,2,0,0,0,0,0,2, > > > 0,1,0,2,0,0,0,1,0,2, > > > 0,1,1,2,0,0,0,1,0,2, > > > 1,1,1,2,1,0,0,2,1,2, > > > 2,0,1,1,1,1,0,1,1,0) > > > df = data.frame(X=rep(1:5,3), Y=rep(1:5,3), Z=factor(c(z1,z2,z3)), I =1:150) > > > ``` > > > Is there a way to obtain a kind of heath map for each point? Let's say > > > for the point (x=1,y-1), what was the most common (average) > > > classification? Is it possible to get the 95% CI of that mean? > > > Would Two-Dimensional Kernel Density Estimation be the right path? > > > Thank you > > > > > > ______________________________________________ > > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > -- > Best regards, > Luigi