Re: [R] Regarding fitted value

2021-02-01 Thread Rui Barradas
Hello, You get the fitted values for years 2000, ..., 2019. Those values are the original series minus the residuals: f <- fitted(model1) g <- yy - resid(model1) identical(f, g) # returns TRUE If you want to *forecast*, this will give you the default h = 10 forecasts. fc <- forecast(

Re: [R] dependent nested for loops in R

2021-02-01 Thread David Winsemius
Sent from my iPhone > On Feb 1, 2021, at 10:16 PM, David Winsemius wrote: > > Or perhaps: > > W <- 1:2000 > W[z>4|z<2] <- 0 Another way: W <- (1:2000)*(z>4|z<2) As I said earlier you really should study logical class vectors and the operators that use them and how to apply them as indi

Re: [R] dependent nested for loops in R

2021-02-01 Thread David Winsemius
Or perhaps: W <- 1:2000 W[z>4|z<2] <- 0 Sent from my iPhone > On Feb 1, 2021, at 9:56 PM, David Winsemius wrote: > > Or perhaps you wanted: > > W <- z > W[z>4|z<2] <- 0 > > Sent from my iPhone > >>> On Feb 1, 2021, at 9:41 PM, David Winsemius wrote: >>> >> Just drop the “+” if you want

Re: [R] dependent nested for loops in R

2021-02-01 Thread David Winsemius
Or perhaps you wanted: W <- z W[z>4|z<2] <- 0 Sent from my iPhone > On Feb 1, 2021, at 9:41 PM, David Winsemius wrote: > > Just drop the “+” if you want logical. > > Sent from my iPhone > >>> On Feb 1, 2021, at 9:36 PM, Shaami wrote: >>> >>  >> Hi Prof. David >> >> Thank you. I will al

Re: [R] dependent nested for loops in R

2021-02-01 Thread David Winsemius
Just drop the “+” if you want logical. Sent from my iPhone > On Feb 1, 2021, at 9:36 PM, Shaami wrote: > >  > Hi Prof. David > > Thank you. I will always follow your advice. The suggested code worked. It > gives either 1 or 0 depending on the condition to be true. I want index of z > for w

Re: [R] dependent nested for loops in R

2021-02-01 Thread David Winsemius
IMTS length 2000 Sent from my iPhone > On Feb 1, 2021, at 9:16 PM, David Winsemius wrote: > > Cc’ed the list as should always be your practice. > > Here’s one way (untested): > > W <- +(z>4| z<2) # assume z is of length 20 > > — > David > > Sent from my iPhone > >>> On Feb 1, 2021, at 7

Re: [R] dependent nested for loops in R

2021-02-01 Thread David Winsemius
Cc’ed the list as should always be your practice. Here’s one way (untested): W <- +(z>4| z<2) # assume z is of length 20 — David Sent from my iPhone > On Feb 1, 2021, at 7:08 PM, Shaami wrote: > >  > Hi Prof. David > > In the following state > > W = (1:2000)[z >4|z<2) > > Could you ple

Re: [R] Regarding fitted value

2021-02-01 Thread Md. Moyazzem Hossain
Dear Rui Barradas Thank you very much for your reply. However, still now, I have a confusion whether I get the fitted value for the year 2000, 2001, ..., 2020 or 2001, 2002, ..., 2021. Need any more help. Thanks in advance. Md On Thu, Jan 28, 2021 at 4:47 PM Rui Barradas wrote: > Hello, > >

Re: [R] dependent nested for loops in R

2021-02-01 Thread Shaami
Hi Duncan It worked. Thank you. Best Regards On Mon, Feb 1, 2021 at 6:26 PM Duncan Murdoch wrote: > On 01/02/2021 7:03 a.m., Shaami wrote: > > z = NULL > > p = 0.25 > > x = rnorm(100) > > z[1] = p*x[1] + (1-p)*5 > > for(i in 2:100) > > { > >z[i] = p*x[i]+(1-p)*z[i-1] > > } > > That's the s

[R] Distance used in lda()

2021-02-01 Thread Agustin Lobo
Whenever using lda(...,CV=TRUE), or if using lda.predict(), a classification is returned. Which distance is used in order to allocate a given individual to a class, once the original data have been transformed into discriminant components? Thanks Agustin Lobo aloboa...@gmail.com

Re: [R] arima/fixed

2021-02-01 Thread Martin Maechler
> Martin Maechler > on Sat, 30 Jan 2021 12:21:14 +0100 writes: > Rolf Turner > on Sat, 30 Jan 2021 16:11:32 +1300 writes: >> On Fri, 29 Jan 2021 12:47:25 + Nasia Petsa >> wrote: >>> Dear all, >>> >>> I have the following problem with determinin

Re: [R] dependent nested for loops in R

2021-02-01 Thread Duncan Murdoch
On 01/02/2021 7:03 a.m., Shaami wrote: z = NULL p = 0.25 x = rnorm(100) z[1] = p*x[1] + (1-p)*5 for(i in 2:100) { z[i] = p*x[i]+(1-p)*z[i-1] } That's the same as p <- 0.25 x <- rnorm(100) z <- stats::filter(p*x, 1-p, init = 5, method="recursive") This leaves z as a time series; if that cau

Re: [R] dependent nested for loops in R

2021-02-01 Thread Shaami
Hi David and Charles Your suggestions helped me a lot. Could you please suggest how I could vectorize the following for loop? z = NULL p = 0.25 x = rnorm(100) z[1] = p*x[1] + (1-p)*5 for(i in 2:100) { z[i] = p*x[i]+(1-p)*z[i-1] } Thank you Regards On Mon, Feb 1, 2021 at 11:01 AM David Winsemi

[R] [R-pkgs] R2BEAT 1.0.2

2021-02-01 Thread Andrea Fasulo
Dear R users: R2BEAT 1.0.2 is now available on CRAN [ https://cran.r-project.org/web/packages/R2BEAT/index.html | https://cran.r-project.org/web/packages/R2BEAT/index.html ] This package covers the two-stage stratified sample design, offering functions for determining the optimal allocation of