Re: [R] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread avi.e.gross
Just to bring it back to R, I want to point out that what many R programmers do 
is not that different. If you develop some skills at analyzing some kinds of 
data and have a sort of toolchest based on past work, then a new project along 
similar lines may move very quickly.  After a while, you may put out a package 
that allows even novices to do a decent job as the code handles so many of the 
details or provides default options you can over-ride.

So if an AI has the ability to use the same tools you provided, and applies 
them properly, is there much difference?

I have seen EXPERTS do horribly when yanked just outside their field of 
expertise. They may use a tool outside the bounds it was designed for, as an 
example, or pick an unfamiliar model that is not applicable or optimal.

The problem with AI is compounded as some kinds of peer feedback may be missing 
while other things have not yet been programmed well that allow some 
selectivity and so on.

But if a simple regression often works well enough, why can't an AI use it too? 

I will say a lot of what people do in R is cleaning the data and getting it 
into the right form. Sometimes humans struggle to detect if say two names are 
the same and someone made a spelling mistake. And humans will still get things 
like that wrong unless they can go back and consult external resources to see 
if say the school has two teachers with similar names or whether all the 
students named should be combined under the same teacher for some purposes.

I will point out there is no good reason to think an Ai would necessarily use R 
or use base R rather than some of the functions in the tidyverse. I am studying 
Wolfram and an amazing amount of work can be done in one liners that rely on 
many thousands of built-in functionality. So why would you want an AI to write 
assembly code or do it in a language like C but rather pick a language well 
suited for whatever task.


-Original Message-
From: R-help  On Behalf Of Spencer Graves
Sent: Monday, July 17, 2023 3:13 PM
To: Bert Gunter ; R-help 
Subject: Re: [R] Off-topic: ChatGPT Code Interpreter

  I don't know about ChatGPT, but Daniel Kahneman won the 2002 Nobel 
Memorial Prize in Economics,[1] even though he's not an economist, for 
his leadership in creating a new subfield in the intersection of human 
psychology and economics now called "behavioral economics".[2] Then in 
2009 Kahneman and Gary Klein published an article on, "Conditions for 
intuitive expertise: a failure to disagree", which concluded that expert 
intuition is learned from frequent, rapid, high-quality feedback. 
People you do not learn from frequent, rapid, high-quality feedback can 
be beaten by simple heuristics developed by intelligent lay people.[3] 
That includes most professions, which Kahneman Sibony and Sunstein call 
"respect-experts".


  Kahneman Sibony and Sunstein further report that with a little data, 
a regression model can outperform a simple heuristic, and with massive 
amounts of data, artificial intelligence can outperform regression 
models.[4]


  An extreme but real example of current reality was describe in an 
article on "Asylum roulette":  With asylum judges in the same 
jurisdiction with cases assigned at random, one judge approved 5 percent 
of cases while another approved 88 percent.[5] However, virtually all 
"respect-experts" are influenced in their judgements by time of day and 
whether their favorite sports team won or lost the previous day.  That 
level of noise can be reduced dramatically by use of appropriate 
artificial intelligence.


  Comments?
  Spencer Graves


[1]


https://en.wikipedia.org/wiki/Daniel_Kahneman


[2]


https://en.wikipedia.org/wiki/Behavioral_economics


[3]


https://www.researchgate.net/publication/26798603_Conditions_for_Intuitive_Expertise_A_Failure_to_Disagree


[4]


Daniel Kahneman; Olivier Sibony; Cass Sunstein (2021). Noise: A Flaw in 
Human Judgment (Little, Brown and Company).


[5]


https://en.wikipedia.org/wiki/Refugee_roulette


On 7/17/23 1:46 PM, Bert Gunter wrote:
> This is an **off-topic** post about the subject line, that I thought
> might be of interest to the R Community. I hope this does not offend
> anyone.
> 
> The widely known ChatGPT software now offers what  is called a "Code
> Interpreter," that, among other things, purports to do "data
> analysis."  (Search for articles with details.) One quote, from the
> (online) NY Times, is:
> 
> "Arvind Narayanan, a professor of computer science at Princeton
> University, cautioned that people should not become overly reliant on
> code interpreter for data analysis as A.I. still produces inaccurate
> results and misinformation.
> 
> 'Appropriate data analysis requires just a lot of critical thinking
> about the data,” he said.' "
> 
> Amen. ... Maybe.
> 
> (As this is off-topic, if you wish to reply to me, probably better to
> do so privately).
> 
> Cheers to all,
> 

Re: [R] Error: promise already under evaluation

2023-07-18 Thread Joseph Lucke
Fixed!
I was not passing a tol value from the outer function to the inner
qnbinom() function. Because the scope of tol in qbinom() was confined to
the outer function, qnbinom was not accessing the globally defined tol
value. Furthermore, because the outer function itself was embedded in
integrate(), the standard nonstandard scoping didn't enable access to the
global value.
I hope this makes sense.
In any case, the problem has been solved.
Thanks.

On Tue, Jul 18, 2023, 10:38 AM Ivan Krylov  wrote:

> В Tue, 18 Jul 2023 09:28:30 -0400
> Joseph Lucke  пишет:
>
> > Error in qnbinom(1 - tol, size = q, prob = r) :
>
> > pRsq.Rhosq <- function(x, n, p, Rhosq,tol=tol){
>
> It looks like you're not passing the `tol` parameter, and its default
> value unfortunately refers to itself:
>
> (function(x = x) x)()
> # Error in (function(x = x) x)() :
> #   promise already under evaluation: recursive default argument
> #   reference or earlier problems?
>
> --
> Best regards,
> Ivan
>

[[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] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread avi.e.gross
Jim,

I am not sure what your example means but text to image conversion can be
done quite easily in many programming environments and does not need an AI
unless you are using it to hunt for info.  I mean you can open up many Paint
or Photo programs and look at the menus and often one allows you to write
using whatever font/size/color/background you want to add a layer on the
image. There are plenty of free resources on-line that I sometimes use to
write something in a large fiery font or whatever and when I get the result
I want, I save it as graphics.

If you mean that you found something other than a human who would listen to
you and maybe ask a few questions and then do it for you, good for you.
Since most people are not programmers, there is plenty of room for that kind
of thing.

Although R is not particularly designed to do what you are saying, a quick
search indicates plenty of packages using R for this kind of thing.

What gets me is an AI can do one of several things. It may give you a result
and you take it or leave it. Or, it can look around at the internet and
knowledge bases and throw a program at you, perhaps in R, and you would then
need to validate if it makes sense given your knowledge about R. If it gave
you a program in a language you did not know, would you blindly try using
it?

To be fair, many years ago the barrier was higher. To figure out what a
function did, or even find such a function, often meant reading through
copious amounts of reference books, or lots of existing code looking for an
example of such use, or ask someone who might have to do the same. Often you
ended up writing code using other more primitive commands  that did what you
wanted. Obviously internet searches and other tools and the vast number of
people who are sharing this kind of info, make this easier. In some ways, an
AI can do much of the searching for you but with results that may be
surprising.



-Original Message-
From: R-help  On Behalf Of Jim Lemon
Sent: Monday, July 17, 2023 7:24 PM
To: Ebert,Timothy Aaron 
Cc: R-help 
Subject: Re: [R] Off-topic: ChatGPT Code Interpreter

I haven't really focused on the statistical capabilities of AI, that
marriage of massive memory and associative learning. I am impressed by
its ability to perform text-to-image conversion, something I have
recently needed. My artistic ability is that of the average three year
old, yet I can employ AI to translate my mental images into realistic
pictures. Perhaps we really are learning about how we think. As far as
I am aware, it just does what we tell it to do. Like other tools, it
is as good or bad as the user.

Jim

__
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] Obtaining R-squared from All Possible Combinations of Linear Models Fitted

2023-07-18 Thread Jan van der Laan

The dredge function has a `extra` argument to get other statistics:

optional additional statistics to be included in the result, provided as 
functions, function names or a list of such (preferably named or 
quoted). As with the rank argument, each function must accept as an 
argument a fitted model object and return (a value coercible to) a 
numeric vector. This could be, for instance, additional information 
criteria or goodness-of-fit statistics. The character strings "R^2" and 
"adjR^2" are treated in a special way and add a likelihood-ratio based 
R² and modified-R² to the result, respectively (this is more efficient 
than using r.squaredLR directly).


HTH
Jan



On 17-07-2023 19:24, Paul Bernal wrote:

Dear friends,

I need to automatically fit all possible linear regression models (with all
possible combinations of regressors), and found the MuMIn package, which
has the dredge function.

This is the dataset  I am working with:

dput(final_frame)

structure(list(y = c(41.9, 44.5, 43.9, 30.9, 27.9, 38.9, 30.9,
28.9, 25.9, 31, 29.5, 35.9, 37.5, 37.9), x1 = c(6.6969, 8.7951,
9.0384, 5.9592, 4.5429, 8.3607, 5.898, 5.6039, 4.9176, 6.2712,
5.0208, 5.8282, 5.9894, 7.5422), x4 = c(1.488, 1.82, 1.5, 1.121,
1.175, 1.777, 1.24, 1.501, 0.998, 0.975, 1.5, 1.225, 1.256, 1.69
), x8 = c(22, 50, 23, 32, 40, 48, 51, 32, 42, 30, 62, 32, 40,
22), x2 = c(1.5, 1.5, 1, 1, 1, 1.5, 1, 1, 1, 1, 1, 1, 1, 1.5),
 x7 = c(3, 4, 3, 3, 3, 4, 3, 3, 4, 2, 4, 3, 3, 3)), class =
"data.frame", row.names = c(NA,
-14L))

I started with the all regressor model, which I called globalmodel as
follows:
#Fitting Regression model with all possible combinations of regressors
options(na.action = "na.fail") # change the default "na.omit" to prevent
models
globalmodel <- lm(y~., data=final_frame)

Then, the following code provides the different coefficients (for
regressors and the intercept) for each of the possible model combinations:
combinations <- dredge(globalmodel)
print(combinations)
  I would like to retrieve  the R-squared generated by each combination, but
have not been able to get it thus far.

Any guidance on how to retrieve the R-squared from all linear model
combinations would be greatly appreciated.

Kind regards,
Paul

[[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] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread Joseph Lucke
The near year as Metropolis,  1927.

On Tue, Jul 18, 2023, 1:27 AM Rui Barradas  wrote:

> Às 00:23 de 18/07/2023, Jim Lemon escreveu:
> > I haven't really focused on the statistical capabilities of AI, that
> > marriage of massive memory and associative learning. I am impressed by
> > its ability to perform text-to-image conversion, something I have
> > recently needed. My artistic ability is that of the average three year
> > old, yet I can employ AI to translate my mental images into realistic
> > pictures. Perhaps we really are learning about how we think. As far as
> > I am aware, it just does what we tell it to do. Like other tools, it
> > is as good or bad as the user.
> >
> > Jim
> >
> > __
> > 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.
> Hello,
>
> Also off-topic but the date is fun:
>
>
> A system is not a head.
> Furniture is not people.
> All processes and all devices,
> will be useless for organizations,
> if the heads of the individuals who employ them,
> are not properly organized.
> And these heads will be organized,
> if the same part of the boss's body that directs them
> is properly organized.
> Just like you can write nonsense
> with a latest model typewriter,
> nonsense can also be done
> with the most perfect systems and devices
> meant to help you not to.
> Systems, processes, furniture, machines,
> are purely auxiliary elements.
> The real process is to think.
> The fundamental machine is intelligence.
>
> Fernando Pessoa, 1926
>
> Revista de Comércio e Contabilidade, nº 4. Lisboa, 25-4-1926.
> (Magazine of Commerce and Accounting, nº 4. Lisbon, 25-4-1926)
>
>
> Rui Barradas
>
> __
> 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] Error: promise already under evaluation

2023-07-18 Thread Joseph Lucke
A repost.
R gurus:
I have a 10 or so functions that use R’s qnbinom() function. Until now,
they have worked without any problems whatsoever.
I created a new function, which involved the integration, using R’s
integrate(), of a function that in turn uses the qnbinom() function.
The function failed because of my programming stupidity. It has been
deleted from my source file.
Now I cannot get any function using qnbinom() to work. I get the following
error.

Error in qnbinom(1 - tol, size = q, prob = r) :
  promise already under evaluation: recursive default argument reference or
earlier problems?
 An example function that that used to work splendidly but now fails is

#Distribution of R2: 0 to x
pRsq.Rhosq <- function(x, n, p, Rhosq,tol=tol){
  a <- p /2; b <- (n-p-1)/2; q <- (n-1)/2
  r <- 1-Rhosq
  k <- 0:qnbinom(1-tol,size=q,prob=r)
 sum(dnbinom(k,size=q,prob=r)*pbeta(x,a+k,b))
}

Tracebacks from more complicated functions, which have worked before,
always return to the above error.
When I re-source the source file without the offending function, I still
get the error.
How do I get rid of this error? What can I do to avoid it error in the
future?

TIA
Joe Lucke

[[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] Error: promise already under evaluation

2023-07-18 Thread Ivan Krylov
В Tue, 18 Jul 2023 09:28:30 -0400
Joseph Lucke  пишет:

> Error in qnbinom(1 - tol, size = q, prob = r) :

> pRsq.Rhosq <- function(x, n, p, Rhosq,tol=tol){

It looks like you're not passing the `tol` parameter, and its default
value unfortunately refers to itself:

(function(x = x) x)()
# Error in (function(x = x) x)() :
#   promise already under evaluation: recursive default argument
#   reference or earlier problems?

-- 
Best regards,
Ivan

__
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] change language at console

2023-07-18 Thread Rich Shepard via R-help
On Wed, 1 Apr 2015, Prof Brian Ripley wrote:  I would start by trying 
LANGUAGE=en , e.g. More specifically, you can use en_US or en_GB. Rich [...]
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ 
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ 
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ 
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ 
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ 
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ 
͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​













[R] change language at console









On Wed, 1 Apr 2015, Prof Brian Ripley wrote:
> I would start by trying LANGUAGE=en , e.g.
More specifically, you can use en_US or en_GB.
Rich
__
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.



ThinkR*

0185091403
|
o...@thinkr.fr [1]
|
http://thinkr.fr [2]


Powered by Odoo [3]



[1] mailto:o...@thinkr.fr
[2] http://thinkr.fr
[3] https://www.odoo.com?utm_source=db_medium=email

[[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] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread Hadley Wickham
> I am not sure what your example means but text to image conversion can be
> done quite easily in many programming environments and does not need an AI
> unless you are using it to hunt for info.  I mean you can open up many Paint
> or Photo programs and look at the menus and often one allows you to write
> using whatever font/size/color/background you want to add a layer on the
> image. There are plenty of free resources on-line that I sometimes use to
> write something in a large fiery font or whatever and when I get the result
> I want, I save it as graphics.

I would recommend you try out one of the many text-to-image AI
services like https://www.midjourney.com/ or
https://openai.com/dall-e-2. These services are much more
sophisticated than you might imagine.

Hadley

-- 
http://hadley.nz

__
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] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread avi.e.gross
Hadley,

Thanks and I know many such things exist. I simply found it interesting that 
what was mentioned seemed simpler as just being a converter of text to make a 
bitmap type image. Now if I want a simulated image of a cat riding a motorcycle 
while holding an Esperanto Flag, sure, I would not easily do it directly or 
even in a standard programming language. 

Of course I may have misunderstood "text" to mean the actual text, as compared 
to a somewhat natural language description using text. R does not easily do 
that.

Then again, there are ways to connect your R program to the Wolfram Knowledge 
base to pass through natural language queries ...

Avi

-Original Message-
From: Hadley Wickham  
Sent: Tuesday, July 18, 2023 6:10 PM
To: avi.e.gr...@gmail.com
Cc: Jim Lemon ; Ebert,Timothy Aaron ; 
R-help 
Subject: Re: [R] Off-topic: ChatGPT Code Interpreter

> I am not sure what your example means but text to image conversion can be
> done quite easily in many programming environments and does not need an AI
> unless you are using it to hunt for info.  I mean you can open up many Paint
> or Photo programs and look at the menus and often one allows you to write
> using whatever font/size/color/background you want to add a layer on the
> image. There are plenty of free resources on-line that I sometimes use to
> write something in a large fiery font or whatever and when I get the result
> I want, I save it as graphics.

I would recommend you try out one of the many text-to-image AI
services like https://www.midjourney.com/ or
https://openai.com/dall-e-2. These services are much more
sophisticated than you might imagine.

Hadley

-- 
http://hadley.nz

__
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] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread Ebert,Timothy Aaron
I was thinking that text-to-image conversion was something like NightCafe 
(https://creator.nightcafe.studio/) which is very much AI and not something I 
know how to do with Paint or Photoshop.

-Original Message-
From: avi.e.gr...@gmail.com 
Sent: Tuesday, July 18, 2023 2:34 PM
To: 'Jim Lemon' ; Ebert,Timothy Aaron 
Cc: 'R-help' 
Subject: RE: [R] Off-topic: ChatGPT Code Interpreter

[External Email]

Jim,

I am not sure what your example means but text to image conversion can be done 
quite easily in many programming environments and does not need an AI unless 
you are using it to hunt for info.  I mean you can open up many Paint or Photo 
programs and look at the menus and often one allows you to write using whatever 
font/size/color/background you want to add a layer on the image. There are 
plenty of free resources on-line that I sometimes use to write something in a 
large fiery font or whatever and when I get the result I want, I save it as 
graphics.

If you mean that you found something other than a human who would listen to you 
and maybe ask a few questions and then do it for you, good for you.
Since most people are not programmers, there is plenty of room for that kind of 
thing.

Although R is not particularly designed to do what you are saying, a quick 
search indicates plenty of packages using R for this kind of thing.

What gets me is an AI can do one of several things. It may give you a result 
and you take it or leave it. Or, it can look around at the internet and 
knowledge bases and throw a program at you, perhaps in R, and you would then 
need to validate if it makes sense given your knowledge about R. If it gave you 
a program in a language you did not know, would you blindly try using it?

To be fair, many years ago the barrier was higher. To figure out what a 
function did, or even find such a function, often meant reading through copious 
amounts of reference books, or lots of existing code looking for an example of 
such use, or ask someone who might have to do the same. Often you ended up 
writing code using other more primitive commands  that did what you wanted. 
Obviously internet searches and other tools and the vast number of people who 
are sharing this kind of info, make this easier. In some ways, an AI can do 
much of the searching for you but with results that may be surprising.



-Original Message-
From: R-help  On Behalf Of Jim Lemon
Sent: Monday, July 17, 2023 7:24 PM
To: Ebert,Timothy Aaron 
Cc: R-help 
Subject: Re: [R] Off-topic: ChatGPT Code Interpreter

I haven't really focused on the statistical capabilities of AI, that marriage 
of massive memory and associative learning. I am impressed by its ability to 
perform text-to-image conversion, something I have recently needed. My artistic 
ability is that of the average three year old, yet I can employ AI to translate 
my mental images into realistic pictures. Perhaps we really are learning about 
how we think. As far as I am aware, it just does what we tell it to do. Like 
other tools, it is as good or bad as the user.

Jim

__
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-es] realizar ANOVAs en Loop

2023-07-18 Thread Proyecto R-UCA
Buenas, Yesica:

La variable iteraccion parece una variable factor, en cuyo caso ¿no se debería 
incluir en el anova? en vez de repetir muchas veces el anova.

Si se trata de repeticiones también hay modelos anova con repeticiones.

En tu código estás haciendo el mismo anova muchas veces pues no cambias los 
datos en el bucle, además estás haciendo un análisis por cada
fila sin eliminar las repeticiones. Por otra parte no imprimes ni guardas nada 
dentro del bucle con lo que cuando sales lo que calculas ya
no está.

Prueba lo siguiente.

## Extraer los valores de iteraccion sin repeticiones
iter <- levels(factor(data$iteraccion))

for(i in iter) {
   ## Hacemos el análisis quedándonos con las filas correspondientes
   res = aov(valor~Grupo, data=datos[datos$iteraccion == iter,])
   print(summary(res))
 }

Un saludo.

P.D.: No lo he probado, puede que tenga alguna errata.

El mar, 18-07-2023 a las 08:25 +0200, Yesica Pallavicini Fernandez escribió:
> Buenos días y gracias de antemano por vuestra ayuda.
> 
> Necesito realizar una serie de ANOVAS en loop.
> Os adjunto unos datos ficticios en este email.
> Dichos datos tienen 3 variables: 
> 1)Valor: corresponde a la variable dependiente y es numérica
> 2) Grupo: Corresponde a la variable independiente y es u factor
> 3) Iteracción: Corresponde a la variable sobre la cual hay que repetir los 
> ANOVAs con las variables anteriores y es un factor.
> 
> Abajo os pego el código con el que he estado trabajando pero que no lo tengo 
> bien, porque no puedo acceder a los resultados.
> Os agradeceria mucho si:
> -Me podéis ayudar a mejorar este código para que funcione
> -Si me podéis sugerir alguna fuente que explique bien cómo hacer un loop 
> porque no he dado con los blogs adecuados.
> -Que me digáis cuál es vuestro libro/web de estadística favorito para 
> profundizar en la matemática detrás de los análisis.
> 
> Mil gracias compañeros
> Yésica
> 
> library(agricolae)
> library(readxl)
> datosa_fict <- read_excel("datosa-fict.xlsx")
> #Cambiar nombre a la base de datos
> datos=datosa_fict
> #Copiar la variable sobre la que hacer el loop
> 
> iter=datos$iteraccion
> #Crear el loop
> for(i in iter) {
>   res=aov(valor~Grupo,data=datos)
>  
> }
> #Salvar los resultados
> ANOVA(res)
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help-es__;!!D9dNQwwGXtA!VjLSaDKJejCZoZy1TgKKYQML4mA7DfvcDtUBYj5iRpdFNSsGUU5lEYtfkt0EYWTPD_-5HztE7U6zv48$
>  

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


[R-es] realizar ANOVAs en Loop

2023-07-18 Thread Yesica Pallavicini Fernandez
Buenos días y gracias de antemano por vuestra ayuda.

Necesito realizar una serie de ANOVAS en loop.
Os adjunto unos datos ficticios en este email.
Dichos datos tienen 3 variables:
1)Valor: corresponde a la variable dependiente y es numérica
2) Grupo: Corresponde a la variable independiente y es u factor
3) Iteracción: Corresponde a la variable sobre la cual hay que repetir los
ANOVAs con las variables anteriores y es un factor.

Abajo os pego el código con el que he estado trabajando pero que no lo
tengo bien, porque no puedo acceder a los resultados.
Os agradeceria mucho si:
-Me podéis ayudar a mejorar este código para que funcione
-Si me podéis sugerir alguna fuente que explique bien cómo hacer un loop
porque no he dado con los blogs adecuados.
-Que me digáis cuál es vuestro libro/web de estadística favorito para
profundizar en la matemática detrás de los análisis.

Mil gracias compañeros
Yésica

library(agricolae)
library(readxl)
datosa_fict <- read_excel("datosa-fict.xlsx")
#Cambiar nombre a la base de datos
datos=datosa_fict
#Copiar la variable sobre la que hacer el loop

iter=datos$iteraccion
#Crear el loop
for(i in iter) {
  res=aov(valor~Grupo,data=datos)

}
#Salvar los resultados
ANOVA(res)


datosa-fict.xlsx
Description: MS-Excel 2007 spreadsheet
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] realizar ANOVAs en Loop

2023-07-18 Thread jose luis via R-help-es
 Holaotra opción, a ver si te sirve.Acabarás teniendo 6 archivos txt y 6 
archivos xlsx cada uno con el resultado de cada una de las  iteraciones.
library(purrr)library(broom)


 iter= unique(datos$iteraccion)#Crear el loopfor(i in iter) {
a<-tidy(aov(valor~Grupo,data=subset(datos, iteraccion==i)))

capture.output(a,i, file =paste0(i, ".txt"))print(a)openxlsx:: 
write.xlsx(a,file = paste0(i,'.xlsx'),                      sheetName = i, 
append = TRUE)
}




En martes, 18 de julio de 2023, 16:53:30 CEST, Jorge I Velez 
 escribió:  
 
 Hola Yésica,

A lo mejor hay otras formas, pero esta funciona bien:

R> u <- unique(datos$iteraccion)
R> resultado <- lapply(u, function(i){
  aov(valor ~ Grupo, data = subset(datos, iteraccion == i))
})
R> names(resultado) <- u

Para acceder a la tabla ANOVA para iteraccion T simplemente haces

> resultado[['T']]
Call:
  aov(formula = valor ~ Grupo, data = subset(datos, iteraccion ==
    i))

Terms:
                  Grupo Residuals
Sum of Squares  0.70326  62.83939
Deg. of Freedom        2        13

Residual standard error: 2.19859
Estimated effects may be unbalanced

Si quieres obtener los estadísticos correspondientes basta con hacer

R> summary(resultado[['T']])
Df Sum Sq Mean Sq F value Pr(>F)
Grupo        2  0.70  0.352  0.073  0.93
Residuals  13  62.84  4.834

Espero sea de utilidad.

Saludos,
Jorge.-


On Tue, Jul 18, 2023 at 1:25 AM Yesica Pallavicini Fernandez <
yesipa...@gmail.com> wrote:

> Buenos días y gracias de antemano por vuestra ayuda.
>
> Necesito realizar una serie de ANOVAS en loop.
> Os adjunto unos datos ficticios en este email.
> Dichos datos tienen 3 variables:
> 1)Valor: corresponde a la variable dependiente y es numérica
> 2) Grupo: Corresponde a la variable independiente y es u factor
> 3) Iteracción: Corresponde a la variable sobre la cual hay que repetir los
> ANOVAs con las variables anteriores y es un factor.
>
> Abajo os pego el código con el que he estado trabajando pero que no lo
> tengo bien, porque no puedo acceder a los resultados.
> Os agradeceria mucho si:
> -Me podéis ayudar a mejorar este código para que funcione
> -Si me podéis sugerir alguna fuente que explique bien cómo hacer un loop
> porque no he dado con los blogs adecuados.
> -Que me digáis cuál es vuestro libro/web de estadística favorito para
> profundizar en la matemática detrás de los análisis.
>
> Mil gracias compañeros
> Yésica
>
> library(agricolae)
> library(readxl)
> datosa_fict <- read_excel("datosa-fict.xlsx")
> #Cambiar nombre a la base de datos
> datos=datosa_fict
> #Copiar la variable sobre la que hacer el loop
>
> iter=datos$iteraccion
> #Crear el loop
> for(i in iter) {
>  res=aov(valor~Grupo,data=datos)
>
> }
> #Salvar los resultados
> ANOVA(res)
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

    [[alternative HTML version deleted]]

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


Re: [R-es] realizar ANOVAs en Loop

2023-07-18 Thread Jorge I Velez
Hola Yésica,

A lo mejor hay otras formas, pero esta funciona bien:

R> u <- unique(datos$iteraccion)
R> resultado <- lapply(u, function(i){
  aov(valor ~ Grupo, data = subset(datos, iteraccion == i))
})
R> names(resultado) <- u

Para acceder a la tabla ANOVA para iteraccion T simplemente haces

> resultado[['T']]
Call:
   aov(formula = valor ~ Grupo, data = subset(datos, iteraccion ==
i))

Terms:
   Grupo Residuals
Sum of Squares   0.70326  62.83939
Deg. of Freedom213

Residual standard error: 2.19859
Estimated effects may be unbalanced

Si quieres obtener los estadísticos correspondientes basta con hacer

R> summary(resultado[['T']])
Df Sum Sq Mean Sq F value Pr(>F)
Grupo2   0.70   0.352   0.073   0.93
Residuals   13  62.84   4.834

Espero sea de utilidad.

Saludos,
Jorge.-


On Tue, Jul 18, 2023 at 1:25 AM Yesica Pallavicini Fernandez <
yesipa...@gmail.com> wrote:

> Buenos días y gracias de antemano por vuestra ayuda.
>
> Necesito realizar una serie de ANOVAS en loop.
> Os adjunto unos datos ficticios en este email.
> Dichos datos tienen 3 variables:
> 1)Valor: corresponde a la variable dependiente y es numérica
> 2) Grupo: Corresponde a la variable independiente y es u factor
> 3) Iteracción: Corresponde a la variable sobre la cual hay que repetir los
> ANOVAs con las variables anteriores y es un factor.
>
> Abajo os pego el código con el que he estado trabajando pero que no lo
> tengo bien, porque no puedo acceder a los resultados.
> Os agradeceria mucho si:
> -Me podéis ayudar a mejorar este código para que funcione
> -Si me podéis sugerir alguna fuente que explique bien cómo hacer un loop
> porque no he dado con los blogs adecuados.
> -Que me digáis cuál es vuestro libro/web de estadística favorito para
> profundizar en la matemática detrás de los análisis.
>
> Mil gracias compañeros
> Yésica
>
> library(agricolae)
> library(readxl)
> datosa_fict <- read_excel("datosa-fict.xlsx")
> #Cambiar nombre a la base de datos
> datos=datosa_fict
> #Copiar la variable sobre la que hacer el loop
>
> iter=datos$iteraccion
> #Crear el loop
> for(i in iter) {
>   res=aov(valor~Grupo,data=datos)
>
> }
> #Salvar los resultados
> ANOVA(res)
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

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


Re: [R-es] realizar ANOVAs en Loop

2023-07-18 Thread Juan Carlos Lopez Mesa
Hola,

library(dplyr)
library(purrr)
library(tidyr)


datos_anova <- datosa_fict |>
  nest(data = c(valor, Grupo)) |>
  mutate(anova = map(.x = data,
 .f = ~aov(valor ~ Grupo, data = .x)),
 summary = map(.x = anova, .f = ~summary(.x)))

# Acceder a los resultados
datos_anova$anova[datos_anova$iteraccion == "Z"]
datos_anova$summary[datos_anova$iteraccion == "Z"]

El mar, 18 jul 2023 a las 1:25, Yesica Pallavicini Fernandez (<
yesipa...@gmail.com>) escribió:

> Buenos días y gracias de antemano por vuestra ayuda.
>
> Necesito realizar una serie de ANOVAS en loop.
> Os adjunto unos datos ficticios en este email.
> Dichos datos tienen 3 variables:
> 1)Valor: corresponde a la variable dependiente y es numérica
> 2) Grupo: Corresponde a la variable independiente y es u factor
> 3) Iteracción: Corresponde a la variable sobre la cual hay que repetir los
> ANOVAs con las variables anteriores y es un factor.
>
> Abajo os pego el código con el que he estado trabajando pero que no lo
> tengo bien, porque no puedo acceder a los resultados.
> Os agradeceria mucho si:
> -Me podéis ayudar a mejorar este código para que funcione
> -Si me podéis sugerir alguna fuente que explique bien cómo hacer un loop
> porque no he dado con los blogs adecuados.
> -Que me digáis cuál es vuestro libro/web de estadística favorito para
> profundizar en la matemática detrás de los análisis.
>
> Mil gracias compañeros
> Yésica
>
> library(agricolae)
> library(readxl)
> datosa_fict <- read_excel("datosa-fict.xlsx")
> #Cambiar nombre a la base de datos
> datos=datosa_fict
> #Copiar la variable sobre la que hacer el loop
>
> iter=datos$iteraccion
> #Crear el loop
> for(i in iter) {
>   res=aov(valor~Grupo,data=datos)
>
> }
> #Salvar los resultados
> ANOVA(res)
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

-- 
*Aviso legal:* El contenido de este mensaje y los archivos adjuntos son 
confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. 
Se encuentran dirigidos sólo para el uso del destinatario al cual van 
enviados. La reproducción, lectura y/o copia se encuentran prohibidas a 
cualquier persona diferente a este y puede ser ilegal. Si usted lo ha 
recibido por error, infórmenos y elimínelo de su correo. Los Datos 
Personales serán tratados conforme a la Ley 1581 de 2012 y a nuestra 
Política de Datos Personales que podrá consultar en la página web 
www.unal.edu.co .* *Las opiniones, informaciones, 
conclusiones y cualquier otro tipo de dato contenido en este correo 
electrónico, no relacionados con la actividad de la Universidad Nacional de 
Colombia, se entenderá como personales y de ninguna manera son avaladas por 
la Universidad.

[[alternative HTML version deleted]]

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