微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

计算相关性并对具有不同观察值数量的变量进行2SLS回归

如何解决计算相关性并对具有不同观察值数量的变量进行2SLS回归

要进行2SLS回归,我首先需要获取educ和fatheduc两个变量之间的相关性。

其中一个(仪器,fatheduc)具有一些NA值,而我不使用它们:

# Default Virtual Host configuration.

# Let Apache kNow we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache/htdocs"
  # BEGIN: Configuration for letsencrypt
  Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
  # END: Configuration for letsencrypt
  # BEGIN: Support domain renewal when using mod_proxy without Location
  <IfModule mod_proxy.c>
    ProxyPass /.well-kNown !
  </IfModule>
  # END: Support domain renewal when using mod_proxy without Location
  # BEGIN: Enable HTTP to HTTPS redirection
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^localhost
  RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
  RewriteCond %{REQUEST_URI} !^/\.well-kNown
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  # END: Enable HTTP to HTTPS redirection
  <Directory "/opt/bitnami/apache/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html
  #Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
  # BEGIN: Support domain renewal when using mod_proxy within Location
  <Location /.well-kNown>
    <IfModule mod_proxy.c>
      ProxyPass !
    </IfModule>
  </Location>
  # END: Support domain renewal when using mod_proxy within Location
</VirtualHost>

Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"

但是现在我的两个变量的维数不同,这意味着找到相关性并进行第一阶段回归是不可能的。我该怎么办?

解决方法

educ和fathereduc中的行是同一个人的观察,因此您不能(不仅仅因为代码不会运行)从fathereduc中移除观察,而不是从educ中移除,您需要移除个人,即移除行来自两个变量。

educ = educ[-which(is.na(fathereduc))] #you need to run this before removing the NA's from fathereduc
fatheduc = na.omit(fatheduc)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。