[R] help for R code

2020-10-13 Thread Ablaye Ngalaba
Good morning dear administrators,
Please help me to code this code in R.
I use in this file the redescription function Φ which by making a scalar
product gives a . You can also choose instead of the redescription function
Φ a kernel k(x,x).




  Sincerely

[[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] help for R code

2020-10-13 Thread Eric Berger
Hi Ablaye,
The CRAN repository has thousands of available R packages. To help
people find relevant packages amid such a huge collection, there are
some 'task view' pages that group packages according to a particular
task. I am guessing that you are interested in kernels because of
their use in machine learning, so you might want to look at the
Machine Learning task view at:

https://cran.r-project.org/web/views/MachineLearning.html

If you search for 'kernels' on that page you will find

'Support Vector Machines and Kernel Methods' which mentions a few
packages that use kernels.

Good luck,
Eric


On Tue, Oct 13, 2020 at 10:09 AM Ablaye Ngalaba  wrote:
>
> Good morning dear administrators,
> Please help me to code this code in R.
> I use in this file the redescription function Φ which by making a scalar
> product gives a . You can also choose instead of the redescription function
> Φ a kernel k(x,x).
>
>
>
>
>   Sincerely
>
> [[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] exiting mclapply early on error

2020-10-13 Thread Giovanni Righi
Thanks for the response, Jeremie. I wholeheartedly agree about testing.

In my case, this feature would be used purely to reduce computation time. I’m 
calculating
an expensive (and embarrassingly parallel) likelihood function, and for some 
parameter combinations 
my objective function diverges to infinity. In those instances, I’d like to 
throw an error that stops
subsequent computations and that I could catch to return a value of infinity. I 
agree, though, 
that the default should allow all processes to finish.

What I’ve suggested does not seem possible with mclapply(). Do you know how I 
could suggest 
this as a feature request to the maintainer of the parallel package?

Thanks,
Giovanni
__
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] Please need help to finalize my code

2020-10-13 Thread PIKAL Petr
Hi.

Maybe you will get better answers, but from your code it seems to me that you 
are treating R as C or other similar language which is not optimal. Considering 
your first 9 lines, it could be changed either to

CenteringV <- function(X, Ms, n) X-Ms

or you probably could use functions sweep or scale.
Your other code is beyond my experience, sorry.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Ablaye Ngalaba
> Sent: Saturday, October 10, 2020 9:24 PM
> To: r-help@r-project.org
> Subject: [R] Please need help to finalize my code
> 
> Good evening dear administrators,
> It is with pleasure that I am writing to you to ask for help to finalize my R
> programming algorithm.
> 
> Indeed, I attach this note to my code which deals with a case of independence
> test statistic . My request is to introduce the kernels using the functional 
> data
> for this same code that I am sending you. So I list the lines for which we 
> need
> to introduce the functional data using the kernels below.
> 
> First of all for this code we need to use the functional data. I have numbered
> the lines myself from the original code to give some indication about the 
> lines
> of code to introduce the kernel.
> 1)Centering of redescription function phi(xi) (just use the kernel) 2)this
> function centers the functional data phi(xi) (just use the kernel)
> 3)phi(x1) (or kernel k( ., .) )
> 5)Even here the kernel with the functional data is used.
> 7)return the kernel
> 28) kernel dimension
> 29) kernel dimension
> 30)kernel dimension
> 73) redescription function phi(xi) or the kernel k(. , .) 74)redescription 
> function
> phi(yi) or the kernel k(. , .) 76)redescription function phi(xbar) or the 
> kernel k(.
> , .) 77)redescription function phi(xjhbar) or the kernel k(. , .) 
> 82)redescription
> function phi(xi) or the kernel k(. , .) introduced instead of x 
> 84)redescription
> function phi(xjhbar) or the kernel k(. , .) 89)w= redescription function
> phi(xbar) or the kernel k(. , .)
> 120) we center the redescription function phi(xi) or the kernel k(. , .) 
> 121)Vn is
> a kernel function, so we use ph(xi) or the kernel k(. , , .) 126)centering of 
> the
> redescription function phi(xji) or the kernel k(. , .) 127)Vij is computed 
> using
> redescription function phi(xi) or the kernel k(.
> , .) instead of X.
> 130)centering redescription function phi(Xkl) or the kernel k(. , .) 131)Vijkl
> always using the kernel function as precedent 132)Vkl always using the kernel
> function as precedent
> 
>  I look forward to your help and sincere request.
> 
> 
>  Yours sincerely
> 
> library(MASS)
> 
> 1 CenteringV<-function(X,Ms,n){
> 2 # this function centers the data of X
> 3 X1=X*0
> 4 for (i in 1:n){
> 5 X1[i,]=X[i,]-Ms
> 6 }
> 7 return(X1)
> 8 }
> 
> 
> 9 # Function N°2
> 10 SqrtMatrix0<-function(M) {
> 11 # This function allows us to compute the square root of a matrix
> 12 # using the decomposition M=PDQ where Q is the inverse of P
> 13 # here negative eigenvalues are replaced by zero
>  14 a=eigen(M,TRUE)
>  15 b=a$values
>  16 b[b<0]=0
>  17 c=a$vectors
> 18 d=diag(sqrt(b))
>  19 b=solve(c)
> 20 a=c%*%d%*%b
> 21 return(a)
> 22 }
> 
> 
> 23 # declaration of parameters
> 24 m1=0.01 # alpha value (1% risk)
> 25 m2=0.05 # alpha value (5% risk)
> 26 m3=0.1 # alpha value (10% risk)
> 27 nbrefoissim=100 # # times the program is running
> 28 p=3 #dimension of variable X
> 29 q=3 #dimension of variable Y
> 30 R=c(5,4,3);# Number of partition of each component of variable Y
> 31 if(length(R) != q) stop("The size of R must be equal to q")
> 32 n=25 # Sample size
> 33 N=c(25,50,100,200,300,400,500,1000) #different sample sizes
> 34 #N=c(25,50) #different sample sizes
> 35 pc1=rep(0.100)
> 36 K=0
> 37 MV=matrix(0,nr=8,nc=4)
> 38 dimnames(MV)[[2]]=c("n","r1%","r5%","r10%")
> 
> 
> 39 #Beginning of the program
> 
>  40 for (n in N){
> 
> 
> 41 l1=0 # initialization of the value to calculate the test level at 1%.
> 42 l2=0 # initialization of the value to calculate the test level at 5%.
> 43 l3=0 # initialization of the value to calculate the test level at 10%.
> 
> 44 # Creation of an n11 list containing the sizes of the different groups
> 45 n11=list()
> 46 for (i in 1:q){
> 47 n11[[i]]=rep(as.integer(n/R[i]),R[i])
> 48 n11[[i]][R[i]]=n-((R[i]-1)*n11[[i]][1])
> 49 }
> 
> 
> 50 # Creation of lists P11 and P12 which contain the probabilities and
> 51 # the inverses of the empirical probabilities of the different groups
> respectively
> 
> 52 P11=list()
> 53 P12=list()
> 54 for (i in 1:q){
> 55 P11[[i]]=n11[[i]]/n
> 56 P12[[i]]=n/n11[[i]
> 
> 57 }
> 
> 58 # creation of a list containing the W matrices
> 59 W=list()
> 60 for (i in 1:q){
> 61 w=matrix(0,n,R[i])
> 62 w[1:n11[[i]][1],1]=1
> 63 if (R[i]>1){
> 64 for (j in 2:R[i]){
> 65 s1=sum(n11[[i]][1:(j-1)])
> 66 w[(1+s1):(s1+n11[[i]][j]),j]=1
> 67 }}
> 68 W[[i]]=w
> 69 }
> 
> 70 for (i1 in 1:nbrefoissim){
> 
> 71 # data generation
> 72 VA1=mvrno

Re: [R] Please need help to finalize my code

2020-10-13 Thread PIKAL Petr
Hm. Google tells me that kernel function is in stats package which comes with 
base installation and is invoked when you start R.

 

search()

[1] ".GlobalEnv""package:stats" "package:graphics" 

[4] "package:grDevices" "package:utils" "package:datasets" 

[7] "package:methods"   "Autoloads" "package:base" 

 

And BTW, keep your posts on R-help, others could give you more relevant answers.

 

Cheers

Petr

 

From: Ablaye Ngalaba  
Sent: Monday, October 12, 2020 7:58 PM
To: PIKAL Petr 
Subject: Re: [R] Please need help to finalize my code

 

Hello.
Thank you for your response.
I would like to ask you the name of the package to install when you want to use 
the kernels 

 

Le lun. 12 oct. 2020 à 08:28, PIKAL Petr mailto:petr.pi...@precheza.cz> > a écrit :

Hi.

Maybe you will get better answers, but from your code it seems to me that you 
are treating R as C or other similar language which is not optimal. Considering 
your first 9 lines, it could be changed either to

CenteringV <- function(X, Ms, n) X-Ms

or you probably could use functions sweep or scale.
Your other code is beyond my experience, sorry.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Ablaye Ngalaba
> Sent: Saturday, October 10, 2020 9:24 PM
> To: r-help@r-project.org  
> Subject: [R] Please need help to finalize my code
> 
> Good evening dear administrators,
> It is with pleasure that I am writing to you to ask for help to finalize my R
> programming algorithm.
> 
> Indeed, I attach this note to my code which deals with a case of independence
> test statistic . My request is to introduce the kernels using the functional 
> data
> for this same code that I am sending you. So I list the lines for which we 
> need
> to introduce the functional data using the kernels below.
> 
> First of all for this code we need to use the functional data. I have numbered
> the lines myself from the original code to give some indication about the 
> lines
> of code to introduce the kernel.
> 1)Centering of redescription function phi(xi) (just use the kernel) 2)this
> function centers the functional data phi(xi) (just use the kernel)
> 3)phi(x1) (or kernel k( ., .) )
> 5)Even here the kernel with the functional data is used.
> 7)return the kernel
> 28) kernel dimension
> 29) kernel dimension
> 30)kernel dimension
> 73) redescription function phi(xi) or the kernel k(. , .) 74)redescription 
> function
> phi(yi) or the kernel k(. , .) 76)redescription function phi(xbar) or the 
> kernel k(.
> , .) 77)redescription function phi(xjhbar) or the kernel k(. , .) 
> 82)redescription
> function phi(xi) or the kernel k(. , .) introduced instead of x 
> 84)redescription
> function phi(xjhbar) or the kernel k(. , .) 89)w= redescription function
> phi(xbar) or the kernel k(. , .)
> 120) we center the redescription function phi(xi) or the kernel k(. , .) 
> 121)Vn is
> a kernel function, so we use ph(xi) or the kernel k(. , , .) 126)centering of 
> the
> redescription function phi(xji) or the kernel k(. , .) 127)Vij is computed 
> using
> redescription function phi(xi) or the kernel k(.
> , .) instead of X.
> 130)centering redescription function phi(Xkl) or the kernel k(. , .) 131)Vijkl
> always using the kernel function as precedent 132)Vkl always using the kernel
> function as precedent
> 
>  I look forward to your help and sincere request.
> 
> 
>  Yours sincerely
> 
> library(MASS)
> 
> 1 CenteringV<-function(X,Ms,n){
> 2 # this function centers the data of X
> 3 X1=X*0
> 4 for (i in 1:n){
> 5 X1[i,]=X[i,]-Ms
> 6 }
> 7 return(X1)
> 8 }
> 
> 
> 9 # Function N°2
> 10 SqrtMatrix0<-function(M) {
> 11 # This function allows us to compute the square root of a matrix
> 12 # using the decomposition M=PDQ where Q is the inverse of P
> 13 # here negative eigenvalues are replaced by zero
>  14 a=eigen(M,TRUE)
>  15 b=a$values
>  16 b[b<0]=0
>  17 c=a$vectors
> 18 d=diag(sqrt(b))
>  19 b=solve(c)
> 20 a=c%*%d%*%b
> 21 return(a)
> 22 }
> 
> 
> 23 # declaration of parameters
> 24 m1=0.01 # alpha value (1% risk)
> 25 m2=0.05 # alpha value (5% risk)
> 26 m3=0.1 # alpha value (10% risk)
> 27 nbrefoissim=100 # # times the program is running
> 28 p=3 #dimension of variable X
> 29 q=3 #dimension of variable Y
> 30 R=c(5,4,3);# Number of partition of each component of variable Y
> 31 if(length(R) != q) stop("The size of R must be equal to q")
> 32 n=25 # Sample size
> 33 N=c(25,50,100,200,300,400,500,1000) #different sample sizes
> 34 #N=c(25,50) #different sample sizes
> 35 pc1=rep(0.100)
> 36 K=0
> 37 MV=matrix(0,nr=8,nc=4)
> 38 dimnames(MV)[[2]]=c("n","r1%","r5%","r10%")
> 
> 
> 39 #Beginning of the program
> 
>  40 for (n in N){
> 
> 
> 41 l1=0 # initialization of the value to calculate the test level at 1%.
> 42 l2=0 # initialization of the value to calculate the test level at 5%.
> 43 l3=0 # initialization of the value to calculate the test level at 10%.
> 
> 44 # Creation

Re: [R] exiting mclapply early on error

2020-10-13 Thread Bert Gunter
This may be O/T. If so, either reply privately or not at all.

"objective function diverges to infinity."

How do you operationally define that? Detecting Inf -- e.g. 1/0, log(0),
etc -- is straightforward. But how do you know other than via math whether
iterations will continue to diverge or not? Would you not need to
operationalize that by defining  divergence criteria? -- e.g. too many
iterations, objective function grows/shrinks too slowly, etc. In other
words, more or less the usual adapted to your particular context.

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 Tue, Oct 13, 2020 at 9:13 AM Giovanni Righi  wrote:

> Thanks for the response, Jeremie. I wholeheartedly agree about testing.
>
> In my case, this feature would be used purely to reduce computation time.
> I’m calculating
> an expensive (and embarrassingly parallel) likelihood function, and for
> some parameter combinations
> my objective function diverges to infinity. In those instances, I’d like
> to throw an error that stops
> subsequent computations and that I could catch to return a value of
> infinity. I agree, though,
> that the default should allow all processes to finish.
>
> What I’ve suggested does not seem possible with mclapply(). Do you know
> how I could suggest
> this as a feature request to the maintainer of the parallel package?
>
> Thanks,
> Giovanni
> __
> 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] Please need help to finalize my code

2020-10-13 Thread Richard O'Keefe
What do you *mean* "when you want to use the kernels".
WHICH kernels?
Use to do WHAT?
In your browser, visit cran.r-project.org
then select "Packages" from the list on the left.
Then pick the alphabetic list.
Now search for 'kernel'.
You will find dozens of matches.

On Wed, 14 Oct 2020 at 05:15, PIKAL Petr  wrote:

> Hm. Google tells me that kernel function is in stats package which comes
> with base installation and is invoked when you start R.
>
>
>
> search()
>
> [1] ".GlobalEnv""package:stats" "package:graphics"
>
> [4] "package:grDevices" "package:utils" "package:datasets"
>
> [7] "package:methods"   "Autoloads" "package:base"
>
>
>
> And BTW, keep your posts on R-help, others could give you more relevant
> answers.
>
>
>
> Cheers
>
> Petr
>
>
>
> From: Ablaye Ngalaba 
> Sent: Monday, October 12, 2020 7:58 PM
> To: PIKAL Petr 
> Subject: Re: [R] Please need help to finalize my code
>
>
>
> Hello.
> Thank you for your response.
> I would like to ask you the name of the package to install when you want
> to use the kernels
>
>
>
> Le lun. 12 oct. 2020 à 08:28, PIKAL Petr  petr.pi...@precheza.cz> > a écrit :
>
> Hi.
>
> Maybe you will get better answers, but from your code it seems to me that
> you are treating R as C or other similar language which is not optimal.
> Considering your first 9 lines, it could be changed either to
>
> CenteringV <- function(X, Ms, n) X-Ms
>
> or you probably could use functions sweep or scale.
> Your other code is beyond my experience, sorry.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help  On Behalf Of Ablaye Ngalaba
> > Sent: Saturday, October 10, 2020 9:24 PM
> > To: r-help@r-project.org 
> > Subject: [R] Please need help to finalize my code
> >
> > Good evening dear administrators,
> > It is with pleasure that I am writing to you to ask for help to finalize
> my R
> > programming algorithm.
> >
> > Indeed, I attach this note to my code which deals with a case of
> independence
> > test statistic . My request is to introduce the kernels using the
> functional data
> > for this same code that I am sending you. So I list the lines for which
> we need
> > to introduce the functional data using the kernels below.
> >
> > First of all for this code we need to use the functional data. I have
> numbered
> > the lines myself from the original code to give some indication about
> the lines
> > of code to introduce the kernel.
> > 1)Centering of redescription function phi(xi) (just use the kernel)
> 2)this
> > function centers the functional data phi(xi) (just use the kernel)
> > 3)phi(x1) (or kernel k( ., .) )
> > 5)Even here the kernel with the functional data is used.
> > 7)return the kernel
> > 28) kernel dimension
> > 29) kernel dimension
> > 30)kernel dimension
> > 73) redescription function phi(xi) or the kernel k(. , .)
> 74)redescription function
> > phi(yi) or the kernel k(. , .) 76)redescription function phi(xbar) or
> the kernel k(.
> > , .) 77)redescription function phi(xjhbar) or the kernel k(. , .)
> 82)redescription
> > function phi(xi) or the kernel k(. , .) introduced instead of x
> 84)redescription
> > function phi(xjhbar) or the kernel k(. , .) 89)w= redescription function
> > phi(xbar) or the kernel k(. , .)
> > 120) we center the redescription function phi(xi) or the kernel k(. , .)
> 121)Vn is
> > a kernel function, so we use ph(xi) or the kernel k(. , , .)
> 126)centering of the
> > redescription function phi(xji) or the kernel k(. , .) 127)Vij is
> computed using
> > redescription function phi(xi) or the kernel k(.
> > , .) instead of X.
> > 130)centering redescription function phi(Xkl) or the kernel k(. , .)
> 131)Vijkl
> > always using the kernel function as precedent 132)Vkl always using the
> kernel
> > function as precedent
> >
> >  I look forward to your help and sincere request.
> >
> >
> >  Yours sincerely
> >
> > library(MASS)
> >
> > 1 CenteringV<-function(X,Ms,n){
> > 2 # this function centers the data of X
> > 3 X1=X*0
> > 4 for (i in 1:n){
> > 5 X1[i,]=X[i,]-Ms
> > 6 }
> > 7 return(X1)
> > 8 }
> >
> >
> > 9 # Function N°2
> > 10 SqrtMatrix0<-function(M) {
> > 11 # This function allows us to compute the square root of a matrix
> > 12 # using the decomposition M=PDQ where Q is the inverse of P
> > 13 # here negative eigenvalues are replaced by zero
> >  14 a=eigen(M,TRUE)
> >  15 b=a$values
> >  16 b[b<0]=0
> >  17 c=a$vectors
> > 18 d=diag(sqrt(b))
> >  19 b=solve(c)
> > 20 a=c%*%d%*%b
> > 21 return(a)
> > 22 }
> >
> >
> > 23 # declaration of parameters
> > 24 m1=0.01 # alpha value (1% risk)
> > 25 m2=0.05 # alpha value (5% risk)
> > 26 m3=0.1 # alpha value (10% risk)
> > 27 nbrefoissim=100 # # times the program is running
> > 28 p=3 #dimension of variable X
> > 29 q=3 #dimension of variable Y
> > 30 R=c(5,4,3);# Number of partition of each component of variable Y
> > 31 if(length(R) != q) stop("The size of R must be equal to q")
> > 32 n=25 # 

[R] Help in Coding

2020-10-13 Thread Faheem Jan via R-help


Good morning dear administrators,
Please help me to code this code in R.
I working in the multivariate time series data, know my objective is that to 
one year forecast of the hourly time series data, using first five as a 
training set and the remaining one year as validation. For this  I transform 
the the data into functional data through Fourier basis functional, apply 
functional principle components as dimensional reduction explaining a specific 
amount of variation   , using the corresponding  functional principle 
components scores. I use the VAR model on those FPCscores for forecasting one 
day ahead forecast, know my problem is that i choose four Fpc,s which give only 
four value in a single day, I want the forecast for 24 hours not only 4, and 
then i want to transform it back to the original functional data. for the 
understanding i am sharing my code (1) transform of the multivariate time 
series data in functional data(2) the functional principle components and the 
corresponding scores(3) I use functional final prediction error for the 
selection of the parameters on the VAR model(4) Using VAR for the analysis and 
forecasting .(1) nb = 23 # number of basis functions for the data  fbf = 
create.fourier.basis(rangeval=c(0,1), nbasis=nb) # basis for data  
args=seq(0,1,length=24)  fdata1=Data2fd(args,y=t(mat),fbf) # functions 
generated from discretized y(2) ffpe = fFPE(fdata1, Pmax=10)  d.hat = ffpe[1] 
#order of the model  p.hat = ffpe[2] #lag of the model
(3) n = ncol(fdata1$coef)  D = nrow(fdata1$coef)  #center the data  mu = 
mean.fd(fdata1)  data = center.fd(fdata1)  #fPCA  fpca = pca.fd(data,nharm=D)  
scores = fpca$scores[,1:d.hat](4) # to avoid warnings from vars predict 
function below      colnames(scores) <- as.character(seq(1:d.hat))      
VAR.pre= predict(VAR(scores, p.hat), n.ahead=1, type="const")$fcst
after this iIneed help first how i transform this into original Functional data 
and to obtain the for for each 24 hours (mean one day forecast) and to how to 
generalize the result for one year.

[[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] Help in Coding

2020-10-13 Thread Jeff Newmiller
1) If you get help on this mailing list, it will generally be from someone like 
yourself... not an "administrator".

2) You desperately need to learn how to send your emails to this list in plain 
text format... See [1] to see how WE see your html-formatted email run through 
a blender. Sending in plain text is a setting in your email client... there are 
way too many client software packages out there for us to be able to help you 
figure that out.

3) Read the Posting Guide mentioned at the bottom of every email on this 
mailing list. One of the items you should note is that homework help is 
off-topic here. (We don't know what help would break the ethics rules of your 
educational institution, and they by definition have avenues for student 
assistance.)

4) This is not a "do my work for me" service. If you want non-homework help, 
post a reproducible example using plain text so we can quickly get an R session 
setup with your problem data and (broken?) code. [2][3][4]

[1] https://stat.ethz.ch/pipermail/r-help/2020-October/469056.html

[2] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[3] http://adv-r.had.co.nz/Reproducibility.html

[4] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 

On October 13, 2020 8:42:08 PM PDT, Faheem Jan via R-help 
 wrote:
>
>Good morning dear administrators,
>Please help me to code this code in R.
>I working in the multivariate time series data, know my objective is
>that to one year forecast of the hourly time series data, using first
>five as a training set and the remaining one year as validation. For
>this  I transform the the data into functional data through Fourier
>basis functional, apply functional principle components as dimensional
>reduction explaining a specific amount of variation   , using the
>corresponding  functional principle components scores. I use the VAR
>model on those FPCscores for forecasting one day ahead forecast, know
>my problem is that i choose four Fpc,s which give only four value in a
>single day, I want the forecast for 24 hours not only 4, and then i
>want to transform it back to the original functional data. for the
>understanding i am sharing my code (1) transform of the multivariate
>time series data in functional data(2) the functional principle
>components and the corresponding scores(3) I use functional final
>prediction error for the selection of the parameters on the VAR
>model(4) Using VAR for the analysis and forecasting .(1) nb = 23 #
>number of basis functions for the data  fbf =
>create.fourier.basis(rangeval=c(0,1), nbasis=nb) # basis for data 
>args=seq(0,1,length=24)  fdata1=Data2fd(args,y=t(mat),fbf) # functions
>generated from discretized y(2) ffpe = fFPE(fdata1, Pmax=10)  d.hat =
>ffpe[1] #order of the model  p.hat = ffpe[2] #lag of the model
>(3) n = ncol(fdata1$coef)  D = nrow(fdata1$coef)  #center the data  mu
>= mean.fd(fdata1)  data = center.fd(fdata1)  #fPCA  fpca =
>pca.fd(data,nharm=D)  scores = fpca$scores[,1:d.hat](4) # to avoid
>warnings from vars predict function below      colnames(scores) <-
>as.character(seq(1:d.hat))      VAR.pre= predict(VAR(scores, p.hat),
>n.ahead=1, type="const")$fcst
>after this iIneed help first how i transform this into original
>Functional data and to obtain the for for each 24 hours (mean one day
>forecast) and to how to generalize the result for one year.
>
>   [[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.

-- 
Sent from my phone. Please excuse my brevity.

__
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.