0

Let's assume that I have a dataset as follows:

set.seed(1)
TDT <- data.table(Country = c(rep("A",30),rep("B",50), rep("C",20)),
                      Id = c(rep(1,20),rep(2,20),rep(3,20),rep(4,20),rep(5,20)),
                      Time = rep(seq(as.Date("2010-01-03"), length=20, by="1 month") - 1,5),
                      norm = round(runif(100)/10,2),
                      Income = sample(100,100),
                      Happiness = sample(10,10),
                      Sex = round(rnorm(10,0.75,0.3),2),
                      Age = round(rnorm(10,0.75,0.3),2),
                      Educ = round(rnorm(10,0.75,0.3),2))
TDT [, ID := .I]

There is a paper, published in the journal of Public Economics called: The marginal utility of income, by Layard, Nickell & Mayraz. They use a maximum likelihood estimation for rho in the formula:

enter image description here

h = happiness
alpha = country
y = income
rho = risk aversion
t = Time
j = ID
gamma = individual fixed effect

I would like to use the glm package from R to do something similar. I am however unsure how to write this formula into the glmfunction. Does anyone have any experience with that?

The idea is to use starting values of rho ranging from 0.1 - 3, with 0.1 increments.

start_rho <- c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,   1.7,    1.8 ,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3)
Tom
  • 2,173
  • 1
  • 17
  • 44
  • 3
    Maybe try `nls`? Why do you need a GLM, do you want to model the errors using some other distribution other than gaussian? https://stats.stackexchange.com/questions/120526/how-to-fit-regression-to-custom-model-in-r – Roman Luštrik Jul 24 '19 at 15:07
  • When you say p, do you mean "rho" (ρ)? – January Jul 24 '19 at 15:22
  • Yes sorry, was a quick post before I left. The letters weren't coming to me. – Tom Jul 24 '19 at 15:23
  • @RomanLuštrik Does `nls` also use maximum likelihood estimation? If not, then that would be the reason (it is much easier to explain using published approaches to a problem). But if it does, I don't see why not. I proposed `glm` because I thought it was the most widely used/safest bet. – Tom Jul 25 '19 at 06:26
  • 1
    [This should get you started](http://www.ms.uky.edu/~mai/sta321/MLEexample.pdf). Good luck! – Roman Luštrik Jul 25 '19 at 15:36

0 Answers0