0

假设我有一个如下数据集:

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]

有一篇论文发表在公共经济学杂志上,名为:收入的边际效用,由 Layard、Nickell 和 Mayraz 撰写。rho他们在公式中使用最大似然估计:

在此处输入图像描述

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

我想使用glmR 中的包来做类似的事情。但是,我不确定如何将此公式写入glm函数。有没有人有这方面的经验?

rho这个想法是使用0.1 - 3 范围内的起始值,增量为 0.1。

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)
4

0 回答 0