Question
Would you please help with r codes for the following
1. Independently generate a, a, and a, from a uniform distribution in the range (-1, 1) conditioned on la, + a2 + al < 1. 2. Generate a series of size 100+ S from the AR process as represented in Equation (1) of order p 3 with ao-0.0 and a,, a, and a, obtained from Step 1. Initialize the starting value, yo 0.0. Discard the first 100 observations to minimize the effect of initial value.
media%2Fe3a%2Fe3a0c067-37ae-4613-aa4c-3f
Where S is the sample size S=50,100,200

media%2F9cd%2F9cd3bafd-f2ec-4a08-8db8-29
Do at least half of the steps please

Thanks
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The error term is generated from standard normal distribution.  In our effort to minimize the initial effect, we simulate 100 + S observations and discard the first 100 observations, leaving the last S observations for order estimation.

R Code:

#Generate a1,a2 and a3 from uniform distribution
a1=2;a2=2;a3=2;
while (abs(a1+a2+a3)>1) {
a1 = runif(1, min = -1, max = 1)
a2 = runif(1, min = -1, max = 1)
a3 = runif(1, min = -1, max = 1)
}
a0=0;
# For S = 200 and p = 3
S = 50;
n = 100+S;
set.seed(1)
e=rnorm(n)
Y=rep(0,n);
y[0]=0
for(t in 4:n)
Y[t]=a0+a1*Y[t-1]+a2*Y[t-2]+a3*Y[t-3]+e[t]
n1 = length(Z)
Y = Y[101:n1]
# For S = 100 and p = 3
S = 100;
n = 100+S;
set.seed(1)
e=rnorm(n)
Y=rep(0,n);
y[0]=0
for(t in 4:n)
Y[t]=a0+a1*Y[t-1]+a2*Y[t-2]+a3*Y[t-3]+e[t]
n1 = length(Z)
Y = Y[101:n1]
# For S = 200 and p = 3
S = 200;
n = 100+S;
set.seed(1)
e=rnorm(n)
Y=rep(0,n);
y[0]=0
for(t in 4:n)
Y[t]=a0+a1*Y[t-1]+a2*Y[t-2]+a3*Y[t-3]+e[t]
n1 = length(Z)
Y = Y[101:n1]

Output:

For S = 50;

> a1
[1] 0.3474245
> a2
[1] -0.8102843
> a3
[1] -0.01480776
> Y
[1] 0.32287902 0.63377260 -0.86103374 -1.71366112
[5] -1.19969171 0.88768788 0.29132765 -0.30755738
[9] 1.43315518 1.84968667 0.46679287 -0.56464294
[13] -1.49396639 0.34129495 2.44164714 0.27898169
[17] -1.56981237 -0.65019564 2.39204148 -0.02491549
[21] -1.49440536 -0.79131151 0.79223157 0.59987858
[25] -0.61055845 -0.99622302 -0.24799895 1.49272956
[29] -0.54207748 -3.22714727 -0.01697972 3.06409058
[33] 1.92582934 -0.23230906 -2.30705395 1.08616817
[37] 1.09617732 -0.59148355 -2.51673652 -0.38319946
[41] 3.75548892 2.04820648 -0.73754200 -3.01567692
[45] 0.27380253 2.54486835 0.31072559 -0.58419050
[49] 1.13762026 -0.16611497 -1.03561485 -1.01774617
>

For S = 100

> Y
[1] 0.32287902 -0.34649406 -1.30231071 -0.01844825
[5] 0.39937869 1.94027383 1.06746897 -0.29704824
[9] -0.61270091 1.69419549 0.45372905 -1.66771542
[13] 0.46014034 0.85377255 -0.25890863 -1.18137125
[17] -0.53328300 0.49669156 1.11635543 -0.18404593
[21] -1.48181968 0.96081722 1.32265251 -0.47662736
[25] -1.35173485 0.60965869 1.24059323 -0.08060243
[29] -1.72392462 -0.87626339 1.15378768 0.54750950
[33] -0.20020614 -2.04867395 -0.25108509 0.03928999
[37] -0.05353925 -0.57499881 -0.80906321 0.12872016
[41] -1.20555324 0.66542511 -0.45885268 -1.14427902
[45] -1.15152297 -0.21690036 2.96181523 1.23920512
[49] -3.25247089 -3.81855978 1.74060222 3.72844877
[53] -0.37655238 -4.10706353 -2.66445015 1.33257748
[57] 3.68277733 -0.38209181 -4.52100399 0.55365254
[61] 4.28640924 0.86888632 -2.12105300 -0.61800010
[65] 0.87183827 3.04116422 0.10426217 -3.86538898
[69] -1.61684513 2.77632686 4.63988422 -0.50786052
[73] -3.52018083 -0.95734477 2.19326166 1.55511414
[77] -0.43506503 0.63153093 1.57630034 1.25027645
[81] -2.08354975 -0.77640143 1.61993779 -0.24448543
[85] -0.86503085 -0.28517243 2.07005262 0.19698484
[89] -2.03488276 -1.82334411 0.83533831 2.19978788
[93] -0.61734991 -1.17893234 -1.15001772 -0.48311678
[97] 2.22260975 0.16483266 -1.32455027 -1.00773041
>

For S = 200

> Y
[1] 0.32287902 -0.34649406 -1.30231071 -0.01844825
[5] 0.39937869 1.94027383 1.06746897 -0.29704824
[9] -0.61270091 1.69419549 0.45372905 -1.66771542
[13] 0.46014034 0.85377255 -0.25890863 -1.18137125
[17] -0.53328300 0.49669156 1.11635543 -0.18404593
[21] -1.48181968 0.96081722 1.32265251 -0.47662736
[25] -1.35173485 0.60965869 1.24059323 -0.08060243
[29] -1.72392462 -0.87626339 1.15378768 0.54750950
[33] -0.20020614 -2.04867395 -0.25108509 0.03928999
[37] -0.05353925 -0.57499881 -0.80906321 0.12872016
[41] -1.20555324 0.66542511 -0.45885268 -1.14427902
[45] -1.15152297 -0.21690036 2.96181523 1.23920512
[49] -3.25247089 -3.81855978 1.74060222 3.72844877
[53] -0.37655238 -4.10706353 -2.66445015 1.33257748
[57] 3.68277733 -0.38209181 -4.52100399 0.55365254
[61] 4.28640924 0.86888632 -2.12105300 -0.61800010
[65] 0.87183827 3.04116422 0.10426217 -3.86538898
[69] -1.61684513 2.77632686 4.63988422 -0.50786052
[73] -3.52018083 -0.95734477 2.19326166 1.55511414
[77] -0.43506503 0.63153093 1.57630034 1.25027645
[81] -2.08354975 -0.77640143 1.61993779 -0.24448543
[85] -0.86503085 -0.28517243 2.07005262 0.19698484
[89] -2.03488276 -1.82334411 0.83533831 2.19978788
[93] -0.61734991 -1.17893234 -1.15001772 -0.48311678
[97] 2.22260975 0.16483266 -1.32455027 -1.00773041
[101] 1.13011312 2.91766397 1.69946560 -2.12134359
[105] -4.44249654 2.64795571 5.21812826 0.27441926
[109] -4.18543719 -1.24364126 2.79088323 2.45999567
[113] -1.78857736 -4.02622598 1.00185797 5.15668747
[117] 0.73064843 -5.19266273 -1.83020869 3.51614535
[121] 1.04825756 -2.45565386 -2.38490743 0.80471163
[125] 1.09181989 1.56573679 -0.68375725 -3.12792674
[129] -0.35867213 2.68319898 0.28332625 -4.95932905
[133] -2.63278092 3.67008612 3.42209199 -1.84408780
[137] -2.90707361 -0.75288528 3.21806916 1.76579029
[141] -1.27561293 -0.88751592 0.92259739 0.17985447
[145] 0.49102635 -1.98896523 -1.63634010 0.78018098
[149] 1.46028571 0.91986503 -0.73899379 -0.61655266
[153] 0.30131363 0.36754516 0.58822505 1.04831428
[157] -2.52095822 -1.16124590 1.99844883 1.24731134
[161] -0.21775696 -1.50516061 -0.64928513 1.85466472
[165] 2.91237679 -0.21130538 -2.88291325 -2.06261623
[169] 1.29147195 1.22285464 -0.84999967 -0.91091522
[173] -0.49769768 3.22694141 1.69389530 -0.88866221
[177] -4.01818749 0.03997075 1.96667494 1.63018735
[181] -0.62966056 -1.97632531 1.12369950 1.29987824
[185] -1.01025591 -2.42197019 -0.71028410 2.67585890
[189] 1.97475699 -0.46645060 -2.19191305 -0.03643806
[193] 2.01448525 -0.66439337 -0.08416340 0.61372474
[197] 1.05685645 0.82626922 -0.62894162 -1.20948777
>

I could only do step 1 and step 2 because you haven't mentioned any thing about the selection criteria. Please post step 3 onwards as separte and mention the six selection criteria for finding the order of AR.

Also, please like the solution if it helps you thank you.

Add a comment
Know the answer?
Add Answer to:
Would you please help with r codes for the following Where S is the sample size...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are given the following information obtained from a random sample of five observations. 20 18...

    You are given the following information obtained from a random sample of five observations. 20 18 17 22 18 At a 10% level of significance, use Excel to determine whether or not the mean of the population from which this sample was taken is significantly less than 21. (Assume the population is normally distributed.) Complete the following table with your Excel functions and the corresponding values. The sample size row is an example. Sate your conclusion about the sample observations...

  • Please exain it thoroughly, will give you good rating if you help me with those Q’s....

    Please exain it thoroughly, will give you good rating if you help me with those Q’s. They are all part of one Q Q3. A particular system can be represented by the following state space equation [2]-[2 ].[2]. where system is simulated using Euler Integration the plot shown in Figure Q3 is obtained when a step of magnitude equal to 3.5 is applied to the input. The simulation step size used to obtain these responses is 0.5 seconds. xi and...

  • AlleleA1 program Natural selection ASAP please please Please help if you know about this program, because...

    AlleleA1 program Natural selection ASAP please please Please help if you know about this program, because ihave truble with explaining rezults. thank you!!! 1. Set the fitness value of A1A1 genotype to 0.9 .Describe and explain results? 2. There's horizontal line ,explain why a horizontal line is expected? 3. Is it possible that two genotype (see image) have the same fitness values? How such a situation could arise in an actual population? Thank you!! Al: 0.02062 A2: 0.97938 AIA1: 0.00043...

  • STATS Use the R function rnorm() to simulate selecting a random sample of size 25 from...

    STATS Use the R function rnorm() to simulate selecting a random sample of size 25 from a population with mean 80 and s.d. 20. The goal here is to show how contamination affects the mean, s.d., and z-scores. (a) Obtain the sample mean and sample sd of the simulated sample and use them to obtain the z-score for 100. (b) Create the vector contam = c(0,seq(1000,10000,length=21)) To show the effects of contamination, separately add each value of contam to the...

  • IN C++ Please!! Declare a global integer constant called SIZE and initialize it to 10. •...

    IN C++ Please!! Declare a global integer constant called SIZE and initialize it to 10. • Declare a global enum variable that will support 10 values – each representing an ant colony {A, B, C, D, E, F, G, H, I, J}. • In the main function, o Declare a 2-dimensional array of size the global integer constant, SIZE. The number of rows and columns should be equal to SIZE, which would make this a square matrix. This array will...

  • Can someone please help me with this? Using the following sample data size of 30 homes for the fo...

    Can someone please help me with this? Using the following sample data size of 30 homes for the following variables; variable a) is address, variable b) is asking price, variable c) is square footage, variable d) is number of days on market and variable e) is cost per square foot, please answer the following below. 1) for variables b-e(asking price, square footage, number of days on market and cost per square foot, determine 96% confidence interval and interpret each result...

  • help! 1 , 2 and extra credit! please answer all. 1. You study the following reaction...

    help! 1 , 2 and extra credit! please answer all. 1. You study the following reaction in a series of experiments: (CH),COH(aq) + HCl(aq) à (CH),CCl(aq) +H,0(1) At 100.C you obtained the following data: Experiment (CH.COH., MHCIL. M Initial Rate, M's 100 0.100 5.0 x 10 0.100 10 x 10 300 6.200 10x10 0.300 0.100 1.5 x 10 0.00 Please do the following: a. Write the rate law for the reaction. b. Indicate the order of the reaction with respect...

  • The Binomial and Poisson Distributions Both the Binomial and Poisson Distributions deal with discrete data where...

    The Binomial and Poisson Distributions Both the Binomial and Poisson Distributions deal with discrete data where we are counting the number of occurrences of an event. However, they are very different distributions.  This problem will help you be able to recognize a random variable that belongs to the Binomial Distribution, the Poisson Distribution or neither. Characteristics of a Binomial Distribution Characteristics of a Poisson Distribution The Binomial random variable is the count of the number of success in n trials:   number of...

  • Choose the correst answer(s) on questions 1-5 (Please Help) Question 1 Which of the following statements...

    Choose the correst answer(s) on questions 1-5 (Please Help) Question 1 Which of the following statements is true? (Select all correct answers) If the mean of two groups remains the same, the P value will not change even if the sample size (n) of those two groups changes. The P value is the probability that the alternative hypothesis is true. In a study of comparing the amount of alcohol consumed by men and women the null hypothesis would be defined...

  • Nombre . Responde las siguientes preguntas A) SI P(A 6 B)-1/3 P(B)- 1/4 y P(Ay B)-1/5, halle P(A) B ) Cual es la probabilidad de lanzar un par de dados y que la suma de los result...

    Nombre . Responde las siguientes preguntas A) SI P(A 6 B)-1/3 P(B)- 1/4 y P(Ay B)-1/5, halle P(A) B ) Cual es la probabilidad de lanzar un par de dados y que la suma de los resultados de los dos dados sea 7 C ) Una prueba de selección múltiple tiene cinco posibles respuestas de las cuales una es correcta, si 13 estudiantes eligen las respuestas al azar. Cuaál es la probabilidad de que los 13 escojan la respuesta correcta?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT