100% found this document useful (1 vote)
80 views2 pages

Regressao Linear Simples - Ipynb - Colaboratory

The document performs a simple linear regression analysis to model the relationship between propaganda (x) and vendas (y) using 5 data points. It finds a strong positive correlation between the two variables and that propaganda is a statistically significant predictor of vendas. The linear regression model fits the data well with an R-squared of 0.96 and the estimated relationship is that for every 1 unit increase in propaganda, vendas increases by 1.7 units on average after controlling for the intercept.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
80 views2 pages

Regressao Linear Simples - Ipynb - Colaboratory

The document performs a simple linear regression analysis to model the relationship between propaganda (x) and vendas (y) using 5 data points. It finds a strong positive correlation between the two variables and that propaganda is a statistically significant predictor of vendas. The linear regression model fits the data well with an R-squared of 0.96 and the estimated relationship is that for every 1 unit increase in propaganda, vendas increases by 1.7 units on average after controlling for the intercept.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

12/03/2022 10:46 regressao_linear_simples.

ipynb - Colaboratory

1 import pandas as pd
2 import statsmodels.formula.api as smf
3 import seaborn as sn

1 propaganda = [1,2,3,4,5]
2 vendas = [1,2,4,5,8]
3 df = pd.DataFrame(list(zip(propaganda,vendas)), 
4                   columns = ['propaganda','vendas'])
5 df

propaganda vendas

0 1 1

1 2 2

2 3 4

3 4 5

4 5 8

1 df.corr(method ='pearson')

propaganda vendas

propaganda 1.000000 0.981495

vendas 0.981495 1.000000

1 correlation = df.corr(method ='pearson')
2 plot = sn.heatmap(correlation, annot = True, fmt=".4f", linewidths=.6)
3 plot

<matplotlib.axes._subplots.AxesSubplot at 0x7fcf373f09d0>

1
model = smf.ols(formula='vendas ~ propaganda', data=df)

2
resultado = model.fit()

https://colab.research.google.com/drive/1U7tF96iZuuNj0E_DDHH155dbJYWc_eLK#scrollTo=6W9IAprWS8j3&printMode=true 1/2
12/03/2022 10:46 regressao_linear_simples.ipynb - Colaboratory

3
print(resultado.summary())

OLS Regression Results


=============================================================================
Dep. Variable: vendas R-squared: 0.96
Model: OLS Adj. R-squared: 0.95
Method: Least Squares F-statistic: 78.8
Date: Sat, 12 Mar 2022 Prob (F-statistic): 0.0030
Time: 13:23:52 Log-Likelihood: -3.309
No. Observations: 5 AIC: 10.6
Df Residuals: 3 BIC: 9.83
Df Model: 1
Covariance Type: nonrobust
=============================================================================
coef std err t P>|t| [0.025 0.975
-----------------------------------------------------------------------------
Intercept -1.1000 0.635 -1.732 0.182 -3.121 0.92
propaganda 1.7000 0.191 8.878 0.003 1.091 2.30
=============================================================================
Omnibus: nan Durbin-Watson: 2.50
Prob(Omnibus): nan Jarque-Bera (JB): 0.39
Skew: -0.174 Prob(JB): 0.82
Kurtosis: 1.667 Cond. No. 8.3
=============================================================================

Warnings:

[1] Standard Errors assume that the covariance matrix of the errors is correc
/usr/local/lib/python3.7/dist-packages/statsmodels/stats/stattools.py:71: Val
"samples were given." % int(n), ValueWarning)

check 0s conclusão: 10:46

https://colab.research.google.com/drive/1U7tF96iZuuNj0E_DDHH155dbJYWc_eLK#scrollTo=6W9IAprWS8j3&printMode=true 2/2

You might also like