0

I have to use the gmm function in order to estimate the scale parameters of a normal distribution and then with the Poisson distribution. Then I have to see which distribution fits the most with my data.

I already stuck with the normal distribution.

My dataset contains the Us Income compiled in 2020 (per region). There is just on column with numerical variables.

I start by writing this code (I've already cleaned my data set) :

g0 <- function(mu, sigma, x) {
m1<- (x - mu)
m2<- (x - mu)^2 - (sigma)^2
f<-cbind(m1, m2)
return(f)
}

These are my just-identified moment conditions (for the normal distribution)

g1 <- function(mu, sigma, x) {
m1<- (x - mu)
m2<- (x - mu)^2 - (sigma)^2
m3 <- (x - mu / sigma)^3
f <- cbind(m1, m2, m3)
return (f)
}

These are my over-indentified moment conditions

value_2020 = income_2$value_2020

this is to take only the column where there is numerical variable in my data set

print(res0 <- gmm(g0, value_2020, t0 =c(mu = 0, sigma =0), wmatrix = "ident"))

And that's where I'm stucked.

The output is :

Erreur dans object$g(object$t0, object$x) : 
l'argument "x" est manquant, avec aucune valeur par défaut

I don't know what to do, I'm pretty new with R so it's pretty difficult for me.

Thanks a lot in advance for your answers,

Maxime

1 Answers1

0

x <- incomeclean$value_2020

g0 <- function(tet, x) {
  +     m1 <- (tet[1] - x)
  +     m2 <- (tet[2]^2 - (x - tet[1])^2)
  +     f <- cbind(m1, m2)
  +     return(f)

print(res0 <- gmm(g0, x, c(mu = 0, sig = 0)))


summarise(res0)
mbd
  • 1