SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
1. R code for Figure 1
set.seed(2880)
tt=2:100
X=vector(length=100)
e1=rpois(1, lambda=1)
alpha=0.5
X[1]=e1
for(t in 2:100){
e=rpois(1, lambda=1)
nt=X[t-1]
S=vector(length=nt )
for(i in 1:nt){
S[i]=rbinom(1,1,0.5)
}
alpha.oX=sum(S)
X[t]= alpha.oX+e
}
X
plot(tt, X[2:100], type='s')
2. R code for Figure 2
set.seed(102)
tt=2:100
X=vector(length=100)
e1=rnorm(n=100, mean = 2, sd = 2)
alpha=0.5
X[1]=e1
for(t in 2:100){
e=rpois(1, lambda=1)
nt=X[t-1]
S=vector(length=nt )
for(i in 1:nt){
S[i]=rbinom(1,1,0.5)
}
alpha.oX=sum(S)
X[t]= alpha.oX+e
}
X
plot(tt, X[2:100], type='s')
3. R code for Table 3
set.seed(2880)
tt=2:51
n=length(tt)
X=vector(length=n+2)
e1=rpois(1, lambda=1)
alpha=0.4
lambda=1
X[1]=e1
for(t in 2:(n+2)){
e=rpois(1, lambda=1)
nt=X[t-1]
S=vector(length=nt )
for(i in 1:nt){
S[i]=rbinom(1,1,0.5)
}
alpha.oX=sum(S)
X[t]= alpha.oX+e
}
X
xbar=mean(X)
Y=X-xbar
length(Y)
Z=Y[2:(n+2)]
xt=Z[1:n]
xt1=Z[2:(n+1)]
alpha_hat1=(t(xt)%*%xt1)/(t(Y)%*%Y)
alpha_hat1-alpha
epsilon_hat=xt1-alpha_hat1*xt
lambda_hat1=mean(epsilon_hat)
#abs(lambda_hat1)-lambda
((lambda/(1-alpha)-Z[(n+1)])/n)-(alpha_hat1-alpha)
alpha_hat2=(sum(xt1*xt)-(sum(xt1)*sum(xt)/n))/
(sum(xt^2)-(sum(xt)^2/n))
alpha_hat2-alpha
lambda_hat2=1/n*(sum(xt1)-alpha_hat2*sum(xt))
((lambda/(1-alpha)-Z[(n+1)])/n)-(alpha_hat2-alpha)

Contenu connexe

Tendances

Quadratic Expressions
Quadratic ExpressionsQuadratic Expressions
Quadratic Expressions2IIM
 
E8 Particle Assignment Symmetry
E8 Particle Assignment SymmetryE8 Particle Assignment Symmetry
E8 Particle Assignment SymmetryJ Gregory Moxness
 
ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-
ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-
ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-ssusere0a682
 
Flash cards derivative
Flash cards derivativeFlash cards derivative
Flash cards derivativeIAmSpartan117
 
1.12 Von Neumann natural numbers
1.12 Von Neumann natural numbers1.12 Von Neumann natural numbers
1.12 Von Neumann natural numbersJan Plaza
 
Engineering Mathematics - Total derivatives, chain rule and derivative of imp...
Engineering Mathematics - Total derivatives, chain rule and derivative of imp...Engineering Mathematics - Total derivatives, chain rule and derivative of imp...
Engineering Mathematics - Total derivatives, chain rule and derivative of imp...Jayanshu Gundaniya
 
Laplace periodic function
Laplace periodic functionLaplace periodic function
Laplace periodic functionKaushal Surti
 
The chain rule
The chain ruleThe chain rule
The chain ruleJ M
 
Niem khuccuoi kyam
Niem khuccuoi kyamNiem khuccuoi kyam
Niem khuccuoi kyam1bidvn1616
 
Programming for Artists and Designers: Week 2
Programming for Artists and Designers: Week 2Programming for Artists and Designers: Week 2
Programming for Artists and Designers: Week 2Tinker
 
Quadratic Functions Min Max
Quadratic Functions Min MaxQuadratic Functions Min Max
Quadratic Functions Min Maxste ve
 
Copia de derivadas tablas
Copia de derivadas tablasCopia de derivadas tablas
Copia de derivadas tablasGeral Delgado
 

Tendances (20)

Quadratic Expressions
Quadratic ExpressionsQuadratic Expressions
Quadratic Expressions
 
E8 Particle Assignment Symmetry
E8 Particle Assignment SymmetryE8 Particle Assignment Symmetry
E8 Particle Assignment Symmetry
 
133467 p2a3
133467 p2a3133467 p2a3
133467 p2a3
 
ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-
ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-
ゲーム理論BASIC 第27回 - 交渉ゲーム : 交渉問題とナッシュ交渉解-
 
Alg2 lesson 5-3 day 1
Alg2 lesson 5-3 day 1Alg2 lesson 5-3 day 1
Alg2 lesson 5-3 day 1
 
Chain Rule
Chain RuleChain Rule
Chain Rule
 
Flash cards derivative
Flash cards derivativeFlash cards derivative
Flash cards derivative
 
Chain rule
Chain ruleChain rule
Chain rule
 
1.12 Von Neumann natural numbers
1.12 Von Neumann natural numbers1.12 Von Neumann natural numbers
1.12 Von Neumann natural numbers
 
Engineering Mathematics - Total derivatives, chain rule and derivative of imp...
Engineering Mathematics - Total derivatives, chain rule and derivative of imp...Engineering Mathematics - Total derivatives, chain rule and derivative of imp...
Engineering Mathematics - Total derivatives, chain rule and derivative of imp...
 
Laplace periodic function
Laplace periodic functionLaplace periodic function
Laplace periodic function
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
Niem khuccuoi kyam
Niem khuccuoi kyamNiem khuccuoi kyam
Niem khuccuoi kyam
 
Programming for Artists and Designers: Week 2
Programming for Artists and Designers: Week 2Programming for Artists and Designers: Week 2
Programming for Artists and Designers: Week 2
 
Quadratic Functions Min Max
Quadratic Functions Min MaxQuadratic Functions Min Max
Quadratic Functions Min Max
 
CLUSTERGRAM
CLUSTERGRAMCLUSTERGRAM
CLUSTERGRAM
 
Copia de derivadas tablas
Copia de derivadas tablasCopia de derivadas tablas
Copia de derivadas tablas
 
Seg code
Seg codeSeg code
Seg code
 
Application of Derivative 7
Application of Derivative 7Application of Derivative 7
Application of Derivative 7
 
Ejercicios estatica
Ejercicios estatica  Ejercicios estatica
Ejercicios estatica
 

Similaire à R code INAR(1)

Signals and systems: part i solutions
Signals and systems: part i solutionsSignals and systems: part i solutions
Signals and systems: part i solutionsPatrickMumba7
 
Фізичні методи дослідження_лекції.pdf
Фізичні методи дослідження_лекції.pdfФізичні методи дослідження_лекції.pdf
Фізичні методи дослідження_лекції.pdfkvmess0
 
ゲーム理論BASIC 第42回 -仁に関する定理の証明3-
ゲーム理論BASIC 第42回 -仁に関する定理の証明3-ゲーム理論BASIC 第42回 -仁に関する定理の証明3-
ゲーム理論BASIC 第42回 -仁に関する定理の証明3-ssusere0a682
 
ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-
ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-
ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-ssusere0a682
 
Assignment properties of linear time-invariant systems
Assignment properties of linear time-invariant systemsAssignment properties of linear time-invariant systems
Assignment properties of linear time-invariant systemsPatrickMumba7
 
Signals and Systems part 2 solutions
Signals and Systems part 2 solutions Signals and Systems part 2 solutions
Signals and Systems part 2 solutions PatrickMumba7
 
Arithmetic progression ex no. 4
Arithmetic progression ex no. 4Arithmetic progression ex no. 4
Arithmetic progression ex no. 4AMIN BUHARI
 
8 Continuous-Time Fourier Transform Solutions To Recommended Problems
8 Continuous-Time Fourier Transform Solutions To Recommended Problems8 Continuous-Time Fourier Transform Solutions To Recommended Problems
8 Continuous-Time Fourier Transform Solutions To Recommended ProblemsSara Alvarez
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tablesGaurav Vasani
 
Lesson 7: Vector-valued functions
Lesson 7: Vector-valued functionsLesson 7: Vector-valued functions
Lesson 7: Vector-valued functionsMatthew Leingang
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signalsDr.SHANTHI K.G
 

Similaire à R code INAR(1) (20)

Signals and systems: part i solutions
Signals and systems: part i solutionsSignals and systems: part i solutions
Signals and systems: part i solutions
 
Sequence of DM
Sequence of  DM Sequence of  DM
Sequence of DM
 
convulution
convulutionconvulution
convulution
 
Фізичні методи дослідження_лекції.pdf
Фізичні методи дослідження_лекції.pdfФізичні методи дослідження_лекції.pdf
Фізичні методи дослідження_лекції.pdf
 
ゲーム理論BASIC 第42回 -仁に関する定理の証明3-
ゲーム理論BASIC 第42回 -仁に関する定理の証明3-ゲーム理論BASIC 第42回 -仁に関する定理の証明3-
ゲーム理論BASIC 第42回 -仁に関する定理の証明3-
 
ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-
ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-
ゲーム理論NEXT コア第2回 -3人ゲームのコアの存在-
 
Md Nasfik
Md NasfikMd Nasfik
Md Nasfik
 
Assignment properties of linear time-invariant systems
Assignment properties of linear time-invariant systemsAssignment properties of linear time-invariant systems
Assignment properties of linear time-invariant systems
 
Signals and Systems part 2 solutions
Signals and Systems part 2 solutions Signals and Systems part 2 solutions
Signals and Systems part 2 solutions
 
Arithmetic progression ex no. 4
Arithmetic progression ex no. 4Arithmetic progression ex no. 4
Arithmetic progression ex no. 4
 
8 Continuous-Time Fourier Transform Solutions To Recommended Problems
8 Continuous-Time Fourier Transform Solutions To Recommended Problems8 Continuous-Time Fourier Transform Solutions To Recommended Problems
8 Continuous-Time Fourier Transform Solutions To Recommended Problems
 
Signals Processing Homework Help
Signals Processing Homework HelpSignals Processing Homework Help
Signals Processing Homework Help
 
About RNN
About RNNAbout RNN
About RNN
 
About RNN
About RNNAbout RNN
About RNN
 
Laplace_1.ppt
Laplace_1.pptLaplace_1.ppt
Laplace_1.ppt
 
Sequences And Series
Sequences And SeriesSequences And Series
Sequences And Series
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tables
 
Lesson 7: Vector-valued functions
Lesson 7: Vector-valued functionsLesson 7: Vector-valued functions
Lesson 7: Vector-valued functions
 
Arithmetic series
Arithmetic seriesArithmetic series
Arithmetic series
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signals
 

R code INAR(1)

  • 1. 1. R code for Figure 1 set.seed(2880) tt=2:100 X=vector(length=100) e1=rpois(1, lambda=1) alpha=0.5 X[1]=e1 for(t in 2:100){ e=rpois(1, lambda=1) nt=X[t-1] S=vector(length=nt ) for(i in 1:nt){ S[i]=rbinom(1,1,0.5) } alpha.oX=sum(S) X[t]= alpha.oX+e } X plot(tt, X[2:100], type='s') 2. R code for Figure 2 set.seed(102) tt=2:100 X=vector(length=100) e1=rnorm(n=100, mean = 2, sd = 2) alpha=0.5 X[1]=e1 for(t in 2:100){ e=rpois(1, lambda=1) nt=X[t-1] S=vector(length=nt ) for(i in 1:nt){ S[i]=rbinom(1,1,0.5) } alpha.oX=sum(S) X[t]= alpha.oX+e } X plot(tt, X[2:100], type='s')
  • 2. 3. R code for Table 3 set.seed(2880) tt=2:51 n=length(tt) X=vector(length=n+2) e1=rpois(1, lambda=1) alpha=0.4 lambda=1 X[1]=e1 for(t in 2:(n+2)){ e=rpois(1, lambda=1) nt=X[t-1] S=vector(length=nt ) for(i in 1:nt){ S[i]=rbinom(1,1,0.5) } alpha.oX=sum(S) X[t]= alpha.oX+e } X xbar=mean(X) Y=X-xbar length(Y) Z=Y[2:(n+2)] xt=Z[1:n] xt1=Z[2:(n+1)] alpha_hat1=(t(xt)%*%xt1)/(t(Y)%*%Y) alpha_hat1-alpha epsilon_hat=xt1-alpha_hat1*xt lambda_hat1=mean(epsilon_hat) #abs(lambda_hat1)-lambda ((lambda/(1-alpha)-Z[(n+1)])/n)-(alpha_hat1-alpha) alpha_hat2=(sum(xt1*xt)-(sum(xt1)*sum(xt)/n))/ (sum(xt^2)-(sum(xt)^2/n)) alpha_hat2-alpha lambda_hat2=1/n*(sum(xt1)-alpha_hat2*sum(xt)) ((lambda/(1-alpha)-Z[(n+1)])/n)-(alpha_hat2-alpha)