Getting started — statsmodels | Statsmodels pandas

The pandas.read_csv function can be used to convert a comma-separated values file to a DataFrame object. patsy is a Python library ...Skiptocontentstatsmodelsv0.13.0.dev0(+600)statsmodelsInstallingstatsmodelsGettingstartedGettingstartedContentsGettingstartedLoadingmodulesandfunctionsDataSubstantivemotivationandmodelDesignmatrices(endog&exog)ModelfitandsummaryDiagnosticsandspecificationtestsDocumentationMoreShowSourceLoadingmodulesandfunctionsDataSubstantivemotivationandmodelDesignmatrices(endog&exog)ModelfitandsummaryDiagnosticsandspecificationtestsDocumentationstatsmodels.tools.web.webdocMoreUserGuideExamplesAPIReferenceAboutstatsmodelsDeveloperPageReleaseNotesContentsGettingstartedLoadingmodulesandfunctionsDataSubstantivemotivationandmodelDesignmatrices(endog&exog)ModelfitandsummaryDiagnosticsandspecificationtestsDocumentationMoreShowSourceGettingstarted¶Thisverysimplecase-studyisdesignedtogetyouup-and-runningquicklywithstatsmodels.Startingfromrawdata,wewillshowthestepsneededtoestimateastatisticalmodelandtodrawadiagnosticplot.Wewillonlyusefunctionsprovidedbystatsmodelsoritspandasandpatsydependencies.Loadingmodulesandfunctions¶Afterinstallingstatsmodelsanditsdependencies,weloadafewmodulesandfunctions:In[1]:importstatsmodels.apiassmIn[2]:importpandasIn[3]:frompatsyimportdmatricespandasbuildsonnumpyarraystoproviderichdatastructuresanddataanalysistools.Thepandas.DataFramefunctionprovideslabelledarraysof(potentiallyheterogenous)data,similartotheR“data.frame”.Thepandas.read_csvfunctioncanbeusedtoconvertacomma-separatedvaluesfiletoaDataFrameobject.patsyisaPythonlibraryfordescribingstatisticalmodelsandbuildingDesignMatricesusingR-likeformulas.NoteThisexampleusestheAPIinterface.SeeImportPathsandStructureforinformationonthedifferencebetweenimportingtheAPIinterfaces(statsmodels.apiandstatsmodels.tsa.api)anddirectlyimportingfromthemodulethatdefinesthemodel.Data¶WedownloadtheGuerrydataset,acollectionofhistoricaldatausedinsupportofAndre-MichelGuerry’s1833EssayontheMoralStatisti


常見投資理財問答


延伸文章資訊