固定截距和计算Pykalman回归的R2的多元回归

发布于 2025-02-02 06:21:03 字数 1169 浏览 2 评论 0原文

我正在使用Pykalman模块进行以下回归:y = b1 * x1 + b2 * x2 +互感。 我想在整个回归中保持截距不变。

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

trans_cov = delta / (1 - delta) * np.eye(3) \
obs_mat = np.vstack( [df['X1'], df['X2'],np.ones(df['X1'].shape)]).T[:, np.newaxis]

from pykalman import KalmanFilter
    kf = KalmanFilter(
    n_dim_obs=1,\
    n_dim_state=3,\
    initial_state_mean=np.zeros(3),\
    initial_state_covariance=np.ones((3, 3)),\
    transition_matrices=np.eye(3),\
    observation_matrices=obs_mat,\
    observation_covariance=1.0,\
    transition_covariance=trans_cov )

    **state_means**, state_covs = kf.filter(df['Y'].values) 

state_means 的输出具有随时间变化的截距值。
- Pykalman有没有办法获得固定的拦截
- 如何计算上卡尔曼回归的r ** 2?

数据: 在此处输入图像描述

结果:

在此处输入图像描述

我正在寻找 contand buntst intercept的结果。

I am using the pykalman module to do the following regression: Y = b1 * x1 + b2 * x2 + intercept.
I would like to keep the intercept constant for the entire regression.

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

trans_cov = delta / (1 - delta) * np.eye(3) \
obs_mat = np.vstack( [df['X1'], df['X2'],np.ones(df['X1'].shape)]).T[:, np.newaxis]

from pykalman import KalmanFilter
    kf = KalmanFilter(
    n_dim_obs=1,\
    n_dim_state=3,\
    initial_state_mean=np.zeros(3),\
    initial_state_covariance=np.ones((3, 3)),\
    transition_matrices=np.eye(3),\
    observation_matrices=obs_mat,\
    observation_covariance=1.0,\
    transition_covariance=trans_cov )

    **state_means**, state_covs = kf.filter(df['Y'].values) 

The output of state_means has time-varying intercept values.
- Is there a way in pykalman to get fixed intercept
- How can I compute the R**2 of the pykalman regression?

DATA:
enter image description here

RESULTS:

enter image description here

I am looking for a result with constant intercept.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文