在使用Biogeme进行参数估计时,可以通过设置calculateRobustStdErrors=True来计算参数的p值。这个参数会使用bootstrap方法来计算标准差和置信区间,从而得到p值。以下是一个使用Biogeme进行参数估计并计算p值的示例代码:

# 导入所需的包
import biogeme.database as db
import biogeme.biogeme as bio
import biogeme.results as res
from biogeme.expressions import Beta, DefineVariable

# 创建数据集
database = db.Database("data.csv")
globals().update(database.variables)

# 创建变量
age = DefineVariable('age', age)
income = DefineVariable('income', income)

# 假设模型
ASC = Beta('ASC', 0, None, None, 0)
B_age = Beta('B_age', 0, None, None, 0)
B_income = Beta('B_income', 0, None, None, 0)

# 用于估计参数的数据集
data = database.data

# 创建选择集
V = ASC + B_age * age + B_income * income
V_no_choice = ASC + B_age * age

# 创建模型
prob = bio.exp(V) / (bio.exp(V) + bio.exp(V_no_choice))
logprob = bio.log(prob)

# 估计参数
biogeme = bio.BIOGEME(database, logprob)
biogeme.calculateRobustStdErrors = True
results = biogeme.estimate()

# 输出结果
print(results.getEstimatedParameters())

在上述代码中,通过设置biogeme.calculateRobustStdErrors = True来计算参数的p值。然后使用results.getEstimatedParameters()函数来获取估计的参数及其相应的p值。

使用Biogeme估计参数并计算p值

原文地址: https://www.cveoy.top/t/topic/qbyH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录