# -*-
coding: utf-8 -*-
"""
Created on Sat Feb 13 12:28:07 2016
@author: Bernard
"""
import pandas
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
import seaborn
data = pandas.read_csv('gapminder_ghana_updated.csv')
data["incomeperperson"] =
data["incomeperperson"].convert_objects(convert_numeric=True)
data['lifeexpectancy'] = data['lifeexpectancy'].convert_objects(convert_numeric=True)
# listwise deletion of missing values
dataSub = data[['incomeperperson',
'lifeexpectancy']].dropna()
scat1 = seaborn.regplot(x="incomeperperson",
y="lifeexpectancy", scatter=True, data=dataSub)
plt.xlabel('Income Per Person')
plt.ylabel('Life Expectancy')
plt.title ('Scatterplot for the Association Between Income
Per Person and Life Expectancy of the People Of Ghana')
print(scat1)
# center quantitative Explanatory variable for regression
analysis
dataSub['incomeperperson_c'] = (dataSub['incomeperperson'] -
dataSub['incomeperperson'].mean())
print("Describe the centered quantitative Explanatory
variable")
ds0 = dataSub["incomeperperson_c"].describe()
print(ds0)
# printing mean
print("Mean for centered quantitative explanatory
variable: incomeperperson_c")
ds1 = dataSub.groupby('incomeperperson_c').mean()
print (ds1)
print("Standard deviation for centered quantitative
explanatory variable:incomeperperson_c")
sd1 = dataSub.groupby('incomeperperson_c').std()
print (sd1)
print("Mean for quantitative explanatory variable:
incomeperperson")
ds2 = dataSub.groupby('incomeperperson').mean()
print (ds2)
print("Checking values in incomeperperson_c")
print(dataSub["incomeperperson_c"])
#Value counts
print("Counts for incomeperperson_c")
inc_c_Count =
dataSub["incomeperperson_c"].value_counts(sort = False ,dropna=False)
#dropna displays missen values
print(inc_c_Count)
print ("OLS regression model for the association
between Income Per Person and Life Expectancy of the People of Ghana")
reg1 = smf.ols('lifeexpectancy ~ incomeperperson_c',
data=dataSub).fit()
print (reg1.summary())
You’ve got interesting articles here. Your site can go viral,
you need some initial traffic only. How to get initial traffic??
Search google for: marihhu’s tips
Thanks regarding supplying this sort of terrific content.
You are welcome.
Heya this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you
have to manually code with HTML. I’m starting a blog soon but have no coding know-how so I wanted to get guidance from someone with experience.
Any help would be greatly appreciated!
It depends on the platform you are using.
If you use WordPress and other establised blogging platforms, you will get many WYSIWYG plugins which you can install easily.
If you want to learn HTML, by the way, there a lot of free resources online, and you can search on google.
Youtube is also a good place to start.
All the best
I got this website from my friend who shared with me on the topic of this web page and at the moment
this time I am browsing this site and reading very informative posts at this place.
Quality posts is the main to attract the viewers to pay a quick visit the website, that’s what this
website is providing.
Hi, i read youjr blog occdasionally and i
own a similar one andd i was just wondering if you get a lot of
spam comments? If so hoow doo you stop it, any plugin or anything you can recommend?
I get so much latelpy it’s driving me insane sso any help is very
much appreciated.
I read through all comments and I flag the spams as spam once I finish reading it.
Very quickly this website is going to be famous amid all blogging and site-building viewers, because of it’s fastidious articles or reviews
Your way of explaining everything with this paragraph is really fastidious, all be competent
at simply understand it, Thanks a lot.