Re: [R] If loop

2024-08-10 Thread martin gregory via R-help
> On 9. Aug 2024, at 10:45, CALUM POLWART wrote: > > Or use <<- assignment I think. (I usually return, but return can only > return one object and I think you want two or more > One can return multiple objects by putting them in a list and returning the list. Martin __

Re: [R] WDI package commands timing out and not working

2024-08-10 Thread Anupam Tyagi
Thanks, Ivan. I will fill out the support form at the World Bank. On Fri, 9 Aug 2024 at 22:16, Ivan Krylov wrote: > В Fri, 9 Aug 2024 20:25:51 +0530 > Anupam Tyagi пишет: > > > I am trying this in Bengaluru, India, using R-studio. I tried > > downloading a single variable. It happened fast, in

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
HI Bert and Ben, Yes, running lm.fit using the matrix format is much faster. I read a couple of online comments why it is faster. However, the residual values for three tested variables or genes from lm function and lm.fit function are different, with Pearson correlation of 0.55, 0.89, and 0.9

Re: [R] a fast way to do my job

2024-08-10 Thread Bert Gunter
Probably because you inadvertently ran different models. Without your code, I haven't a clue. On Sat, Aug 10, 2024, 12:29 Yuan Chun Ding wrote: > HI Bert and Ben, > > > > Yes, running lm.fit using the matrix format is much faster. I read a > couple of online comments why it is faster. > > > > Ho

Re: [R] a fast way to do my job

2024-08-10 Thread Bert Gunter
Ah, messages crossed. A no-intercept model **assumes** the straight line fit must pass through the origin. Unless there is a strong justification for such an assumption, you should include an intercept. -- Bert On Sat, Aug 10, 2024 at 1:02 PM Bert Gunter wrote: > > Is it because I failed to to a

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
after add intercept, all residuals are the same from lm or lm.fit. Ding From: Bert Gunter Sent: Saturday, August 10, 2024 1:00 PM To: Yuan Chun Ding Cc: Ben Bolker ; r-help@r-project.org Subject: Re: [R] a fast way to do my job Probably because you inadvertently ran different models. Without y

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
You are right. I also just thought about that, no intercept is not applicable to my case. Ding From: Bert Gunter Sent: Saturday, August 10, 2024 1:06 PM To: Yuan Chun Ding Cc: Ben Bolker ; r-help@r-project.org Subject: Re: [R] a fast way to do my job Ah, messages crossed. A no-intercept mode

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
Hi Bert and Ben, Thanks a lot for your suggestion!!. About the different residuals between lm function and lm.fit, from online search, lt seems like that I need to add an intercept in the design matrix x; pur2 <- matrix(gem751be.rpkm$purity2, ncol =1) pur2.1 <- cbind(1,gem751be.rpkm$purity2

Re: [R] a fast way to do my job

2024-08-10 Thread Bert Gunter
Is it because I failed to to add a column of ones for an intercept to the x matrix? TRhat would be my bad. -- Bert On Sat, Aug 10, 2024 at 12:59 PM Bert Gunter wrote: > > Probably because you inadvertently ran different models. Without your code, I > haven't a clue. > > > On Sat, Aug 10, 2024,

Re: [R] a fast way to do my job

2024-08-10 Thread Rui Barradas
Hello, .lm.fit is an order of magnitude faster than lm.fit but the Description section warns on its use, see the examples in help("lm.fit"). Hope this helps, Rui Barradas Às 21:08 de 10/08/2024, Yuan Chun Ding via R-help escreveu: You are right. I also just thought about that, no intercept