Question: Write a function in R to generate a series of length T, i.e. from the model x i = x i-1 + w i .

Write a function in R to generate a series of length T, i.e. from the model xi = Write a function in R to generate a series of length T,xi-1 + wi. You can enter the parameter i.e. from the model xi = xi-1 + wi. You can enter directly and we only have on fixed parameter the parameter directly and we only have on fixed parameter . Also,. Also, the index i should start from 2.

This will be similar to:

randomwalk=function(sigsq,T){ x=rep(0,T) w=rnorm(T,sd=sqrt(sigsq)) for ( i in 2:T){ x[i]=x[i-1]+w[i] } x }

AND

masim=function(thetas, sigsq, T){ q=length(thetas) noise=rnorm(T+q, sd=sqrt(sigsq)) x=c(noise[1:q],rep(0,T)) #put the initial noise terms in and set the rest to zero for (i in (q+1):(T+q)){ #this loop generates the MA series x[i]=thetas %*% noise[i-(1:q)] +noise[i] } x=x[(q+1):(T+q)] #throw away those initial starting points x }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!