Stata 错误:在协变量列表中找不到 [英] Stata error: not found in list of covariates

查看:720
本文介绍了Stata 错误:在协变量列表中找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制两个变量之间的交互作用.

I want to plot an interaction effect among two variables.

margins   SentiSat_Rounded#PriceReduction

我收到以下错误:

'SentiSat_Rounded' not found in list of covariates
r(322);

变量存在于数据集中.此外,如果该变量不存在于数据集中,则会引发不同的错误,例如

The variables are present in the dataset. Also if the variable is not present in the dataset it throws a different error, like

variable X not found

您能否建议不出现在协变量列表中是什么意思?

Can you please suggest what is meant by not present in list of covariates?

为了找到协变量,我遇到了以下代码:程序协变量,rclass版本 8

To find covariates I came across this code: program covars, rclass version 8

    capture local Covars : colnames e(b) 
    if _rc error 301 

    tempname b 
    mat `b' = e(b) 
    tokenize `Covars' 
    local k = 0 

    forval j = 1/`= colsof(`b')' {
        if "``j''" != "_cons" & `b'[1,`j'] != 0 { 
            local covars "`covars'``j'' " 
            local ++k 
        }
    }

    if `k' { 
        di as txt "{p}`covars'{p_end}" 
        return local covars "`covars'" 
        c_local covars "`covars'" 
    }   
end 

我跑了

covars

之后..在协变量列表中,上面的变量没有列出..该协变量列表与我的数据集中的变量不同吗?Stata 如何确定什么是协变量?

after that .. in the list of covariates, the above variable is not listed .. Is that list of covariates different from the variables in my dataset? How does Stata determine what is a covariate?

推荐答案

协变量是之前模型中使用的协变量.也就是说,margins 始终遵循建模命令,在您的情况下为 xtmixed,协变量是该模型调用中命名的响应(第一个命名变量)以外的变量.

The covariates are those used as such in the previous model. That is, margins always follows a modelling command, in your case xtmixed, and the covariates are the variables other than the response (first-named variable) named in that model call.

您可能知道协变量是预测变量,甚至是自变量,或通过其他一些术语.但是对于 Stata 来说,协变量当然不仅仅是数据集中的任何变量;它们必须已在您的模型调用中命名.

You may know covariates as predictors or even independent variables or through some other terminology. But for Stata covariates are certainly not just any variables in your dataset; they must have been named in your model call.

如果您对此不清楚,请在您的 margins 调用之前向我们展示确切的 xtmixed 命令.

If this isn't clear to you, show us the exact xtmixed command preceding your margins call.

Stata 不能对不在数据集中的变量做任何事情也就不足为奇了!

It shouldn't be surprising that Stata can't do anything with a variable not in the dataset!

这篇关于Stata 错误:在协变量列表中找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆