[파이썬] statsmodels 추정량 속성

In statistics and econometrics, estimation refers to the process of estimating unknown model parameters using observed data. Statsmodels is a popular Python library that provides a wide range of statistical models and tools for estimating these parameters.

After fitting a statistical model using Statsmodels, you can access various attributes of the estimated parameters. These attributes provide valuable information about the estimated model and its performance. In this blog post, we will explore some of the commonly used estimation attributes in Statsmodels and how to access them using Python.

1. params

The params attribute returns the estimated parameters of the model as a Pandas Series or DataFrame object. The index of this object represents the names of the estimated parameters, while the values correspond to their estimated values.

import statsmodels.api as sm

# Fit a linear regression model
X = sm.add_constant(X)
model = sm.OLS(y, X).fit()

# Access the estimated parameters
estimated_params = model.params
print(estimated_params)

2. bse

The bse attribute provides the standard errors of the estimated parameters. These standard errors measure the uncertainty associated with the estimated values. Like params, the bse attribute returns a Pandas Series or DataFrame object that contains the standard errors of the estimated parameters.

# Access the estimated parameter standard errors
parameter_standard_errors = model.bse
print(parameter_standard_errors)

3. tvalues and pvalues

The tvalues attribute returns the t-statistics of the estimated parameters. T-statistics measure the estimated parameter’s significance by evaluating its estimated value relative to its standard error.

The pvalues attribute provides the p-values of the estimated parameters. P-values indicate the statistical significance of the estimated parameters. Lower p-values suggest higher significance and indicate that the estimated parameter is unlikely to be zero.

# Access the t-values and p-values of the estimated parameters
t_values = model.tvalues
p_values = model.pvalues
print(t_values)
print(p_values)

4. rsquared and rsquared_adj

The rsquared attribute calculates the coefficient of determination (R-squared) of the estimated model. R-squared represents the proportion of the variance in the dependent variable that is explained by the independent variables in the model. The rsquared_adj attribute is an adjusted version of R-squared that accounts for the number of predictors in the model.

# Access the R-squared and adjusted R-squared values
r_squared = model.rsquared
adjusted_r_squared = model.rsquared_adj
print(r_squared)
print(adjusted_r_squared)

Conclusion

In this blog post, we discussed some of the commonly used estimation attributes in Statsmodels. These attributes provide valuable information about the estimated model parameters, including estimated values, standard errors, t-statistics, p-values, and goodness-of-fit measures such as R-squared and adjusted R-squared. By accessing these attributes, you can gain insights into the estimated model’s performance and statistical significance.